Audacity  2.2.2
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 #include "portaudio.h"
17 #include "Audacity.h"
18 #include "Experimental.h"
19 
20 #include "MemoryX.h"
21 #include <utility>
22 #include <vector>
23 #include <wx/atomic.h>
24 #include <wx/weakref.h>
25 
26 #ifdef USE_MIDI
27 
28 // TODO: Put the relative paths into automake.
29 
30 #ifdef EXPERIMENTAL_MIDI_OUT
31 #include "../lib-src/portmidi/pm_common/portmidi.h"
32 #include "../lib-src/portmidi/porttime/porttime.h"
33 #include <cstring> // Allegro include fails if this header isn't included do to no memcpy
34 #include "../lib-src/header-substitutes/allegro.h"
35 
36 class NoteTrack;
37 using NoteTrackArray = std::vector < std::shared_ptr< NoteTrack > >;
38 using NoteTrackConstArray = std::vector < std::shared_ptr< const NoteTrack > >;
39 
40 #endif // EXPERIMENTAL_MIDI_OUT
41 
42 #endif // USE_MIDI
43 
44 #if USE_PORTMIXER
45 #include "../lib-src/portmixer/include/portmixer.h"
46 #endif
47 
48 #include <wx/event.h>
49 #include <wx/string.h>
50 #include <wx/thread.h>
51 
52 #include "SampleFormat.h"
53 
54 class AudioIO;
55 class RingBuffer;
56 class Mixer;
57 class Resample;
58 class TimeTrack;
59 class AudioThread;
60 class MeterPanel;
61 class SelectedRegion;
62 
63 class AudacityProject;
64 
65 class WaveTrack;
66 using WaveTrackArray = std::vector < std::shared_ptr < WaveTrack > >;
67 using WaveTrackConstArray = std::vector < std::shared_ptr < const WaveTrack > >;
68 
69 extern AUDACITY_DLL_API AudioIO *gAudioIO;
70 
71 void InitAudioIO();
72 void DeinitAudioIO();
73 wxString DeviceName(const PaDeviceInfo* info);
74 wxString HostName(const PaDeviceInfo* info);
75 bool ValidateDeviceNames();
76 
77 class AudioIOListener;
78 
79 // #include <cfloat> if you need this constant
80 #define BAD_STREAM_TIME (-DBL_MAX)
81 
82 #define MAX_MIDI_BUFFER_SIZE 5000
83 #define DEFAULT_SYNTH_LATENCY 5
84 
85 #define DEFAULT_LATENCY_DURATION 100.0
86 #define DEFAULT_LATENCY_CORRECTION -130.0
87 
88 #define AUDIO_PRE_ROLL_KEY (wxT("/AudioIO/PreRoll"))
89 #define DEFAULT_PRE_ROLL_SECONDS 5.0
90 
91 #define AUDIO_ROLL_CROSSFADE_KEY (wxT("/AudioIO/Crossfade"))
92 #define DEFAULT_ROLL_CROSSFADE_MS 10.0
93 
94 #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
95  #define AILA_DEF_TARGET_PEAK 92
96  #define AILA_DEF_DELTA_PEAK 2
97  #define AILA_DEF_ANALYSIS_TIME 1000
98  #define AILA_DEF_NUMBER_ANALYSIS 5
99 #endif
100 
101 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
102  EVT_AUDIOIO_PLAYBACK, wxCommandEvent);
103 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
104  EVT_AUDIOIO_CAPTURE, wxCommandEvent);
105 wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API,
106  EVT_AUDIOIO_MONITOR, wxCommandEvent);
107 
108 // PRL:
109 // If we always run a portaudio output stream (even just to produce silence)
110 // whenever we play Midi, then we might use just one thread for both.
111 // I thought this would improve MIDI synch problems on Linux/ALSA, but RBD
112 // convinced me it was neither a necessary nor sufficient fix. Perhaps too the
113 // MIDI thread might block in some error situations but we should then not
114 // also block the audio thread.
115 // So leave the separate thread ENABLED.
116 #define USE_MIDI_THREAD
117 
118 struct ScrubbingOptions;
119 
120 using PRCrossfadeData = std::vector< std::vector < float > >;
121 
122 // To avoid growing the argument list of StartStream, add fields here
124 {
125  explicit
127  : timeTrack(NULL)
128  , listener(NULL)
129  , rate(rate_)
130  , playLooped(false)
131  , cutPreviewGapStart(0.0)
132  , cutPreviewGapLen(0.0)
133  , pStartTime(NULL)
134  , preRoll(0.0)
135  {}
136 
139  double rate;
143  double * pStartTime;
144  double preRoll;
145 
146 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
147  // Non-null value indicates that scrubbing will happen
148  // (do not specify a time track, looping, or recording, which
149  // are all incompatible with scrubbing):
151 #endif
152 
153  // contents may get swapped with empty vector
155 };
156 
160 #ifdef EXPERIMENTAL_MIDI_OUT
161  NoteTrackConstArray midiTracks;
162 #endif
163 
164  // This is a subset of playbackTracks
166 };
167 
168 // This workaround makes pause and stop work when output is to GarageBand,
169 // which seems not to implement the notes-off message correctly.
170 #define AUDIO_IO_GB_MIDI_WORKAROUND
171 
172 class AUDACITY_DLL_API AudioIO final {
173 
174  public:
175  AudioIO();
176  ~AudioIO();
177 
178  AudioIOListener* GetListener() { return mListener; }
179  void SetListener(AudioIOListener* listener);
180 
188  void StartMonitoring(double sampleRate);
189 
197  int StartStream(const TransportTracks &tracks,
198  double t0, double t1,
199  const AudioIOStartStreamOptions &options);
200 
206  void StopStream();
209  void SeekStream(double seconds) { mSeek = seconds; }
210 
211 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
212  bool IsScrubbing() { return IsBusy() && mScrubQueue != 0; }
213 
224  bool EnqueueScrub(double endTimeOrSpeed, const ScrubbingOptions &options);
225 
228  double GetLastTimeInScrubQueue() const;
229 #endif
230 
235  bool IsBusy();
236 
243  bool IsStreamActive();
244  bool IsStreamActive(int token);
245 
246  wxLongLong GetLastPlaybackTime() const { return mLastPlaybackTimeMillis; }
247  AudacityProject *GetOwningProject() const { return mOwningProject; }
248 
249 #ifdef EXPERIMENTAL_MIDI_OUT
250 
254  PmTimestamp MidiTime();
255 
256  // Note: audio code solves the problem of soloing/muting tracks by scanning
257  // all playback tracks on every call to the audio buffer fill routine.
258  // We do the same for Midi, but it seems wasteful for at least two
259  // threads to be frequently polling to update status. This could be
260  // eliminated (also with a reduction in code I think) by updating mHasSolo
261  // each time a solo button is activated or deactivated. For now, I'm
262  // going to do this polling in the FillMidiBuffer routine to localize
263  // changes for midi to the midi code, but I'm declaring the variable
264  // here so possibly in the future, Audio code can use it too. -RBD
265  private:
266  bool mHasSolo; // is any playback solo button pressed?
267  public:
268  bool SetHasSolo(bool hasSolo);
269  bool GetHasSolo() { return mHasSolo; }
270 #endif
271 
277  bool IsAudioTokenActive(int token);
278 
281  bool IsMonitoring();
282 
284  void SetPaused(bool state);
286  bool IsPaused();
287 
288  /* Mixer services are always available. If no stream is running, these
289  * methods use whatever device is specified by the preferences. If a
290  * stream *is* running, naturally they manipulate the mixer associated
291  * with that stream. If no mixer is available, output is emulated and
292  * input is stuck at 1.0f (a gain is applied to output samples).
293  */
294  void SetMixer(int inputSource);
295  void SetMixer(int inputSource, float inputVolume,
296  float playbackVolume);
297  void GetMixer(int *inputSource, float *inputVolume,
298  float *playbackVolume);
305  bool InputMixerWorks();
306 
313  bool OutputMixerEmulated();
314 
319  wxArrayString GetInputSourceNames();
320 
329  void HandleDeviceChange();
330 
343  static std::vector<long> GetSupportedPlaybackRates(int DevIndex = -1,
344  double rate = 0.0);
345 
358  static std::vector<long> GetSupportedCaptureRates(int devIndex = -1,
359  double rate = 0.0);
360 
375  static std::vector<long> GetSupportedSampleRates(int playDevice = -1,
376  int recDevice = -1,
377  double rate = 0.0);
378 
387  static int GetOptimalSupportedSampleRate();
388 
395  double GetStreamTime();
396 
397  sampleFormat GetCaptureFormat() { return mCaptureFormat; }
398  unsigned GetNumPlaybackChannels() const { return mNumPlaybackChannels; }
399  unsigned GetNumCaptureChannels() const { return mNumCaptureChannels; }
400 
401  // Meaning really capturing, not just pre-rolling
402  bool IsCapturing() const;
403 
408  static const int StandardRates[];
410  static const int NumStandardRates;
411 
415  wxString GetDeviceInfo();
416 
417 #ifdef EXPERIMENTAL_MIDI_OUT
418 
419  wxString GetMidiDeviceInfo();
420 #endif
421 
425  static bool ValidateDeviceNames(const wxString &play, const wxString &rec);
426 
430  #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
431  void AILAInitialize();
432  void AILADisable();
433  bool AILAIsActive();
434  void AILAProcess(double maxPeak);
435  void AILASetStartTime();
436  double AILAGetLastDecisionTime();
437  #endif
438 
439  bool IsAvailable(AudacityProject *projecT);
440  void SetCaptureMeter(AudacityProject *project, MeterPanel *meter);
441  void SetPlaybackMeter(AudacityProject *project, MeterPanel *meter);
442 
443 private:
446  void SetMeters();
447 
458  double GetBestRate(bool capturing, bool playing, double sampleRate);
459 
470  bool StartPortAudioStream(double sampleRate,
471  unsigned int numPlaybackChannels,
472  unsigned int numCaptureChannels,
473  sampleFormat captureFormat);
474  void FillBuffers();
475 
476 #ifdef EXPERIMENTAL_MIDI_OUT
477  void PrepareMidiIterator(bool send = true, double offset = 0);
478  bool StartPortMidiStream();
479 
480  // Compute nondecreasing time stamps, accounting for pauses, but not the
481  // synth latency.
482  double UncorrectedMidiEventTime();
483 
484  void OutputEvent();
485  void FillMidiBuffers();
486  void GetNextEvent();
487  double AudioTime() { return mT0 + mNumFrames / mRate; }
488  double PauseTime();
489  void AllNotesOff(bool looping = false);
490 #endif
491 
497  size_t GetCommonlyAvailPlayback();
498 
505  size_t GetCommonlyAvailCapture();
506 
514  static int getRecordDevIndex(const wxString &devName = wxEmptyString);
519 #if USE_PORTMIXER
520  static int getRecordSourceIndex(PxMixer *portMixer);
521 #endif
522 
530  static int getPlayDevIndex(const wxString &devName = wxEmptyString);
531 
536  static const int RatesToTry[];
538  static const int NumRatesToTry;
539 
541  bool ReversedTime() const
542  {
543  return mT1 < mT0;
544  }
551  double LimitStreamTime(double absoluteTime) const;
552 
559  double NormalizeStreamTime(double absoluteTime) const;
560 
564  void StartStreamCleanup(bool bOnlyBuffers = false);
565 
566  PRCrossfadeData mCrossfadeData{};
567 
568 #ifdef EXPERIMENTAL_MIDI_OUT
569  // MIDI_PLAYBACK:
570  PmStream *mMidiStream;
571  PmError mLastPmError;
572 
574  long mSynthLatency; // ms
575 
576  // These fields are used to synchronize MIDI with audio:
577 
579  volatile double mAudioCallbackClockTime;
580 
582  volatile long mNumFrames;
584  volatile long mNumPauseFrames;
586  volatile int mMidiLoopPasses;
587  inline double MidiLoopOffset() { return mMidiLoopPasses * (mT1 - mT0); }
588 
589  volatile long mAudioFramesPerBuffer;
592  volatile bool mMidiPaused;
595  PmTimestamp mMaxMidiTimestamp;
596 
600  double mSystemMinusAudioTime;
603  double mAudioOutLatency;
604 
605  // Next two are used to adjust the previous two, if
606  // PortAudio does not provide the info (using ALSA):
607 
610  double mStartTime;
612  long mCallbackCount;
613 
616  volatile double mSystemMinusAudioTimePlusLatency;
617 
618  Alg_seq_ptr mSeq;
619  std::unique_ptr<Alg_iterator> mIterator;
621  Alg_event_ptr mNextEvent;
622 
623 #ifdef AUDIO_IO_GB_MIDI_WORKAROUND
624  std::vector< std::pair< int, int > > mPendingNotesOff;
625 #endif
626 
629  double mNextEventTime;
631  NoteTrack *mNextEventTrack;
633  bool mMidiOutputComplete{ true };
635  bool mNextIsNoteOn;
637  bool mMidiStreamActive;
640  bool mSendMidiState;
641  NoteTrackConstArray mMidiPlaybackTracks;
642 #endif
643 
644 #ifdef EXPERIMENTAL_AUTOMATED_INPUT_LEVEL_ADJUSTMENT
645  bool mAILAActive;
646  bool mAILAClipped;
647  int mAILATotalAnalysis;
648  int mAILAAnalysisCounter;
649  double mAILAMax;
650  double mAILAGoalPoint;
651  double mAILAGoalDelta;
652  double mAILAAnalysisTime;
653  double mAILALastStartTime;
654  double mAILAChangeFactor;
655  double mAILATopLevel;
656  double mAILAAnalysisEndTime;
657  double mAILAAbsolutStartTime;
658  unsigned short mAILALastChangeType; //0 - no change, 1 - increase change, 2 - decrease change
659 #endif
660 
661  std::unique_ptr<AudioThread> mThread;
662 #ifdef EXPERIMENTAL_MIDI_OUT
663 #ifdef USE_MIDI_THREAD
664  std::unique_ptr<AudioThread> mMidiThread;
665 #endif
666 #endif
672 
674  volatile int mStreamToken;
675  static int mNextStreamToken;
676  double mFactor;
678  double mRate;
680  double mT0;
682  double mT1;
684  double mTime;
685 
689  double mWarpedTime;
690 
695 
696  double mSeek;
702  bool mPaused;
703  PaStream *mPortStreamV19;
706  bool mPauseRec;
708  unsigned int mNumCaptureChannels;
709  unsigned int mNumPlaybackChannels;
711  unsigned long long mLostSamples{ 0 };
715 
717 
718 #ifdef EXPERIMENTAL_MIDI_OUT
719  volatile bool mMidiThreadFillBuffersLoopRunning;
720  volatile bool mMidiThreadFillBuffersLoopActive;
721 #endif
722 
723  volatile double mLastRecordingOffset;
724  PaError mLastPaError;
725 
727  wxWeakRef<MeterPanel> mInputMeter{};
730  volatile bool mUpdatingMeters;
731 
732  #if USE_PORTMIXER
733  PxMixer *mPortMixer;
734  float mPreviousHWPlaythrough;
735  #endif /* USE_PORTMIXER */
736 
747 
748  volatile enum {
751 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
753 #endif
754  } mPlayMode;
757 
759 
761 
762  friend class AudioThread;
763 #ifdef EXPERIMENTAL_MIDI_OUT
764  friend class MidiThread;
765 #endif
766 
767  friend void InitAudioIO();
768 
770 
771  bool mUsingAlsa { false };
772 
773  // For cacheing supported sample rates
775  static std::vector<long> mCachedPlaybackRates;
777  static std::vector<long> mCachedCaptureRates;
778  static std::vector<long> mCachedSampleRates;
779  static double mCachedBestRateIn;
780  static double mCachedBestRateOut;
781 
804  friend int audacityAudioCallback(
805  const void *inputBuffer, void *outputBuffer,
806  unsigned long framesPerBuffer,
807  const PaStreamCallbackTimeInfo *timeInfo,
808  PaStreamCallbackFlags statusFlags, void *userData );
809 
810  // Serialize main thread and PortAudio thread's attempts to pause and change
811  // the state used by the third, Audio thread.
813 
814 #ifdef EXPERIMENTAL_SCRUBBING_SUPPORT
815  struct ScrubQueue;
816  std::unique_ptr<ScrubQueue> mScrubQueue;
817 
820 #endif
821 
822  // A flag tested and set in one thread, cleared in another. Perhaps
823  // this guarantee of atomicity is more cautious than necessary.
824  wxAtomicInt mRecordingException {};
826  { wxAtomicInc( mRecordingException ); }
828  { if (mRecordingException) wxAtomicDec( mRecordingException ); }
829 
830  std::vector< std::pair<double, double> > mLostCaptureIntervals;
831  bool mDetectDropouts{ true };
832 
833 public:
834  // Pairs of starting time and duration
835  const std::vector< std::pair<double, double> > &LostCaptureIntervals()
836  { return mLostCaptureIntervals; }
837 
838  // Used only for testing purposes in alpha builds
839  bool mSimulateRecordingErrors{ false };
840 
841  // Whether to check the error code passed to audacityAudioCallback to
842  // detect more dropouts
843  bool mDetectUpstreamDropouts{ true };
844 
845 private:
847  double mPreRoll{};
848  double mLatencyCorrection{}; // negative value usually
849  double mDuration{};
851 
852  // These are initialized by the main thread, then updated
853  // only by the thread calling FillBuffers:
854  double mPosition{};
855  bool mLatencyCorrected{};
856 
857  double TotalCorrection() const { return mLatencyCorrection - mPreRoll; }
858  double ToConsume() const;
859  double Consumed() const;
860  double ToDiscard() const;
861  } mRecordingSchedule{};
862 };
863 
864 #endif
AudioIO uses the PortAudio library to play and record sound.
Definition: AudioIO.h:172
wxDECLARE_EXPORTED_EVENT(AUDACITY_DLL_API, EVT_AUDIOIO_PLAYBACK, wxCommandEvent)
double mMinCaptureSecsToCopy
Definition: AudioIO.h:700
static std::vector< long > mCachedSampleRates
Definition: AudioIO.h:778
TimeTrack * timeTrack
Definition: AudioIO.h:137
double TotalCorrection() const
Definition: AudioIO.h:857
static double mCachedBestRateIn
Definition: AudioIO.h:779
static int mNextStreamToken
Definition: AudioIO.h:675
wxLongLong GetLastPlaybackTime() const
Definition: AudioIO.h:246
WaveTrackConstArray prerollTracks
Definition: AudioIO.h:165
sampleCount mScrubDuration
Definition: AudioIO.h:819
const std::vector< std::pair< double, double > > & LostCaptureIntervals()
Definition: AudioIO.h:835
volatile bool mUpdatingMeters
Definition: AudioIO.h:730
float mMixerOutputVol
Definition: AudioIO.h:746
unsigned GetNumCaptureChannels() const
Definition: AudioIO.h:399
double mTime
Current time position during playback, in seconds. Between mT0 and mT1.
Definition: AudioIO.h:684
bool mInputMixerWorks
Can we control the hardware input level?
Definition: AudioIO.h:745
bool mSoftwarePlaythrough
Definition: AudioIO.h:704
void DeinitAudioIO()
Definition: AudioIO.cpp:1149
AudioIOStartStreamOptions(double rate_)
Definition: AudioIO.h:126
const TimeTrack * mTimeTrack
Definition: AudioIO.h:769
MeterPanel * mOutputMeter
Definition: AudioIO.h:728
ArrayOf< std::unique_ptr< RingBuffer > > mPlaybackBuffers
Definition: AudioIO.h:670
ScrubbingOptions * pScrubbingOptions
Definition: AudioIO.h:150
AudioIOListener * GetListener()
Definition: AudioIO.h:178
MeterPanel is a panel that paints the meter used for monitoring or playback.
Definition: Meter.h:97
bool ValidateDeviceNames()
float mSilenceLevel
Definition: AudioIO.h:707
ArrayOf< std::unique_ptr< Resample > > mResample
Definition: AudioIO.h:667
AUDACITY_DLL_API AudioIO * gAudioIO
Definition: AudioIO.cpp:482
sampleFormat mCaptureFormat
Definition: AudioIO.h:710
GrowableSampleBuffer mSilentBuf
Definition: AudioIO.h:758
ArrayOf< std::unique_ptr< Mixer > > mPlaybackMixers
Definition: AudioIO.h:673
std::unique_ptr< ScrubQueue > mScrubQueue
Definition: AudioIO.h:815
double mWarpedTime
Definition: AudioIO.h:689
static int mCachedPlaybackIndex
Definition: AudioIO.h:774
wxMutex mSuspendAudioThread
Definition: AudioIO.h:812
AudacityProject provides the main window, with tools and tracks contained within it.
Definition: Project.h:176
static std::vector< long > mCachedPlaybackRates
Definition: AudioIO.h:775
PRCrossfadeData * pCrossfadeData
Definition: AudioIO.h:154
A kind of Track used to 'warp time'.
Definition: TimeTrack.h:29
bool mPaused
True if audio playback is paused.
Definition: AudioIO.h:702
ArrayOf< std::unique_ptr< RingBuffer > > mCaptureBuffers
Definition: AudioIO.h:668
bool ReversedTime() const
True if the end time is before the start time.
Definition: AudioIO.h:541
volatile int mStreamToken
Definition: AudioIO.h:674
Defines a selected portion of a project.
WaveTrackArray mCaptureTracks
Definition: AudioIO.h:669
bool mEmulateMixerOutputVol
Definition: AudioIO.h:737
std::vector< std::shared_ptr< WaveTrack > > WaveTrackArray
Definition: AudioIO.h:66
PaStream * mPortStreamV19
Definition: AudioIO.h:703
struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether t...
Definition: AudioIO.h:123
static std::vector< long > mCachedCaptureRates
Definition: AudioIO.h:777
void ClearRecordingException()
Definition: AudioIO.h:827
std::vector< std::shared_ptr< const WaveTrack > > WaveTrackConstArray
Definition: AudioIO.h:67
double mCaptureRingBufferSecs
Definition: AudioIO.h:698
sampleFormat
Definition: Types.h:188
int audacityAudioCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
A Track that contains audio waveform data.
Definition: WaveTrack.h:60
wxString DeviceName(const PaDeviceInfo *info)
Definition: AudioIO.cpp:1154
AudacityProject * GetOwningProject() const
Definition: AudioIO.h:247
AudacityProject * mOwningProject
Definition: AudioIO.h:726
wxLongLong mLastPlaybackTimeMillis
Definition: AudioIO.h:716
AudioIOListener * mListener
Definition: AudioIO.h:760
volatile bool mAudioThreadShouldCallFillBuffersOnce
Definition: AudioIO.h:712
bool IsScrubbing()
Definition: AudioIO.h:212
unsigned int mNumPlaybackChannels
Definition: AudioIO.h:709
WaveTrackConstArray playbackTracks
Definition: AudioIO.h:158
double mSeek
Definition: AudioIO.h:696
unsigned int mNumCaptureChannels
Definition: AudioIO.h:708
std::unique_ptr< AudioThread > mThread
Definition: AudioIO.h:661
wxString HostName(const PaDeviceInfo *info)
Definition: AudioIO.cpp:1161
PRCrossfadeData mCrossfadeData
Definition: AudioIO.h:850
std::vector< std::vector< float > > PRCrossfadeData
Definition: AudioIO.h:120
std::vector< std::shared_ptr< const NoteTrack > > NoteTrackConstArray
Definition: Track.h:54
double mRate
Audio playback rate in samples per second.
Definition: AudioIO.h:678
Monitors record play start/stop and new blockfiles. Has callbacks for these events.
bool mUpdateMeters
Definition: AudioIO.h:729
Holds streamed audio samples.
Definition: RingBuffer.h:17
volatile double mLastRecordingOffset
Definition: AudioIO.h:723
Interface to libsoxr.
Definition: Resample.h:32
static int mCachedCaptureIndex
Definition: AudioIO.h:776
static const int NumStandardRates
How many standard sample rates there are.
Definition: AudioIO.h:410
Memory.h template class for making an array of float, bool, etc.
Definition: MemoryX.h:86
sampleFormat GetCaptureFormat()
Definition: AudioIO.h:397
void InitAudioIO()
Definition: AudioIO.cpp:1116
double mWarpedLength
Definition: AudioIO.h:694
double mCutPreviewGapLen
Definition: AudioIO.h:756
double mT0
Playback starts at offset of mT0, which is measured in seconds.
Definition: AudioIO.h:680
double mCutPreviewGapStart
Definition: AudioIO.h:755
static double mCachedBestRateOut
Definition: AudioIO.h:780
std::vector< std::pair< double, double > > mLostCaptureIntervals
Definition: AudioIO.h:830
AudioIOListener * listener
Definition: AudioIO.h:138
static const int NumRatesToTry
How many sample rates to try.
Definition: AudioIO.h:538
volatile bool mAudioThreadFillBuffersLoopActive
Definition: AudioIO.h:714
Functions for doing the mixdown of the tracks.
Definition: Mix.h:80
double mFactor
Definition: AudioIO.h:676
PaError mLastPaError
Definition: AudioIO.h:724
size_t mPlaybackSamplesToCopy
Definition: AudioIO.h:699
void SeekStream(double seconds)
Move the playback / recording position of the current stream by the specified amount from where it is...
Definition: AudioIO.h:209
unsigned GetNumPlaybackChannels() const
Definition: AudioIO.h:398
double mT1
Playback ends at offset of mT1, which is measured in seconds. Note that mT1 may be less than mT0 duri...
Definition: AudioIO.h:682
volatile bool mAudioThreadFillBuffersLoopRunning
Definition: AudioIO.h:713
WaveTrackArray captureTracks
Definition: AudioIO.h:159
bool mPauseRec
True if Sound Activated Recording is enabled.
Definition: AudioIO.h:706
void SetRecordingException()
Definition: AudioIO.h:825
bool mSilentScrub
Definition: AudioIO.h:818
WaveTrackConstArray mPlaybackTracks
Definition: AudioIO.h:671
A Track that is used for Midi notes. (Somewhat old code).
double mPlaybackRingBufferSecs
Definition: AudioIO.h:697
Defined different on Mac and other platforms (on Mac it does not use wxWidgets wxThread), this class sits in a thread loop reading and writing audio.
Definition: AudioIO.cpp:1094