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 56 of file ProjectAudioIO.cpp.

58{
59}
const auto project
AudacityProject & mProject

◆ ProjectAudioIO() [2/2]

ProjectAudioIO::ProjectAudioIO ( const ProjectAudioIO )
delete

◆ ~ProjectAudioIO()

ProjectAudioIO::~ProjectAudioIO ( )

Definition at line 61 of file ProjectAudioIO.cpp.

62{
63}

Member Function Documentation

◆ DefaultOptionsFactory()

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

Default factory function ignores the second argument.

Definition at line 19 of file ProjectAudioIO.cpp.

20{
21 auto &projectAudioIO = Get(project);
23 project.shared_from_this(), ProjectRate::Get(project).GetRate()
24 };
25 options.captureMeter = projectAudioIO.GetCaptureMeter();
26 options.playbackMeter = projectAudioIO.GetPlaybackMeter();
27 options.envelope =
29 // options.listener remains null
30 // boolean argument is ignored
31 return options;
32}
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
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 AudacityProject *) >::Call(), Get(), ProjectRate::Get(), ProjectRate::GetRate(), and project.

Here is the call graph for this function:

◆ Get() [1/2]

ProjectAudioIO & ProjectAudioIO::Get ( AudacityProject project)
static

Definition at line 46 of file ProjectAudioIO.cpp.

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

References project, and sAudioIOKey.

Referenced by AudioIOBusyPred(), StretchHandle::Click(), CutlineHandle::Click(), SampleHandle::Click(), WaveClipAdjustBorderHandle::Click(), EnvelopeHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), TrackSelectHandle::Click(), CloseButtonHandle::CommitChanges(), Scrubber::ContinueScrubbingPoll(), 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(), DefaultPlaybackPolicy::GetPlaySpeed(), LabelGlyphHandle::HandleGlyphDragRelease(), anonymous_namespace{AdornedRulerPanel.cpp}::PlayheadHandle::HitTest(), anonymous_namespace{WaveTrackControls.cpp}::initFn(), DefaultPlaybackPolicy::Initialize(), TrackPanel::IsAudioActive(), Scrubber::IsScrubbing(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), Scrubber::MarkScrubStart(), 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(), MixerBoard::OnTimer(), PlayIndicatorOverlay::OnTimer(), ProjectManager::OnTimer(), TrackPanel::OnTimer(), anonymous_namespace{TrackMenus.cpp}::OnTrackClose(), anonymous_namespace{ViewMenus.cpp}::OnZoomIn(), ProjectAudioManager::PlayPlayRegion(), PitchAndSpeedDialog::PopulateOrExchange(), WaveClipAdjustBorderHandle::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(), and AdornedRulerPanel::ScrubbingRulerOverlay::Update().

◆ Get() [2/2]

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

Definition at line 51 of file ProjectAudioIO.cpp.

52{
53 return Get( const_cast<AudacityProject &>(project) );
54}
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(), and project.

Referenced by Get().

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

◆ GetAudioIOToken()

int ProjectAudioIO::GetAudioIOToken ( ) const

Definition at line 65 of file ProjectAudioIO.cpp.

66{
67 return mAudioIOToken;
68}

References mAudioIOToken.

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

Here is the caller graph for this function:

◆ GetCaptureMeter()

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

Definition at line 99 of file ProjectAudioIO.cpp.

100{
101 return mCaptureMeter;
102}
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 34 of file ProjectAudioIO.cpp.

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

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

Referenced by DefaultSpeedPlayOptions(), EffectPreview(), Scrubber::MaybeStartScrubbing(), 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(), anonymous_namespace{TransportMenus.cpp}::OnPunchAndRoll(), 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 82 of file ProjectAudioIO.cpp.

83{
84 return mPlaybackMeter;
85}
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 75 of file ProjectAudioIO.cpp.

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

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

Referenced by StretchHandle::Click(), CutlineHandle::Click(), SampleHandle::Click(), WaveClipAdjustBorderHandle::Click(), EnvelopeHandle::Click(), SelectHandle::Click(), TimeShiftHandle::Click(), TrackSelectHandle::Click(), 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(), SelectActions::Handler::OnCursorPositionStore(), anonymous_namespace{SelectMenus.cpp}::OnlyHandleKeyUp(), SelectActions::Handler::OnSelectCursorStoredCursor(), ProjectWindow::PlaybackScroller::OnTimer(), MixerBoard::OnTimer(), PlayIndicatorOverlay::OnTimer(), anonymous_namespace{TrackMenus.cpp}::OnTrackClose(), PitchAndSpeedDialog::PopulateOrExchange(), WaveClipAdjustBorderHandle::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 70 of file ProjectAudioIO.cpp.

71{
72 mAudioIOToken = token;
73}

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 104 of file ProjectAudioIO.cpp.

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

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

Here is the call graph for this function:

◆ SetPlaybackMeter()

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

Definition at line 87 of file ProjectAudioIO.cpp.

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

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

Here is the call graph for this function:

◆ SetPlaySpeed()

void ProjectAudioIO::SetPlaySpeed ( double  value)

Definition at line 117 of file ProjectAudioIO.cpp.

118{
119 if (auto oldValue = GetPlaySpeed(); value != oldValue) {
120 mPlaySpeed.store( value, std::memory_order_relaxed );
121 Publish({});
122 }
123}
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: