Audacity  3.0.3
ProjectAudioIO.cpp
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 ProjectAudioIO.cpp
6 
7 Paul Licameli split from AudacityProject.cpp
8 
9 **********************************************************************/
10 
11 #include "ProjectAudioIO.h"
12 
13 #include "AudioIOBase.h"
14 #include "Project.h"
15 
17  []( AudacityProject &parent ){
18  return std::make_shared< ProjectAudioIO >( parent );
19  }
20 };
21 
23 {
24  return project.AttachedObjects::Get< ProjectAudioIO >( sAudioIOKey );
25 }
26 
28 {
29  return Get( const_cast<AudacityProject &>(project) );
30 }
31 
33 : mProject{ project }
34 {
35 }
36 
38 {
39 }
40 
42 {
43  return mAudioIOToken;
44 }
45 
47 {
48  mAudioIOToken = token;
49 }
50 
52 {
53  auto gAudioIO = AudioIOBase::Get();
54  return GetAudioIOToken() > 0 &&
55  gAudioIO->IsStreamActive(GetAudioIOToken());
56 }
57 
58 const std::shared_ptr<Meter> &ProjectAudioIO::GetPlaybackMeter() const
59 {
60  return mPlaybackMeter;
61 }
62 
64  const std::shared_ptr<Meter> &playback)
65 {
66  auto &project = mProject;
67  mPlaybackMeter = playback;
68  auto gAudioIO = AudioIOBase::Get();
69  if (gAudioIO)
70  {
71  gAudioIO->SetPlaybackMeter( project.shared_from_this() , mPlaybackMeter );
72  }
73 }
74 
75 const std::shared_ptr<Meter> &ProjectAudioIO::GetCaptureMeter() const
76 {
77  return mCaptureMeter;
78 }
79 
81  const std::shared_ptr<Meter> &capture)
82 {
83  auto &project = mProject;
84  mCaptureMeter = capture;
85 
86  auto gAudioIO = AudioIOBase::Get();
87  if (gAudioIO)
88  {
89  gAudioIO->SetCaptureMeter( project.shared_from_this(), mCaptureMeter );
90  }
91 }
AudioIOBase.h
ProjectAudioIO::GetAudioIOToken
int GetAudioIOToken() const
Definition: ProjectAudioIO.cpp:41
ProjectAudioIO::ProjectAudioIO
ProjectAudioIO(AudacityProject &project)
Definition: ProjectAudioIO.cpp:32
Project.h
ProjectAudioIO::mProject
AudacityProject & mProject
Definition: ProjectAudioIO.h:47
ProjectAudioIO::Get
static ProjectAudioIO & Get(AudacityProject &project)
Definition: ProjectAudioIO.cpp:22
ProjectAudioIO::mAudioIOToken
int mAudioIOToken
Definition: ProjectAudioIO.h:53
ClientData::Site::RegisteredFactory
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:266
ProjectAudioIO::IsAudioActive
bool IsAudioActive() const
Definition: ProjectAudioIO.cpp:51
ProjectAudioIO::mPlaybackMeter
std::shared_ptr< Meter > mPlaybackMeter
Definition: ProjectAudioIO.h:50
ProjectAudioIO::SetPlaybackMeter
void SetPlaybackMeter(const std::shared_ptr< Meter > &playback)
Definition: ProjectAudioIO.cpp:63
ProjectAudioIO::GetCaptureMeter
const std::shared_ptr< Meter > & GetCaptureMeter() const
Definition: ProjectAudioIO.cpp:75
ProjectAudioIO::GetPlaybackMeter
const std::shared_ptr< Meter > & GetPlaybackMeter() const
Definition: ProjectAudioIO.cpp:58
AudioIOBase::Get
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:89
sAudioIOKey
static const AudacityProject::AttachedObjects::RegisteredFactory sAudioIOKey
Definition: ProjectAudioIO.cpp:16
ProjectAudioIO::SetAudioIOToken
void SetAudioIOToken(int token)
Definition: ProjectAudioIO.cpp:46
ProjectAudioIO::~ProjectAudioIO
~ProjectAudioIO()
Definition: ProjectAudioIO.cpp:37
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
ProjectAudioIO
Definition: ProjectAudioIO.h:25
ProjectAudioIO::SetCaptureMeter
void SetCaptureMeter(const std::shared_ptr< Meter > &capture)
Definition: ProjectAudioIO.cpp:80
ProjectAudioIO.h
ProjectAudioIO::mCaptureMeter
std::shared_ptr< Meter > mCaptureMeter
Definition: ProjectAudioIO.h:51