11#ifndef __AUDACITY_AUDIO_IO_BASE__
12#define __AUDACITY_AUDIO_IO_BASE__
40#define BAD_STREAM_TIME (-DBL_MAX)
49 const std::shared_ptr<AudacityProject> &
pProject = {},
50 double rate_ = 44100.0
103 :
public NonInterferingBase
114 void SetCaptureMeter(
115 const std::shared_ptr<AudacityProject> &
project,
const std::weak_ptr<Meter> &meter);
116 void SetPlaybackMeter(
117 const std::shared_ptr<AudacityProject> &
project,
const std::weak_ptr<Meter> &meter);
127 void HandleDeviceChange();
139 static std::vector<long> GetSupportedPlaybackRates(
int DevIndex = -1);
156 static long GetClosestSupportedPlaybackRate(
int devIndex,
long rate);
168 static std::vector<long> GetSupportedCaptureRates(
int devIndex = -1);
185 static long GetClosestSupportedCaptureRate(
int devIndex,
long rate);
199 static std::vector<long> GetSupportedSampleRates(
int playDevice = -1,
217 static long GetClosestSupportedSampleRate(
int playDevice,
218 int recDevice,
long rate);
228 static int GetOptimalSupportedSampleRate();
235 static bool IsPlaybackRateSupported(
int devIndex,
long rate);
242 static bool IsCaptureRateSupported(
int devIndex,
long rate);
248 static const int StandardRates[];
255 wxString GetDeviceInfo()
const;
258 std::vector<AudioIODiagnostics> GetAllDeviceInfo();
261 bool IsPaused()
const;
277 bool IsStreamActive()
const;
278 bool IsStreamActive(
int token)
const;
285 bool IsAudioTokenActive(
int token)
const;
289 bool IsMonitoring()
const;
297 void SetMixer(
int inputSource);
301 static wxString DeviceName(
const PaDeviceInfo* info);
302 static wxString HostName(
const PaDeviceInfo* info);
307 std::atomic<bool> mPaused{
false };
310 int mStreamToken{ 0 };
318 std::weak_ptr<Meter> mInputMeter{};
319 std::weak_ptr<Meter> mOutputMeter{};
323 float mPreviousHWPlaythrough;
351 static int getRecordDevIndex(
const wxString &devName = {});
358 static int getRecordSourceIndex(PxMixer *portMixer);
368 static int getPlayDevIndex(
const wxString &devName = {});
374 static const int RatesToTry[];
AUDIO_DEVICES_API IntSetting AudioIORecordChannels
AUDIO_DEVICES_API DoubleSetting AudioIOLatencyCorrection
AUDIO_DEVICES_API StringSetting AudioIOHost
AUDIO_DEVICES_API StringSetting AudioIORecordingSource
AUDIO_DEVICES_API StringSetting AudioIOPlaybackSource
AUDIO_DEVICES_API DoubleSetting AudioIOLatencyDuration
AUDIO_DEVICES_API StringSetting AudioIOPlaybackDevice
AUDIO_DEVICES_API DoubleSetting AudioIOPlaybackVolume
AUDIO_DEVICES_API StringSetting AudioIORecordingDevice
std::vector< std::vector< float > > PRCrossfadeData
AUDIO_DEVICES_API IntSetting AudioIORecordingSourceIndex
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
A singleton object supporting queries of the state of any active audio streams, and audio device capa...
PaStream * mPortStreamV19
static std::map< std::pair< int, int >, std::vector< long > > mCachedSampleRates
double mRate
Audio playback rate in samples per second.
AudioIOBase & operator=(const AudioIOBase &)=delete
static int mCurrentPlaybackIndex
static std::unique_ptr< AudioIOBase > ugAudioIO
std::vector< std::unique_ptr< AudioIOExtBase > > mAudioIOExt
static double mCachedBestRateIn
virtual void StopStream()=0
static int mCurrentCaptureIndex
AudioIOBase(const AudioIOBase &)=delete
static std::map< int, std::vector< long > > mCachedCaptureRates
std::weak_ptr< AudacityProject > mOwningProject
static std::map< int, std::vector< long > > mCachedPlaybackRates
bool mInputMixerWorks
Can we control the hardware input level?
static const int NumRatesToTry
How many sample rates to try.
static const int NumStandardRates
How many standard sample rates there are.
Abstract interface to alternative, concurrent playback with the main audio (such as MIDI events)
virtual bool IsOtherStreamActive() const =0
virtual AudioIODiagnostics Dump() const =0
Get diagnostic information for audio devices and also for extensions.
virtual ~AudioIOExtBase()
Monitors record play start/stop and new sample blocks. Has callbacks for these events.
Specialization of Setting for double.
Specialization of Setting for int.
AudioIO uses this to send sample buffers for real-time display updates.
Directs which parts of tracks to fetch for playback.
Specialization of Setting for strings.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
std::function< std::chrono::milliseconds() > playbackStreamPrimer
PolicyFactory policyFactory
std::shared_ptr< AudacityProject > pProject
std::weak_ptr< Meter > captureMeter
std::weak_ptr< Meter > playbackMeter
AudioIOStartStreamOptions(const std::shared_ptr< AudacityProject > &pProject={}, double rate_=44100.0)
PRCrossfadeData * pCrossfadeData
const BoundedEnvelope * envelope
std::function< std::unique_ptr< PlaybackPolicy >(const AudioIOStartStreamOptions &) > PolicyFactory
std::optional< double > pStartTime
std::shared_ptr< AudioIOListener > listener