Audacity 3.2.0
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
ProjectAudioIO Class Referencefinal

#include <ProjectAudioIO.h>

Inheritance diagram for ProjectAudioIO:
[legend]
Collaboration diagram for ProjectAudioIO:
[legend]

Classes

struct  DefaultOptions
 

Public Member Functions

 ProjectAudioIO (AudacityProject &project)
 
 ProjectAudioIO (const ProjectAudioIO &)=delete
 
ProjectAudioIOoperator= (const ProjectAudioIO &)=delete
 
 ~ProjectAudioIO ()
 
int GetAudioIOToken () const
 
bool IsAudioActive () const
 
void SetAudioIOToken (int token)
 
const std::shared_ptr< Meter > & GetPlaybackMeter () const
 
void SetPlaybackMeter (const std::shared_ptr< Meter > &playback)
 
const std::shared_ptr< Meter > & GetCaptureMeter () const
 
void SetCaptureMeter (const std::shared_ptr< Meter > &capture)
 
double GetPlaySpeed () const
 
void SetPlaySpeed (double value)
 
- Public Member Functions inherited from ClientData::Base
virtual ~Base ()
 
- Public Member Functions inherited from Observer::Publisher< SpeedChangeMessage >
 Publisher (ExceptionPolicy *pPolicy=nullptr, Alloc a={})
 Constructor supporting type-erased custom allocation/deletion. More...
 
 Publisher (Publisher &&)=default
 
Publisheroperator= (Publisher &&)=default
 
Subscription Subscribe (Callback callback)
 Connect a callback to the Publisher; later-connected are called earlier. More...
 
Subscription Subscribe (Object &obj, Return(Object::*callback)(Args...))
 Overload of Subscribe takes an object and pointer-to-member-function. More...
 

Static Public Member Functions

static AudioIOStartStreamOptions DefaultOptionsFactory (AudacityProject &project, bool newDefaults)
 Default factory function ignores the second argument. More...
 
static AudioIOStartStreamOptions GetDefaultOptions (AudacityProject &project, bool newDefaults=false)
 Invoke the global hook, supplying a default argument. More...
 
static ProjectAudioIOGet (AudacityProject &project)
 
static const ProjectAudioIOGet (const AudacityProject &project)
 

Private Attributes

AudacityProjectmProject
 
std::shared_ptr< MetermPlaybackMeter
 
std::shared_ptr< MetermCaptureMeter
 
std::atomic< double > mPlaySpeed {}
 
int mAudioIOToken { -1 }
 

Additional Inherited Members

- Public Types inherited from Observer::Publisher< SpeedChangeMessage >
using message_type = SpeedChangeMessage
 
using CallbackReturn = std::conditional_t< true, void, bool >
 
using Callback = std::function< CallbackReturn(const SpeedChangeMessage &) >
 Type of functions that can be connected to the Publisher. More...
 
- Static Public Attributes inherited from Observer::Publisher< SpeedChangeMessage >
static constexpr bool notifies_all
 
- Protected Member Functions inherited from Observer::Publisher< SpeedChangeMessage >
CallbackReturn Publish (const SpeedChangeMessage &message)
 Send a message to connected callbacks. More...
 

Detailed Description

\ brief Holds per-project state needed for interaction with AudioIO, including the audio stream token and pointers to meters

Definition at line 29 of file ProjectAudioIO.h.

Constructor & Destructor Documentation

◆ ProjectAudioIO() [1/2]

ProjectAudioIO::ProjectAudioIO ( AudacityProject project)
explicit

Definition at line 57 of file ProjectAudioIO.cpp.

58: mProject{ project }
59{
60}
AudacityProject & mProject

◆ ProjectAudioIO() [2/2]

ProjectAudioIO::ProjectAudioIO ( const ProjectAudioIO )
delete

◆ ~ProjectAudioIO()

ProjectAudioIO::~ProjectAudioIO ( )

Definition at line 62 of file ProjectAudioIO.cpp.

63{
64}

Member Function Documentation

◆ DefaultOptionsFactory()

AudioIOStartStreamOptions ProjectAudioIO::DefaultOptionsFactory ( AudacityProject project,
bool  newDefaults 
)
static

Default factory function ignores the second argument.

Definition at line 20 of file ProjectAudioIO.cpp.

21{
22 auto &projectAudioIO = Get(project);
24 project.shared_from_this(), ProjectRate::Get(project).GetRate()
25 };
26 options.captureMeter = projectAudioIO.GetCaptureMeter();
27 options.playbackMeter = projectAudioIO.GetPlaybackMeter();
28 options.envelope =
30 // options.listener remains null
31 // boolean argument is ignored
32 return options;
33}
static result_type Call(Arguments &&...arguments)
Null check of the installed function is done for you.
static ProjectAudioIO & Get(AudacityProject &project)
static ProjectRate & Get(AudacityProject &project)
Definition: ProjectRate.cpp:28
double GetRate() const
Definition: ProjectRate.cpp:53
static TrackList & Get(AudacityProject &project)
Definition: Track.cpp:385
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:44

References GlobalHook< DefaultWarp, const BoundedEnvelope *(const TrackList &) >::Call(), Get(), ProjectRate::Get(), TrackList::Get(), and ProjectRate::GetRate().

Here is the call graph for this function:

◆ Get() [1/2]

ProjectAudioIO & ProjectAudioIO::Get ( AudacityProject project)
static

Definition at line 47 of file ProjectAudioIO.cpp.

48{
49 return project.AttachedObjects::Get< ProjectAudioIO >( sAudioIOKey );
50}
static const AudacityProject::AttachedObjects::RegisteredFactory sAudioIOKey

References sAudioIOKey.

Referenced by AudioIOBusyPred(), StretchHandle::Click(), CutlineHandle::Click(), SampleHandle::Click(), WaveClipTrimHandle::Click(), EnvelopeHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), TrackSelectHandle::Click(), SelectButtonHandle::CommitChanges(), CloseButtonHandle::CommitChanges(), DefaultOptionsFactory(), anonymous_namespace{SelectMenus.cpp}::DoBoundaryMove(), anonymous_namespace{SelectMenus.cpp}::DoCursorMove(), anonymous_namespace{TransportMenus.cpp}::DoMoveToLabel(), ProjectAudioManager::DoPlayStopSelect(), ProjectAudioManager::DoRecord(), TransportUtilities::DoStopPlaying(), StretchHandle::Drag(), SampleHandle::Drag(), EnvelopeHandle::Drag(), TimeShiftHandle::Drag(), TrackSelectHandle::Drag(), MeterToolBar::Expose(), Get(), DefaultPlaybackPolicy::GetPlaySpeed(), LabelGlyphHandle::HandleGlyphDragRelease(), anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::HitTest(), anonymous_namespace{WaveTrackControls.cpp}::initFn(), DefaultPlaybackPolicy::Initialize(), TrackPanel::IsAudioActive(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), Scrubber::MarkScrubStart(), ProjectWindow::MayScrollBeyondZero(), anonymous_namespace{LabelMenus.cpp}::OnAddLabelPlaying(), ProjectAudioManager::OnAudioIOStopRecording(), ProjectManager::OnCloseWindow(), SelectActions::Handler::OnCursorPositionStore(), TimeToolBar::OnIdle(), AudacityApp::OnKeyDown(), anonymous_namespace{SelectMenus.cpp}::OnlyHandleKeyUp(), SelectActions::Handler::OnSelectCursorStoredCursor(), SelectUtilities::OnSetRegion(), ProjectWindow::PlaybackScroller::OnTimer(), LyricsWindow::OnTimer(), MixerBoard::OnTimer(), PlayIndicatorOverlay::OnTimer(), ProjectManager::OnTimer(), TrackPanel::OnTimer(), anonymous_namespace{TrackMenus.cpp}::OnTrackClose(), ProjectAudioManager::PlayPlayRegion(), WaveClipTrimHandle::Preview(), AffordanceHandle::Preview(), StretchHandle::Preview(), CutlineHandle::Preview(), SampleHandle::Preview(), EnvelopeHandle::Preview(), TimeShiftHandle::Preview(), TrackSelectHandle::Preview(), MeterToolBar::ReCreateButtons(), StretchHandle::Release(), SampleHandle::Release(), EnvelopeHandle::Release(), TimeShiftHandle::Release(), anonymous_namespace{SelectMenus.cpp}::SeekLeftOrRight(), TranscriptionToolBar::SetPlaySpeed(), ProjectAudioManager::Stop(), AdornedRulerPanel::ScrubbingRulerOverlay::Update(), and ProjectWindow::ZoomInByFactor().

◆ Get() [2/2]

const ProjectAudioIO & ProjectAudioIO::Get ( const AudacityProject project)
static

Definition at line 52 of file ProjectAudioIO.cpp.

53{
54 return Get( const_cast<AudacityProject &>(project) );
55}
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90

References Get().

Here is the call graph for this function:

◆ GetAudioIOToken()

int ProjectAudioIO::GetAudioIOToken ( ) const

Definition at line 66 of file ProjectAudioIO.cpp.

67{
68 return mAudioIOToken;
69}

References mAudioIOToken.

Referenced by ProjectAudioManager::DoPlayStopSelect(), TransportUtilities::DoStopPlaying(), IsAudioActive(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), anonymous_namespace{LabelMenus.cpp}::OnAddLabelPlaying(), AudacityApp::OnKeyDown(), SelectUtilities::OnSetRegion(), and ProjectWindow::ZoomInByFactor().

Here is the caller graph for this function:

◆ GetCaptureMeter()

const std::shared_ptr< Meter > & ProjectAudioIO::GetCaptureMeter ( ) const

Definition at line 100 of file ProjectAudioIO.cpp.

101{
102 return mCaptureMeter;
103}
std::shared_ptr< Meter > mCaptureMeter

References mCaptureMeter.

◆ GetDefaultOptions()

AudioIOStartStreamOptions ProjectAudioIO::GetDefaultOptions ( AudacityProject project,
bool  newDefaults = false 
)
static

Invoke the global hook, supplying a default argument.

Parameters
newDefaultsif true, policy is meant to respond to looping region; but specifying that is outside this library's scope

Definition at line 35 of file ProjectAudioIO.cpp.

37{
38 return DefaultOptions::Call(project, newDefaults);
39}

References GlobalHook< DefaultOptions, std::remove_pointer_t< decltype(DefaultFunction)>, DefaultFunction, Options... >::Call().

Referenced by DefaultSpeedPlayOptions(), EffectPreview(), anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayAfterSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeAndAfterSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionEnd(), anonymous_namespace{TransportMenus.cpp}::OnPlayBeforeSelectionStart(), anonymous_namespace{TransportMenus.cpp}::OnPlayOneSecond(), anonymous_namespace{TransportMenus.cpp}::OnPlayToSelection(), ProjectAudioManager::OnRecord(), TranscriptionToolBar::PlayAtSpeed(), ProjectAudioManager::PlayCurrentRegion(), MeterPanel::StartMonitoring(), and AdornedRulerPanel::StartQPPlay().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPlaybackMeter()

const std::shared_ptr< Meter > & ProjectAudioIO::GetPlaybackMeter ( ) const

Definition at line 83 of file ProjectAudioIO.cpp.

84{
85 return mPlaybackMeter;
86}
std::shared_ptr< Meter > mPlaybackMeter

References mPlaybackMeter.

◆ GetPlaySpeed()

double ProjectAudioIO::GetPlaySpeed ( ) const
inline

Definition at line 72 of file ProjectAudioIO.h.

72 {
73 return mPlaySpeed.load( std::memory_order_relaxed ); }
std::atomic< double > mPlaySpeed

Referenced by DefaultPlaybackPolicy::GetPlaySpeed(), and SetPlaySpeed().

Here is the caller graph for this function:

◆ IsAudioActive()

bool ProjectAudioIO::IsAudioActive ( ) const

Definition at line 76 of file ProjectAudioIO.cpp.

77{
78 auto gAudioIO = AudioIOBase::Get();
79 return GetAudioIOToken() > 0 &&
80 gAudioIO->IsStreamActive(GetAudioIOToken());
81}
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:93
int GetAudioIOToken() const

References AudioIOBase::Get(), and GetAudioIOToken().

Referenced by StretchHandle::Click(), CutlineHandle::Click(), SampleHandle::Click(), WaveClipTrimHandle::Click(), EnvelopeHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), TrackSelectHandle::Click(), SelectButtonHandle::CommitChanges(), CloseButtonHandle::CommitChanges(), anonymous_namespace{SelectMenus.cpp}::DoBoundaryMove(), StretchHandle::Drag(), SampleHandle::Drag(), EnvelopeHandle::Drag(), TimeShiftHandle::Drag(), TrackSelectHandle::Drag(), LabelGlyphHandle::HandleGlyphDragRelease(), anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::HitTest(), anonymous_namespace{WaveTrackControls.cpp}::initFn(), TrackPanel::IsAudioActive(), ProjectWindow::MayScrollBeyondZero(), SelectActions::Handler::OnCursorPositionStore(), anonymous_namespace{SelectMenus.cpp}::OnlyHandleKeyUp(), SelectActions::Handler::OnSelectCursorStoredCursor(), ProjectWindow::PlaybackScroller::OnTimer(), LyricsWindow::OnTimer(), MixerBoard::OnTimer(), PlayIndicatorOverlay::OnTimer(), anonymous_namespace{TrackMenus.cpp}::OnTrackClose(), WaveClipTrimHandle::Preview(), AffordanceHandle::Preview(), StretchHandle::Preview(), CutlineHandle::Preview(), SampleHandle::Preview(), EnvelopeHandle::Preview(), TimeShiftHandle::Preview(), TrackSelectHandle::Preview(), StretchHandle::Release(), SampleHandle::Release(), EnvelopeHandle::Release(), TimeShiftHandle::Release(), and AdornedRulerPanel::ScrubbingRulerOverlay::Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=()

ProjectAudioIO & ProjectAudioIO::operator= ( const ProjectAudioIO )
delete

◆ SetAudioIOToken()

void ProjectAudioIO::SetAudioIOToken ( int  token)

Definition at line 71 of file ProjectAudioIO.cpp.

72{
73 mAudioIOToken = token;
74}

References mAudioIOToken.

Referenced by ProjectAudioManager::DoRecord(), Scrubber::MarkScrubStart(), and ProjectAudioManager::PlayPlayRegion().

Here is the caller graph for this function:

◆ SetCaptureMeter()

void ProjectAudioIO::SetCaptureMeter ( const std::shared_ptr< Meter > &  capture)

Definition at line 105 of file ProjectAudioIO.cpp.

107{
108 auto &project = mProject;
109 mCaptureMeter = capture;
110
111 auto gAudioIO = AudioIOBase::Get();
112 if (gAudioIO)
113 {
114 gAudioIO->SetCaptureMeter( project.shared_from_this(), mCaptureMeter );
115 }
116}

References AudioIOBase::Get(), mCaptureMeter, and mProject.

Here is the call graph for this function:

◆ SetPlaybackMeter()

void ProjectAudioIO::SetPlaybackMeter ( const std::shared_ptr< Meter > &  playback)

Definition at line 88 of file ProjectAudioIO.cpp.

90{
91 auto &project = mProject;
92 mPlaybackMeter = playback;
93 auto gAudioIO = AudioIOBase::Get();
94 if (gAudioIO)
95 {
96 gAudioIO->SetPlaybackMeter( project.shared_from_this() , mPlaybackMeter );
97 }
98}

References AudioIOBase::Get(), mPlaybackMeter, and mProject.

Here is the call graph for this function:

◆ SetPlaySpeed()

void ProjectAudioIO::SetPlaySpeed ( double  value)

Definition at line 118 of file ProjectAudioIO.cpp.

119{
120 if (auto oldValue = GetPlaySpeed(); value != oldValue) {
121 mPlaySpeed.store( value, std::memory_order_relaxed );
122 Publish({});
123 }
124}
CallbackReturn Publish(const SpeedChangeMessage &message)
Send a message to connected callbacks.
Definition: Observer.h:207
double GetPlaySpeed() const

References GetPlaySpeed(), mPlaySpeed, and Observer::Publisher< SpeedChangeMessage >::Publish().

Referenced by TranscriptionToolBar::SetPlaySpeed().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ mAudioIOToken

int ProjectAudioIO::mAudioIOToken { -1 }
private

Definition at line 87 of file ProjectAudioIO.h.

Referenced by GetAudioIOToken(), and SetAudioIOToken().

◆ mCaptureMeter

std::shared_ptr<Meter> ProjectAudioIO::mCaptureMeter
private

Definition at line 81 of file ProjectAudioIO.h.

Referenced by GetCaptureMeter(), and SetCaptureMeter().

◆ mPlaybackMeter

std::shared_ptr<Meter> ProjectAudioIO::mPlaybackMeter
private

Definition at line 80 of file ProjectAudioIO.h.

Referenced by GetPlaybackMeter(), and SetPlaybackMeter().

◆ mPlaySpeed

std::atomic<double> ProjectAudioIO::mPlaySpeed {}
private

Definition at line 85 of file ProjectAudioIO.h.

Referenced by SetPlaySpeed().

◆ mProject

AudacityProject& ProjectAudioIO::mProject
private

Definition at line 77 of file ProjectAudioIO.h.

Referenced by SetCaptureMeter(), and SetPlaybackMeter().


The documentation for this class was generated from the following files: