![]() |
Audacity 3.2.0
|
A singleton object supporting queries of the state of any active audio streams, and audio device capabilities. More...
#include <AudioIOBase.h>
Public Member Functions | |
AudioIOBase () | |
virtual | ~AudioIOBase () |
AudioIOBase (const AudioIOBase &)=delete | |
AudioIOBase & | operator= (const AudioIOBase &)=delete |
void | SetCaptureMeter (const std::shared_ptr< AudacityProject > &project, const std::weak_ptr< Meter > &meter) |
void | SetPlaybackMeter (const std::shared_ptr< AudacityProject > &project, const std::weak_ptr< Meter > &meter) |
void | HandleDeviceChange () |
update state after changing what audio devices are selected More... | |
wxString | GetDeviceInfo () const |
Get diagnostic information on all the available audio I/O devices. More... | |
std::vector< AudioIODiagnostics > | GetAllDeviceInfo () |
Get diagnostic information for audio devices and also for extensions. More... | |
bool | IsPaused () const |
Find out if playback / recording is currently paused. More... | |
virtual void | StopStream ()=0 |
bool | IsBusy () const |
Returns true if audio i/o is busy starting, stopping, playing, or recording. More... | |
bool | IsStreamActive () const |
Returns true if the audio i/o is running at all, but not during cleanup. More... | |
bool | IsStreamActive (int token) const |
bool | IsAudioTokenActive (int token) const |
Returns true if the stream is active, or even if audio I/O is busy cleaning up its data or writing to disk. More... | |
bool | IsMonitoring () const |
Returns true if we're monitoring input (but not recording or playing actual audio) More... | |
void | SetMixer (int inputSource) |
Static Public Member Functions | |
static AudioIOBase * | Get () |
static std::vector< long > | GetSupportedPlaybackRates (int DevIndex=-1, double rate=0.0) |
Get a list of sample rates the output (playback) device supports. More... | |
static std::vector< long > | GetSupportedCaptureRates (int devIndex=-1, double rate=0.0) |
Get a list of sample rates the input (recording) device supports. More... | |
static std::vector< long > | GetSupportedSampleRates (int playDevice=-1, int recDevice=-1, double rate=0.0) |
Get a list of sample rates the current input/output device combination supports. More... | |
static int | GetOptimalSupportedSampleRate () |
Get a supported sample rate which can be used a an optimal default. More... | |
Static Public Attributes | |
static const int | StandardRates [] |
Array of common audio sample rates. More... | |
static const int | NumStandardRates = WXSIZEOF(AudioIOBase::StandardRates) |
How many standard sample rates there are. More... | |
Static Protected Member Functions | |
static wxString | DeviceName (const PaDeviceInfo *info) |
static wxString | HostName (const PaDeviceInfo *info) |
static int | getRecordDevIndex (const wxString &devName={}) |
get the index of the supplied (named) recording device, or the device selected in the preferences if none given. More... | |
static int | getPlayDevIndex (const wxString &devName={}) |
get the index of the device selected in the preferences. More... | |
Protected Attributes | |
std::weak_ptr< AudacityProject > | mOwningProject |
std::atomic< bool > | mPaused { false } |
True if audio playback is paused. More... | |
int | mStreamToken { 0 } |
double | mRate |
Audio playback rate in samples per second. More... | |
PaStream * | mPortStreamV19 |
std::weak_ptr< Meter > | mInputMeter {} |
std::weak_ptr< Meter > | mOutputMeter {} |
bool | mInputMixerWorks |
Can we control the hardware input level? More... | |
std::vector< std::unique_ptr< AudioIOExtBase > > | mAudioIOExt |
Static Protected Attributes | |
static std::unique_ptr< AudioIOBase > | ugAudioIO |
static int | mCachedPlaybackIndex = -1 |
static std::vector< long > | mCachedPlaybackRates |
static int | mCachedCaptureIndex = -1 |
static std::vector< long > | mCachedCaptureRates |
static std::vector< long > | mCachedSampleRates |
static double | mCachedBestRateIn = 0.0 |
static const int | RatesToTry [] |
Array of audio sample rates to try to use. More... | |
static const int | NumRatesToTry = WXSIZEOF(AudioIOBase::RatesToTry) |
How many sample rates to try. More... | |
A singleton object supporting queries of the state of any active audio streams, and audio device capabilities.
Definition at line 100 of file AudioIOBase.h.
|
default |
|
virtualdefault |
|
delete |
|
staticprotected |
Definition at line 75 of file AudioIOBase.cpp.
Referenced by GetDeviceInfo(), getPlayDevIndex(), getRecordDevIndex(), and AudioIO::Init().
|
static |
Definition at line 93 of file AudioIOBase.cpp.
References ugAudioIO.
Referenced by AudioIOBusyPred(), AudioSetupToolBar::CommonMenuItemSteps(), LabelTrackView::DoCaptureKey(), AdornedRulerPanel::DoSelectionChange(), TransportUtilities::DoStartPlaying(), TransportUtilities::DoStopPlaying(), LyricsPanel::DoUpdateLyrics(), cloud::ShareAudioToolbar::EnableDisableButtons(), AudioSetupToolBar::EnableDisableButtons(), DeviceToolBar::EnableDisableButtons(), AudioIO::Get(), GetMIDIDeviceInfo(), ProjectAudioIO::IsAudioActive(), ScrubState::IsScrubbing(), anonymous_namespace{TransportMenus.cpp}::MakeReadyToPlay(), anonymous_namespace{HelpMenus.cpp}::OnAudioDeviceInfo(), DeviceToolBar::OnChoice(), ControlToolBar::OnKeyEvent(), TranscriptionToolBar::OnKeyEvent(), PrefsDialog::OnOK(), NyqBench::OnRunUpdate(), anonymous_namespace{SpectrumView.cpp}::SpectrogramSettingsHandler::OnSpectrogramSettings(), PausedFlag(), TranscriptionToolBar::PlayAtSpeed(), DeviceManager::Rescan(), ProjectAudioIO::SetCaptureMeter(), ProjectAudioIO::SetPlaybackMeter(), and ProjectAudioManager::StopIfPaused().
auto AudioIOBase::GetAllDeviceInfo | ( | ) |
Get diagnostic information for audio devices and also for extensions.
Definition at line 926 of file AudioIOBase.cpp.
References wxT().
wxString AudioIOBase::GetDeviceInfo | ( | ) | const |
Get diagnostic information on all the available audio I/O devices.
Definition at line 697 of file AudioIOBase.cpp.
References AudioIOLatencyCorrection, AudioIOPlaybackDevice, AudioIORecordingDevice, DeviceName(), Setting< T >::GetDefault(), GetSupportedPlaybackRates(), GetSupportedSampleRates(), HostName(), IsStreamActive(), name, Setting< T >::Read(), wxT(), and XO().
|
static |
Get a supported sample rate which can be used a an optimal default.
Currently, this uses the first supported rate in the list [44100, 48000, highest sample rate]. Used in Project as a default value for project rates if one cannot be retrieved from the preferences. So all in all not that useful or important really
Definition at line 551 of file AudioIOBase.cpp.
References GetSupportedSampleRates(), and make_iterator_range().
|
staticprotected |
get the index of the device selected in the preferences.
If the device isn't found, returns -1
get the index of the supplied (named) playback device, or the device selected in the preferences if none given.
Pure utility function, but it comes round a number of times in the code and would be neater done once. If the device isn't found, return the default device index.
Definition at line 585 of file AudioIOBase.cpp.
References AudioIOHost, AudioIOPlaybackDevice, DeviceName(), and Setting< T >::Read().
Referenced by GetSupportedPlaybackRates(), GetSupportedSampleRates(), HandleDeviceChange(), AudioIO::Init(), AudioIO::StartPortAudioStream(), and AudioIO::ValidateDeviceNames().
|
staticprotected |
get the index of the supplied (named) recording device, or the device selected in the preferences if none given.
Pure utility function, but it comes round a number of times in the code and would be neater done once. If the device isn't found, return the default device index.
Definition at line 640 of file AudioIOBase.cpp.
References AudioIOHost, AudioIORecordingDevice, DeviceName(), and Setting< T >::Read().
Referenced by GetSupportedCaptureRates(), GetSupportedSampleRates(), HandleDeviceChange(), AudioIO::Init(), AudioIO::StartPortAudioStream(), and AudioIO::ValidateDeviceNames().
|
static |
Get a list of sample rates the input (recording) device supports.
If no information about available sample rates can be fetched, an empty list is returned.
You can explicitly give the index of the device. If you don't give it, the currently selected device from the preferences will be used.
You may also specify a rate for which to check in addition to the standard rates.
Definition at line 437 of file AudioIOBase.cpp.
References AudioIOLatencyDuration, AudioIORecordChannels, getRecordDevIndex(), make_iterator_range(), mCachedCaptureIndex, mCachedCaptureRates, NumRatesToTry, RatesToTry, Setting< T >::Read(), Setting< T >::ReadWithDefault(), and wxT().
Referenced by AudioIO::GetBestRate(), GetSupportedSampleRates(), and HandleDeviceChange().
|
static |
Get a list of sample rates the output (playback) device supports.
If no information about available sample rates can be fetched, an empty list is returned.
You can explicitly give the index of the device. If you don't give it, the currently selected device from the preferences will be used.
You may also specify a rate for which to check in addition to the standard rates.
Definition at line 372 of file AudioIOBase.cpp.
References getPlayDevIndex(), make_iterator_range(), mCachedPlaybackIndex, mCachedPlaybackRates, NumRatesToTry, RatesToTry, and wxT().
Referenced by AudioIO::GetBestRate(), GetDeviceInfo(), GetSupportedSampleRates(), and HandleDeviceChange().
|
static |
Get a list of sample rates the current input/output device combination supports.
Since there is no concept (yet) for different input/output sample rates, this currently returns only sample rates that are supported on both the output and input device. If no information about available sample rates can be fetched, it returns a default list. You can explicitly give the indexes of the playDevice/recDevice. If you don't give them, the selected devices from the preferences will be used. You may also specify a rate for which to check in addition to the standard rates.
Definition at line 506 of file AudioIOBase.cpp.
References getPlayDevIndex(), getRecordDevIndex(), GetSupportedCaptureRates(), GetSupportedPlaybackRates(), make_iterator_range(), mCachedCaptureIndex, mCachedPlaybackIndex, and mCachedSampleRates.
Referenced by AudioIO::GetBestRate(), GetDeviceInfo(), GetOptimalSupportedSampleRate(), and HandleDeviceChange().
void AudioIOBase::HandleDeviceChange | ( | ) |
update state after changing what audio devices are selected
Called when the devices stored in the preferences are changed to update the audio mixer capabilities
Definition at line 111 of file AudioIOBase.cpp.
References AudioIOLatencyCorrection, AudioIORecordingSourceIndex, Setting< T >::GetDefault(), getPlayDevIndex(), getRecordDevIndex(), GetSupportedCaptureRates(), GetSupportedPlaybackRates(), GetSupportedSampleRates(), IsStreamActive(), mCachedBestRateIn, mCachedCaptureIndex, mCachedCaptureRates, mCachedPlaybackIndex, mCachedPlaybackRates, mCachedSampleRates, mInputMixerWorks, Setting< T >::Read(), and SetMixer().
Referenced by AudioIO::AudioIO().
|
staticprotected |
Definition at line 82 of file AudioIOBase.cpp.
Referenced by GetDeviceInfo(), and AudioIO::Init().
bool AudioIOBase::IsAudioTokenActive | ( | int | token | ) | const |
Returns true if the stream is active, or even if audio I/O is busy cleaning up its data or writing to disk.
This is used by TrackPanel to determine when a track has been completely recorded, and it's safe to flush to disk.
Definition at line 362 of file AudioIOBase.cpp.
References mStreamToken.
Referenced by AudioIOBusyPred(), and IsStreamActive().
bool AudioIOBase::IsBusy | ( | ) | const |
Returns true if audio i/o is busy starting, stopping, playing, or recording.
When this is false, it's safe to start playing or recording
Definition at line 336 of file AudioIOBase.cpp.
References mStreamToken.
Referenced by AudioIoCallback::SetListener(), and AudioIO::StartStream().
bool AudioIOBase::IsMonitoring | ( | ) | const |
Returns true if we're monitoring input (but not recording or playing actual audio)
Definition at line 367 of file AudioIOBase.cpp.
References mPortStreamV19, and mStreamToken.
Referenced by AudioIO::AudioThread().
bool AudioIOBase::IsPaused | ( | ) | const |
Find out if playback / recording is currently paused.
Definition at line 331 of file AudioIOBase.cpp.
References mPaused.
Referenced by AudioIoCallback::AddToOutputChannel(), AudioIoCallback::AudioCallback(), AudioIoCallback::CallbackCheckCompletion(), AudioIoCallback::CheckSoundActivatedRecordingLevel(), PausedFlag(), AudioIO::SetPaused(), and AudioIoCallback::TrackShouldBeSilent().
bool AudioIOBase::IsStreamActive | ( | ) | const |
Returns true if the audio i/o is running at all, but not during cleanup.
Doesn't return true if the device has been closed but some disk i/o or cleanup is still going on. If you want to know if it's safe to start a NEW stream, use IsBusy()
Definition at line 344 of file AudioIOBase.cpp.
References mAudioIOExt, and mPortStreamV19.
Referenced by AudioIO::DrainRecordBuffers(), GetDeviceInfo(), AudioIO::GetStreamTime(), HandleDeviceChange(), AudioIO::IsCapturing(), and IsStreamActive().
bool AudioIOBase::IsStreamActive | ( | int | token | ) | const |
Definition at line 357 of file AudioIOBase.cpp.
References IsAudioTokenActive(), and IsStreamActive().
|
delete |
void AudioIOBase::SetCaptureMeter | ( | const std::shared_ptr< AudacityProject > & | project, |
const std::weak_ptr< Meter > & | meter | ||
) |
Definition at line 297 of file AudioIOBase.cpp.
References mInputMeter, mOwningProject, and mRate.
Referenced by AudioIO::StartPortAudioStream().
void AudioIOBase::SetMixer | ( | int | inputSource | ) |
Definition at line 102 of file AudioIOBase.cpp.
Referenced by HandleDeviceChange(), and AudioIO::SetMixer().
void AudioIOBase::SetPlaybackMeter | ( | const std::shared_ptr< AudacityProject > & | project, |
const std::weak_ptr< Meter > & | meter | ||
) |
Definition at line 314 of file AudioIOBase.cpp.
References mOutputMeter, mOwningProject, and mRate.
|
pure virtual |
Implemented in AudioIO.
|
protected |
This class needs to iterate this array for one limited purpose but does not populate it and does not give access to it except to subclasses
Definition at line 322 of file AudioIOBase.h.
Referenced by IsStreamActive().
|
staticprotected |
Definition at line 282 of file AudioIOBase.h.
Referenced by AudioIO::GetBestRate(), and HandleDeviceChange().
|
staticprotected |
Definition at line 279 of file AudioIOBase.h.
Referenced by GetSupportedCaptureRates(), GetSupportedSampleRates(), and HandleDeviceChange().
|
staticprotected |
Definition at line 280 of file AudioIOBase.h.
Referenced by GetSupportedCaptureRates(), and HandleDeviceChange().
|
staticprotected |
Definition at line 277 of file AudioIOBase.h.
Referenced by GetSupportedPlaybackRates(), GetSupportedSampleRates(), and HandleDeviceChange().
|
staticprotected |
Definition at line 278 of file AudioIOBase.h.
Referenced by GetSupportedPlaybackRates(), and HandleDeviceChange().
|
staticprotected |
Definition at line 281 of file AudioIOBase.h.
Referenced by GetSupportedSampleRates(), and HandleDeviceChange().
|
protected |
Definition at line 259 of file AudioIOBase.h.
Referenced by AudioIoCallback::SendVuInputMeterData(), SetCaptureMeter(), AudioIO::SetMeters(), AudioIO::StartPortAudioStream(), and AudioIO::StopStream().
|
protected |
Can we control the hardware input level?
This flag is set to true if using portmixer to control the input volume seems to be working (and so we offer the user the control), and to false (locking the control out) otherwise. This avoids stupid scaled clipping problems when trying to do software emulated input volume control
Definition at line 274 of file AudioIOBase.h.
Referenced by AudioIO::AudioIO(), AudioIO::GetMixer(), HandleDeviceChange(), and AudioIO::InputMixerWorks().
|
protected |
Definition at line 260 of file AudioIOBase.h.
Referenced by AudioIO::AudioIO(), AudioIoCallback::SendVuOutputMeterData(), AudioIO::SetMeters(), SetPlaybackMeter(), AudioIO::StartPortAudioStream(), and AudioIO::StopStream().
|
protected |
Definition at line 245 of file AudioIOBase.h.
Referenced by AudioIO::FillPlayBuffers(), AudioIO::IsAvailable(), AudioIO::ResetOwningProject(), SetCaptureMeter(), AudioIO::SetOwningProject(), AudioIO::SetPaused(), SetPlaybackMeter(), AudioIO::StartMonitoring(), AudioIO::StartPortAudioStream(), AudioIO::StartStream(), AudioIO::StopStream(), and AudioIO::~AudioIO().
|
protected |
True if audio playback is paused.
Definition at line 248 of file AudioIOBase.h.
Referenced by IsPaused(), and AudioIO::SetPaused().
|
protected |
Definition at line 257 of file AudioIOBase.h.
Referenced by AudioIO::AudioIO(), AudioIO::DelayingActions(), IsMonitoring(), IsStreamActive(), AudioIO::StartMonitoring(), AudioIO::StartPortAudioStream(), AudioIO::StartStream(), AudioIO::StartStreamCleanup(), and AudioIO::StopStream().
|
protected |
Audio playback rate in samples per second.
Read by worker threads but unchanging during playback
Definition at line 255 of file AudioIOBase.h.
Referenced by AudioIO::AllocateBuffers(), AudioIoCallback::AudioCallback(), AudioIoCallback::DrainInputBuffers(), AudioIO::DrainRecordBuffers(), SetCaptureMeter(), AudioIO::SetMeters(), SetPlaybackMeter(), AudioIO::StartMonitoring(), AudioIO::StartPortAudioStream(), AudioIO::StartStream(), AudioIO::StopStream(), and AudioIoCallback::UpdateTimePosition().
|
protected |
Read by worker threads but unchanging during playback
Definition at line 251 of file AudioIOBase.h.
Referenced by AudioIoCallback::AudioCallback(), AudioIoCallback::CallbackDoSeek(), AudioIoCallback::DrainInputBuffers(), AudioIoCallback::FillOutputBuffers(), IsAudioTokenActive(), IsBusy(), IsMonitoring(), AudioIO::StartMonitoring(), AudioIO::StartStream(), AudioIO::StartStreamCleanup(), AudioIO::StopStream(), and AudioIoCallback::UpdateTimePosition().
|
staticprotected |
How many sample rates to try.
Definition at line 317 of file AudioIOBase.h.
Referenced by GetSupportedCaptureRates(), and GetSupportedPlaybackRates().
|
static |
How many standard sample rates there are.
Definition at line 191 of file AudioIOBase.h.
Referenced by DevicePrefs::GetNamesAndLabels(), and ImportRawDialog::ImportRawDialog().
|
staticprotected |
Array of audio sample rates to try to use.
These are the rates we will check if a device supports, and is as long as I can think of (to try and work out what the card can do)
Definition at line 315 of file AudioIOBase.h.
Referenced by GetSupportedCaptureRates(), and GetSupportedPlaybackRates().
|
static |
Array of common audio sample rates.
These are the rates we will always support, regardless of hardware support for them (by resampling in audacity if needed)
Definition at line 189 of file AudioIOBase.h.
Referenced by DevicePrefs::GetNamesAndLabels(), and ImportRawDialog::ImportRawDialog().
|
staticprotected |
Definition at line 241 of file AudioIOBase.h.
Referenced by AudioIO::Deinit(), Get(), and AudioIO::Init().