Audacity  3.0.3
AudioIO.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  AudioIO.h
6 
7  Dominic Mazzoni
8 
9  Use the PortAudio library to play and record sound
10 
11 **********************************************************************/
12 
13 #ifndef __AUDACITY_AUDIO_IO__
14 #define __AUDACITY_AUDIO_IO__
15 
16 
17 
18 #include "AudioIOBase.h" // to inherit
19 #include "PlaybackSchedule.h" // member variable
20 
21 
22 
23 #include <memory>
24 #include <utility>
25 #include <wx/atomic.h> // member variable
26 
27 #ifdef EXPERIMENTAL_MIDI_OUT
28 typedef void PmStream;
29 typedef int32_t PmTimestamp;
30 
31 class Alg_seq;
32 class Alg_event;
33 class Alg_iterator;
34 
35 class NoteTrack;
36 using NoteTrackArray = std::vector < std::shared_ptr< NoteTrack > >;
37 using NoteTrackConstArray = std::vector < std::shared_ptr< const NoteTrack > >;
38 
39 #endif // EXPERIMENTAL_MIDI_OUT
40 
41 #include <wx/event.h> // to declare custom event types
42 
43 #include "SampleFormat.h"
44 
45 class wxArrayString;
46 class AudioIOBase;
47 class AudioIO;
48 class RingBuffer;
49 class Mixer;
50 class Resample;
51 class AudioThread;
52 class SelectedRegion;
53 
54 class AudacityProject;
55 
56 class WaveTrack;
57 using WaveTrackArray = std::vector < std::shared_ptr < WaveTrack > >;
58 using WaveTrackConstArray = std::vector < std::shared_ptr < const WaveTrack > >;
59 
60 struct PaStreamCallbackTimeInfo;
61 typedef unsigned long PaStreamCallbackFlags;
62 typedef int PaError;
63 
65 
66 #define MAX_MIDI_BUFFER_SIZE 5000
67 #define DEFAULT_SYNTH_LATENCY 5
68 
69 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
70  EVT_AUDIOIO_PLAYBACK, wxCommandEvent);
71 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
72  EVT_AUDIOIO_CAPTURE, wxCommandEvent);
73 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
74  EVT_AUDIOIO_MONITOR, wxCommandEvent);
75 
76 // PRL:
77 // If we always run a portaudio output stream (even just to produce silence)
78 // whenever we play Midi, then we might use just one thread for both.
79 // I thought this would improve MIDI synch problems on Linux/ALSA, but RBD
80 // convinced me it was neither a necessary nor sufficient fix. Perhaps too the
81 // MIDI thread might block in some error situations but we should then not
82 // also block the audio thread.
83 // So leave the separate thread ENABLED.
84 #define USE_MIDI_THREAD
85 
89 #ifdef EXPERIMENTAL_MIDI_OUT
90  NoteTrackConstArray midiTracks;
91 #endif
92 
93  // This is a subset of playbackTracks
95 };
96 
97 // This workaround makes pause and stop work when output is to GarageBand,
98 // which seems not to implement the notes-off message correctly.
99 #define AUDIO_IO_GB_MIDI_WORKAROUND
100 
124  const void *inputBuffer, void *outputBuffer,
125  unsigned long framesPerBuffer,
126  const PaStreamCallbackTimeInfo *timeInfo,
127  PaStreamCallbackFlags statusFlags, void *userData );
128 
129 // Communicate data from one writer to one reader.
130 // This is not a queue: it is not necessary for each write to be read.
131 // Rather loss of a message is allowed: writer may overwrite.
132 // Data must be default-constructible and either copyable or movable.
133 template<typename Data>
135  struct UpdateSlot {
136  std::atomic<bool> mBusy{ false };
137  Data mData;
138  };
140 
141  std::atomic<unsigned char> mLastWrittenSlot{ 0 };
142 
143 public:
144  void Initialize();
145 
146  // Move data out (if available), or else copy it out
147  Data Read();
148 
149  // Copy data in
150  void Write( const Data &data );
151  // Move data in
152  void Write( Data &&data );
153 };
154 
155 template<typename Data>
157 {
158  for (auto &slot : mSlots)
159  // Lock both slots first, maybe spinning a little
160  while ( slot.mBusy.exchange( true, std::memory_order_acquire ) )
161  {}
162 
163  mSlots[0].mData = {};
164  mSlots[1].mData = {};
165  mLastWrittenSlot.store( 0, std::memory_order_relaxed );
166 
167  for (auto &slot : mSlots)
168  slot.mBusy.exchange( false, std::memory_order_release );
169 }
170 
171 template<typename Data>
173 {
174  // Whichever slot was last written, prefer to read that.
175  auto idx = mLastWrittenSlot.load( std::memory_order_relaxed );
176  idx = 1 - idx;
177  bool wasBusy = false;
178  do {
179  // This loop is unlikely to execute twice, but it might because the
180  // producer thread is writing a slot.
181  idx = 1 - idx;
182  wasBusy = mSlots[idx].mBusy.exchange( true, std::memory_order_acquire );
183  } while ( wasBusy );
184 
185  // Copy the slot
186  auto result = std::move( mSlots[idx].mData );
187 
188  mSlots[idx].mBusy.store( false, std::memory_order_release );
189 
190  return result;
191 }
192 
193 template<typename Data>
194 void MessageBuffer<Data>::Write( const Data &data )
195 {
196  // Whichever slot was last written, prefer to write the other.
197  auto idx = mLastWrittenSlot.load( std::memory_order_relaxed );
198  bool wasBusy = false;
199  do {
200  // This loop is unlikely to execute twice, but it might because the
201  // consumer thread is reading a slot.
202  idx = 1 - idx;
203  wasBusy = mSlots[idx].mBusy.exchange( true, std::memory_order_acquire );
204  } while ( wasBusy );
205 
206  mSlots[idx].mData = data;
207  mLastWrittenSlot.store( idx, std::memory_order_relaxed );
208 
209  mSlots[idx].mBusy.store( false, std::memory_order_release );
210 }
211 
212 template<typename Data>
213 void MessageBuffer<Data>::Write( Data &&data )
214 {
215  // Whichever slot was last written, prefer to write the other.
216  auto idx = mLastWrittenSlot.load( std::memory_order_relaxed );
217  bool wasBusy = false;
218  do {
219  // This loop is unlikely to execute twice, but it might because the
220  // consumer thread is reading a slot.
221  idx = 1 - idx;
222  wasBusy = mSlots[idx].mBusy.exchange( true, std::memory_order_acquire );
223  } while ( wasBusy );
224 
225  mSlots[idx].mData = std::move( data );
226  mLastWrittenSlot.store( idx, std::memory_order_relaxed );
227 
228  mSlots[idx].mBusy.store( false, std::memory_order_release );
229 }
230 
231 class AUDACITY_DLL_API AudioIoCallback /* not final */
232  : public AudioIOBase
233 {
234 public:
235  AudioIoCallback();
236  ~AudioIoCallback();
237 
238 public:
239  // This function executes in a thread spawned by the PortAudio library
240  int AudioCallback(
241  const void *inputBuffer, void *outputBuffer,
242  unsigned long framesPerBuffer,
243  const PaStreamCallbackTimeInfo *timeInfo,
244  const PaStreamCallbackFlags statusFlags, void *userData);
245 
246 #ifdef EXPERIMENTAL_MIDI_OUT
247  void PrepareMidiIterator(bool send = true, double offset = 0);
248  bool StartPortMidiStream();
249 
250  // Compute nondecreasing real time stamps, accounting for pauses, but not the
251  // synth latency.
252  double UncorrectedMidiEventTime();
253 
254  void OutputEvent();
255  void FillMidiBuffers();
256  void GetNextEvent();
257  double PauseTime();
258  void AllNotesOff(bool looping = false);
259 
264  PmTimestamp MidiTime();
265 
266  // Note: audio code solves the problem of soloing/muting tracks by scanning
267  // all playback tracks on every call to the audio buffer fill routine.
268  // We do the same for Midi, but it seems wasteful for at least two
269  // threads to be frequently polling to update status. This could be
270  // eliminated (also with a reduction in code I think) by updating mHasSolo
271  // each time a solo button is activated or deactivated. For now, I'm
272  // going to do this polling in the FillMidiBuffer routine to localize
273  // changes for midi to the midi code, but I'm declaring the variable
274  // here so possibly in the future, Audio code can use it too. -RBD
275  private:
276  bool mHasSolo; // is any playback solo button pressed?
277  public:
278  bool SetHasSolo(bool hasSolo);
279  bool GetHasSolo() { return mHasSolo; }
280 #endif
281 
282  std::shared_ptr< AudioIOListener > GetListener() const
283  { return mListener.lock(); }
284  void SetListener( const std::shared_ptr< AudioIOListener > &listener);
285 
286  // Part of the callback
287  int CallbackDoSeek();
288 
289  // Part of the callback
290  void CallbackCheckCompletion(
291  int &callbackReturn, unsigned long len);
292 
295  // Helpers to determine if tracks have already been faded out.
296  unsigned CountSoloingTracks();
297  bool TrackShouldBeSilent( const WaveTrack &wt );
298  bool TrackHasBeenFadedOut( const WaveTrack &wt );
299  bool AllTracksAlreadySilent();
300 
301  // These eight functions do different parts of AudioCallback().
302  void ComputeMidiTimings(
303  const PaStreamCallbackTimeInfo *timeInfo,
304  unsigned long framesPerBuffer);
305  void CheckSoundActivatedRecordingLevel(
306  float *inputSamples,
307  unsigned long framesPerBuffer
308  );
309  void AddToOutputChannel( unsigned int chan,
310  float * outputMeterFloats,
311  float * outputFloats,
312  float * tempBuf,
313  bool drop,
314  unsigned long len,
315  WaveTrack *vt
316  );
317  bool FillOutputBuffers(
318  void *outputBuffer,
319  unsigned long framesPerBuffer, float *outputMeterFloats
320  );
321  void FillInputBuffers(
322  const void *inputBuffer,
323  unsigned long framesPerBuffer,
324  const PaStreamCallbackFlags statusFlags,
325  float * tempFloats
326  );
327  void UpdateTimePosition(
328  unsigned long framesPerBuffer
329  );
330  void DoPlaythrough(
331  const void *inputBuffer,
332  void *outputBuffer,
333  unsigned long framesPerBuffer,
334  float *outputMeterFloats
335  );
336  void SendVuInputMeterData(
337  float *inputSamples,
338  unsigned long framesPerBuffer
339  );
340  void SendVuOutputMeterData(
341  float *outputMeterFloats,
342  unsigned long framesPerBuffer
343  );
344 
345 
346 // Required by these functions...
347 #ifdef EXPERIMENTAL_MIDI_OUT
348  double AudioTime() { return mPlaybackSchedule.mT0 + mNumFrames / mRate; }
349 #endif
350 
351 
357  size_t GetCommonlyReadyPlayback();
358 
359 
360 #ifdef EXPERIMENTAL_MIDI_OUT
361  // MIDI_PLAYBACK:
362  PmStream *mMidiStream;
363  int mLastPmError;
364 
366  long mSynthLatency; // ms
367 
368  // These fields are used to synchronize MIDI with audio:
369 
371  volatile long mNumFrames;
373  volatile long mNumPauseFrames;
375  volatile int mMidiLoopPasses;
376  inline double MidiLoopOffset() {
377  return mMidiLoopPasses * (mPlaybackSchedule.mT1 - mPlaybackSchedule.mT0);
378  }
379 
380  volatile long mAudioFramesPerBuffer;
383  volatile bool mMidiPaused;
386  PmTimestamp mMaxMidiTimestamp;
387 
391  double mSystemMinusAudioTime;
394  double mAudioOutLatency;
395 
396  // Next two are used to adjust the previous two, if
397  // PortAudio does not provide the info (using ALSA):
398 
401  double mStartTime;
403  long mCallbackCount;
404 
407  volatile double mSystemMinusAudioTimePlusLatency;
408 
409  Alg_seq *mSeq;
410  std::unique_ptr<Alg_iterator> mIterator;
412  Alg_event *mNextEvent;
413 
414 #ifdef AUDIO_IO_GB_MIDI_WORKAROUND
415  std::vector< std::pair< int, int > > mPendingNotesOff;
416 #endif
417 
420  double mNextEventTime;
422  NoteTrack *mNextEventTrack;
424  bool mNextIsNoteOn;
427  bool mSendMidiState;
428  NoteTrackConstArray mMidiPlaybackTracks;
429 #endif
430 
431 #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
432  bool mAILAActive;
433  bool mAILAClipped;
434  int mAILATotalAnalysis;
435  int mAILAAnalysisCounter;
436  double mAILAMax;
437  double mAILAGoalPoint;
438  double mAILAGoalDelta;
439  double mAILAAnalysisTime;
440  double mAILALastStartTime;
441  double mAILAChangeFactor;
442  double mAILATopLevel;
443  double mAILAAnalysisEndTime;
444  double mAILAAbsolutStartTime;
445  unsigned short mAILALastChangeType; //0 - no change, 1 - increase change, 2 - decrease change
446 #endif
447 
448  std::unique_ptr<AudioThread> mThread;
449 #ifdef EXPERIMENTAL_MIDI_OUT
450 #ifdef USE_MIDI_THREAD
451  std::unique_ptr<AudioThread> mMidiThread;
452 #endif
453 #endif
459 
461  static int mNextStreamToken;
462  double mFactor;
463  unsigned long mMaxFramesOutput; // The actual number of frames output.
465 
466  double mSeek;
469 
474 
478  bool mPauseRec;
480  unsigned int mNumCaptureChannels;
481  unsigned int mNumPlaybackChannels;
483  unsigned long long mLostSamples{ 0 };
487 
489 
490 #ifdef EXPERIMENTAL_MIDI_OUT
491  volatile bool mMidiThreadFillBuffersLoopRunning;
492  volatile bool mMidiThreadFillBuffersLoopActive;
493 #endif
494 
495  volatile double mLastRecordingOffset;
497 
498 protected:
499 
501  volatile bool mUpdatingMeters;
502 
503  std::weak_ptr< AudioIOListener > mListener;
504 
505  friend class AudioThread;
506 #ifdef EXPERIMENTAL_MIDI_OUT
507  friend class MidiThread;
508 #endif
509 
510  bool mUsingAlsa { false };
511 
512  // For cacheing supported sample rates
513  static double mCachedBestRateOut;
516 
517  // Serialize main thread and PortAudio thread's attempts to pause and change
518  // the state used by the third, Audio thread.
520 
521 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
522 public:
523  struct ScrubState;
524  std::unique_ptr<ScrubState> mScrubState;
525 
526  bool mSilentScrub;
527  double mScrubSpeed;
528  sampleCount mScrubDuration;
529 #endif
530 
531 protected:
532  // A flag tested and set in one thread, cleared in another. Perhaps
533  // this guarantee of atomicity is more cautious than necessary.
534  wxAtomicInt mRecordingException {};
536  { wxAtomicInc( mRecordingException ); }
538  { if (mRecordingException) wxAtomicDec( mRecordingException ); }
539 
540  std::vector< std::pair<double, double> > mLostCaptureIntervals;
541  bool mDetectDropouts{ true };
542 
543 public:
544  // Pairs of starting time and duration
545  const std::vector< std::pair<double, double> > &LostCaptureIntervals()
546  { return mLostCaptureIntervals; }
547 
548  // Used only for testing purposes in alpha builds
549  bool mSimulateRecordingErrors{ false };
550 
551  // Whether to check the error code passed to audacityAudioCallback to
552  // detect more dropouts
553  bool mDetectUpstreamDropouts{ true };
554 
555 protected:
556  RecordingSchedule mRecordingSchedule{};
557 
558  // Another circular buffer
559  // Holds track time values corresponding to every nth sample in the playback
560  // buffers, for some large n
561  struct TimeQueue {
563  size_t mSize{ 0 };
564  double mLastTime {};
565  // These need not be updated atomically, because we rely on the atomics
566  // in the playback ring buffers to supply the synchronization. Still,
567  // align them to avoid false sharing.
568  struct Cursor {
569  size_t mIndex {};
570  size_t mRemainder {};
571  };
573 
574  void Producer(
575  const PlaybackSchedule &schedule, double rate, double scrubSpeed,
576  size_t nSamples );
577  double Consumer( size_t nSamples, double rate );
578  } mTimeQueue;
579 
581 };
582 
583 class AUDACITY_DLL_API AudioIO final
584  : public AudioIoCallback
585 {
586 
587  AudioIO();
588  ~AudioIO();
589 
590 public:
591  // This might return null during application startup or shutdown
592  static AudioIO *Get();
593 
601  void StartMonitoring( const AudioIOStartStreamOptions &options );
602 
610  int StartStream(const TransportTracks &tracks,
611  double t0, double t1,
612  const AudioIOStartStreamOptions &options);
613 
619  void StopStream() override;
622  void SeekStream(double seconds) { mSeek = seconds; }
623 
624 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
625  bool IsScrubbing() const { return IsBusy() && mScrubState != 0; }
626 
632  void UpdateScrub(double endTimeOrSpeed, const ScrubbingOptions &options);
633 
634  void StopScrub();
635 
638  double GetLastScrubTime() const;
639 #endif
640 
641 public:
642  wxString LastPaErrorString();
643 
644  wxLongLong GetLastPlaybackTime() const { return mLastPlaybackTimeMillis; }
646 
648  void SetPaused(bool state);
649 
650  /* Mixer services are always available. If no stream is running, these
651  * methods use whatever device is specified by the preferences. If a
652  * stream *is* running, naturally they manipulate the mixer associated
653  * with that stream. If no mixer is available, output is emulated and
654  * input is stuck at 1.0f (a gain is applied to output samples).
655  */
656  void SetMixer(int inputSource, float inputVolume,
657  float playbackVolume);
658  void GetMixer(int *inputSource, float *inputVolume,
659  float *playbackVolume);
666  bool InputMixerWorks();
667 
674  bool OutputMixerEmulated();
675 
680  wxArrayString GetInputSourceNames();
681 
683  unsigned GetNumPlaybackChannels() const { return mNumPlaybackChannels; }
684  unsigned GetNumCaptureChannels() const { return mNumCaptureChannels; }
685 
686  // Meaning really capturing, not just pre-rolling
687  bool IsCapturing() const;
688 
692  static bool ValidateDeviceNames(const wxString &play, const wxString &rec);
693 
697  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
698  void AILAInitialize();
699  void AILADisable();
700  bool AILAIsActive();
701  void AILAProcess(double maxPeak);
702  void AILASetStartTime();
703  double AILAGetLastDecisionTime();
704  #endif
705 
706  bool IsAvailable(AudacityProject *projecT) const;
707 
718  double GetBestRate(bool capturing, bool playing, double sampleRate);
719 
726  double GetStreamTime();
727 
728  friend class AudioThread;
729 #ifdef EXPERIMENTAL_MIDI_OUT
730  friend class MidiThread;
731 #endif
732 
733  static void Init();
734  static void Deinit();
735 
736 
737 
738 private:
739 
742  void SetMeters();
743 
744 
755  bool StartPortAudioStream(const AudioIOStartStreamOptions &options,
756  unsigned int numPlaybackChannels,
757  unsigned int numCaptureChannels,
758  sampleFormat captureFormat);
759  void FillBuffers();
760 
766  size_t GetCommonlyFreePlayback();
767 
774  size_t GetCommonlyAvailCapture();
775 
781  bool AllocateBuffers(
782  const AudioIOStartStreamOptions &options,
783  const TransportTracks &tracks, double t0, double t1, double sampleRate,
784  bool scrubbing );
785 
789  void StartStreamCleanup(bool bOnlyBuffers = false);
790 };
791 
792 static constexpr unsigned ScrubPollInterval_ms = 50;
793 
794 #endif
AudioIoCallback::mPlaybackQueueMinimum
size_t mPlaybackQueueMinimum
Occupancy of the queue we try to maintain, with bigger batches if needed.
Definition: AudioIO.h:473
Init
Definition: ModuleManager.h:142
WaveTrackArray
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:57
AudioIoCallback::mCaptureFormat
sampleFormat mCaptureFormat
Definition: AudioIO.h:482
AudioIOBase.h
WaveTrackConstArray
std::vector< std::shared_ptr< const WaveTrack > > WaveTrackConstArray
Definition: AudioIO.h:58
TransportTracks::playbackTracks
WaveTrackArray playbackTracks
Definition: AudioIO.h:87
AudioIoCallback::mPlaybackTracks
WaveTrackArray mPlaybackTracks
Definition: AudioIO.h:458
AudioIoCallback::mbMicroFades
bool mbMicroFades
Definition: AudioIO.h:464
WaveTrack
A Track that contains audio waveform data.
Definition: WaveTrack.h:68
AudioIoCallback::LostCaptureIntervals
const std::vector< std::pair< double, double > > & LostCaptureIntervals()
Definition: AudioIO.h:545
AudioIoCallback::mThread
std::unique_ptr< AudioThread > mThread
Definition: AudioIO.h:448
AudioIoCallback::mAudioThreadShouldCallFillBuffersOnce
volatile bool mAudioThreadShouldCallFillBuffersOnce
Definition: AudioIO.h:484
AudioIOBase::mOwningProject
AudacityProject * mOwningProject
Definition: AudioIOBase.h:260
AudioIoCallback::TimeQueue
Definition: AudioIO.h:561
ScrubbingOptions
Definition: AudioIOBase.h:44
MessageBuffer::Initialize
void Initialize()
Definition: AudioIO.h:156
TransportTracks::captureTracks
WaveTrackArray captureTracks
Definition: AudioIO.h:88
AudioIO::GetNumPlaybackChannels
unsigned GetNumPlaybackChannels() const
Definition: AudioIO.h:683
AudioIoCallback::mNumPlaybackChannels
unsigned int mNumPlaybackChannels
Definition: AudioIO.h:481
AudioIO::GetCaptureFormat
sampleFormat GetCaptureFormat()
Definition: AudioIO.h:682
AudioIoCallback::mNumCaptureChannels
unsigned int mNumCaptureChannels
Definition: AudioIO.h:480
MessageBuffer::Write
void Write(const Data &data)
Definition: AudioIO.h:194
MessageBuffer::mLastWrittenSlot
std::atomic< unsigned char > mLastWrittenSlot
Definition: AudioIO.h:141
AudioIoCallback::mUpdatingMeters
volatile bool mUpdatingMeters
Definition: AudioIO.h:501
AudioIoCallback::mMaxFramesOutput
unsigned long mMaxFramesOutput
Definition: AudioIO.h:463
AudioIoCallback::mPlaybackSamplesToCopy
size_t mPlaybackSamplesToCopy
Preferred batch size for replenishing the playback RingBuffer.
Definition: AudioIO.h:471
AudioIoCallback
AudioIoCallback is a class that implements the callback required by PortAudio. The callback needs to ...
Definition: AudioIO.h:233
AudioIoCallback::mPlaybackBuffers
ArrayOf< std::unique_ptr< RingBuffer > > mPlaybackBuffers
Definition: AudioIO.h:457
AudioIoCallback::mUpdateMeters
bool mUpdateMeters
Definition: AudioIO.h:500
AudioIO::GetNumCaptureChannels
unsigned GetNumCaptureChannels() const
Definition: AudioIO.h:684
ScrubPollInterval_ms
static constexpr unsigned ScrubPollInterval_ms
Definition: AudioIO.h:792
AudioIoCallback::mAudioThreadFillBuffersLoopActive
volatile bool mAudioThreadFillBuffersLoopActive
Definition: AudioIO.h:486
AudioIOBase::IsBusy
bool IsBusy() const
Returns true if audio i/o is busy starting, stopping, playing, or recording.
Definition: AudioIOBase.cpp:345
PlaybackSchedule.h
AudioIoCallback::mSoftwarePlaythrough
bool mSoftwarePlaythrough
Definition: AudioIO.h:476
sampleFormat
sampleFormat
Definition: Types.h:194
AudioIoCallback::mPauseRec
bool mPauseRec
True if Sound Activated Recording is enabled.
Definition: AudioIO.h:478
MessageBuffer::mSlots
NonInterfering< UpdateSlot > mSlots[2]
Definition: AudioIO.h:139
AudioIoCallback::TimeQueue::Cursor
Definition: AudioIO.h:568
wxDECLARE_EXPORTED_EVENT
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_AUDIOIO_PLAYBACK, wxCommandEvent)
AudioIO::SeekStream
void SeekStream(double seconds)
Move the playback / recording position of the current stream by the specified amount from where it is...
Definition: AudioIO.h:622
AudioIoCallback::mCaptureBuffers
ArrayOf< std::unique_ptr< RingBuffer > > mCaptureBuffers
Definition: AudioIO.h:455
AudioIoCallback::mLastPlaybackTimeMillis
wxLongLong mLastPlaybackTimeMillis
Definition: AudioIO.h:488
PaError
int PaError
Definition: AudioIO.h:62
MessageBuffer::UpdateSlot::mBusy
std::atomic< bool > mBusy
Definition: AudioIO.h:136
PlaybackSchedule
Definition: PlaybackSchedule.h:38
MessageBuffer
Definition: AudioIO.h:134
AudioIO::GetOwningProject
AudacityProject * GetOwningProject() const
Definition: AudioIO.h:645
NoteTrackConstArray
std::vector< std::shared_ptr< const NoteTrack > > NoteTrackConstArray
Definition: Track.h:48
AudioIoCallback::mCallbackReturn
int mCallbackReturn
Definition: AudioIO.h:294
AudioIOBase::Get
static AudioIOBase * Get()
Definition: AudioIOBase.cpp:94
AudioIoCallback::mPlaybackMixers
ArrayOf< std::unique_ptr< Mixer > > mPlaybackMixers
Definition: AudioIO.h:460
AudioIOBase::mRate
double mRate
Audio playback rate in samples per second.
Definition: AudioIOBase.h:274
AudioIoCallback::mSuspendAudioThread
wxMutex mSuspendAudioThread
Definition: AudioIO.h:519
AudioIoCallback::mLastRecordingOffset
volatile double mLastRecordingOffset
Definition: AudioIO.h:495
AudioIOBase::SetMixer
void SetMixer(int inputSource)
Definition: AudioIOBase.cpp:101
AudioIoCallback::mAudioThreadFillBuffersLoopRunning
volatile bool mAudioThreadFillBuffersLoopRunning
Definition: AudioIO.h:485
AudioIOStartStreamOptions
struct holding stream options, including a pointer to the time warp info and AudioIOListener and whet...
Definition: AudioIOBase.h:77
AudioIoCallback::mNextStreamToken
static int mNextStreamToken
Definition: AudioIO.h:461
AudioIoCallback::mCachedBestRateCapturing
static bool mCachedBestRateCapturing
Definition: AudioIO.h:515
Resample
Interface to libsoxr.
Definition: Resample.h:29
TransportTracks
Definition: AudioIO.h:86
AudioIoCallback::ClearRecordingException
void ClearRecordingException()
Definition: AudioIO.h:537
NonInterfering
Definition: MemoryX.h:609
AudioIoCallback::mCaptureRingBufferSecs
double mCaptureRingBufferSecs
Definition: AudioIO.h:468
PaStreamCallbackFlags
unsigned long PaStreamCallbackFlags
Definition: AudioIO.h:60
AudioIoCallback::mbHasSoloTracks
int mbHasSoloTracks
Definition: AudioIO.h:293
AudioIoCallback::mSilenceLevel
float mSilenceLevel
Definition: AudioIO.h:479
sampleCount
Definition: Types.h:66
AudioIoCallback::mSeek
double mSeek
Definition: AudioIO.h:466
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
AudioIoCallback::mLostCaptureIntervals
std::vector< std::pair< double, double > > mLostCaptureIntervals
Definition: AudioIO.h:540
AudioIoCallback::mCachedBestRatePlaying
static bool mCachedBestRatePlaying
Definition: AudioIO.h:514
AudioIO::GetLastPlaybackTime
wxLongLong GetLastPlaybackTime() const
Definition: AudioIO.h:644
AudioIoCallback::mLastPaError
PaError mLastPaError
Definition: AudioIO.h:496
AudioIOBase::StopStream
virtual void StopStream()=0
AudioIoCallback::GetListener
std::shared_ptr< AudioIOListener > GetListener() const
Definition: AudioIO.h:282
MessageBuffer::UpdateSlot
Definition: AudioIO.h:135
AudioIoCallback::TimeQueue::mData
Doubles mData
Definition: AudioIO.h:562
AudioIoCallback::mResample
ArrayOf< std::unique_ptr< Resample > > mResample
Definition: AudioIO.h:454
MessageBuffer::UpdateSlot::mData
Data mData
Definition: AudioIO.h:137
AudioIoCallback::mPlaybackSchedule
PlaybackSchedule mPlaybackSchedule
Definition: AudioIO.h:580
AudioIoCallback::mListener
std::weak_ptr< AudioIOListener > mListener
Definition: AudioIO.h:503
RingBuffer
Holds streamed audio samples.
Definition: RingBuffer.h:17
RecordingSchedule
Definition: PlaybackSchedule.h:21
ValidateDeviceNames
bool ValidateDeviceNames()
AudioIO
AudioIO uses the PortAudio library to play and record sound.
Definition: AudioIO.h:585
AudioThread
Defined different on Mac and other platforms (on Mac it does not use wxWidgets wxThread),...
Definition: AudioIO.cpp:889
AudioIOBase
A singleton object supporting queries of the state of any active audio streams, and audio device capa...
Definition: AudioIOBase.h:121
MessageBuffer::Read
Data Read()
Definition: AudioIO.h:172
AudioIoCallback::mMinCaptureSecsToCopy
double mMinCaptureSecsToCopy
Definition: AudioIO.h:475
TransportTracks::prerollTracks
WaveTrackConstArray prerollTracks
Definition: AudioIO.h:94
Mixer
Functions for doing the mixdown of the tracks.
Definition: Mix.h:78
SampleFormat.h
ArrayOf
Memory.h template class for making an array of float, bool, etc.
Definition: MemoryX.h:26
AudioIoCallback::SetRecordingException
void SetRecordingException()
Definition: AudioIO.h:535
AudioIoCallback::mCaptureTracks
WaveTrackArray mCaptureTracks
Definition: AudioIO.h:456
audacityAudioCallback
int audacityAudioCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition: AudioIO.cpp:3636
NoteTrack
A Track that is used for Midi notes. (Somewhat old code).
Definition: NoteTrack.h:66
AudioIoCallback::mFactor
double mFactor
Definition: AudioIO.h:462
AudioIoCallback::TimeQueue::mTail
NonInterfering< Cursor > mTail
Definition: AudioIO.h:572
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38
AudioIoCallback::mCachedBestRateOut
static double mCachedBestRateOut
Definition: AudioIO.h:513
AudioIoCallback::mPlaybackRingBufferSecs
double mPlaybackRingBufferSecs
Definition: AudioIO.h:467