Audacity  3.0.3
Classes | Macros | Typedefs | Functions | Variables
AudioIO.h File Reference
#include "AudioIOBase.h"
#include "PlaybackSchedule.h"
#include <memory>
#include <utility>
#include <wx/atomic.h>
#include <wx/event.h>
#include "SampleFormat.h"
Include dependency graph for AudioIO.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  TransportTracks
 
class  MessageBuffer< Data >
 
struct  MessageBuffer< Data >::UpdateSlot
 
class  AudioIoCallback
 AudioIoCallback is a class that implements the callback required by PortAudio. The callback needs to be responsive, has no GUI, and copies data into and out of the sound card buffers. It also sends data to the meters. More...
 
struct  AudioIoCallback::TimeQueue
 
struct  AudioIoCallback::TimeQueue::Cursor
 
class  AudioIO
 AudioIO uses the PortAudio library to play and record sound. More...
 

Macros

#define MAX_MIDI_BUFFER_SIZE   5000
 
#define DEFAULT_SYNTH_LATENCY   5
 
#define USE_MIDI_THREAD
 
#define AUDIO_IO_GB_MIDI_WORKAROUND
 

Typedefs

using WaveTrackArray = std::vector< std::shared_ptr< WaveTrack > >
 
using WaveTrackConstArray = std::vector< std::shared_ptr< const WaveTrack > >
 
typedef unsigned long PaStreamCallbackFlags
 
typedef int PaError
 

Functions

bool ValidateDeviceNames ()
 
 wxDECLARE_EXPORTED_EVENT (AUDACITY_DLL_API, EVT_AUDIOIO_PLAYBACK, wxCommandEvent)
 
 wxDECLARE_EXPORTED_EVENT (AUDACITY_DLL_API, EVT_AUDIOIO_CAPTURE, wxCommandEvent)
 
 wxDECLARE_EXPORTED_EVENT (AUDACITY_DLL_API, EVT_AUDIOIO_MONITOR, wxCommandEvent)
 
int audacityAudioCallback (const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
 

Variables

static constexpr unsigned ScrubPollInterval_ms = 50
 

Macro Definition Documentation

◆ AUDIO_IO_GB_MIDI_WORKAROUND

#define AUDIO_IO_GB_MIDI_WORKAROUND

Definition at line 99 of file AudioIO.h.

◆ DEFAULT_SYNTH_LATENCY

#define DEFAULT_SYNTH_LATENCY   5

Definition at line 67 of file AudioIO.h.

◆ MAX_MIDI_BUFFER_SIZE

#define MAX_MIDI_BUFFER_SIZE   5000

Definition at line 66 of file AudioIO.h.

◆ USE_MIDI_THREAD

#define USE_MIDI_THREAD

Definition at line 84 of file AudioIO.h.

Typedef Documentation

◆ PaError

typedef int PaError

Definition at line 62 of file AudioIO.h.

◆ PaStreamCallbackFlags

typedef unsigned long PaStreamCallbackFlags

Definition at line 61 of file AudioIO.h.

◆ WaveTrackArray

using WaveTrackArray = std::vector < std::shared_ptr < WaveTrack > >

Definition at line 57 of file AudioIO.h.

◆ WaveTrackConstArray

using WaveTrackConstArray = std::vector < std::shared_ptr < const WaveTrack > >

Definition at line 58 of file AudioIO.h.

Function Documentation

◆ audacityAudioCallback()

int audacityAudioCallback ( const void *  inputBuffer,
void *  outputBuffer,
unsigned long  framesPerBuffer,
const PaStreamCallbackTimeInfo *  timeInfo,
PaStreamCallbackFlags  statusFlags,
void *  userData 
)

brief The function which is called from PortAudio's callback thread context to collect and deliver audio for / from the sound device.

This covers recording, playback, and doing both simultaneously. It is also invoked to do monitoring and software playthrough. Note that dealing with the two buffers needs some care to ensure that the right things happen for all possible cases.

Parameters
inputBufferBuffer of length framesPerBuffer containing samples from the sound card, or null if not capturing audio. Note that the data type will depend on the format of audio data that was chosen when the stream was created (so could be floats or various integers)
outputBufferUninitialised buffer of length framesPerBuffer which will be sent to the sound card after the callback, or null if not playing audio back.
framesPerBufferThe length of the playback and recording buffers
PaStreamCallbackTimeInfoPointer to PortAudio time information structure, which tells us how long we have been playing / recording
statusFlagsPortAudio stream status flags
userDatapointer to user-defined data structure. Provided for flexibility by PortAudio, but not used by Audacity - the data is stored in the AudioIO class instead.

Definition at line 3636 of file AudioIO.cpp.

3640 {
3641  auto gAudioIO = AudioIO::Get();
3642  return gAudioIO->AudioCallback(
3643  inputBuffer, outputBuffer, framesPerBuffer,
3644  timeInfo, statusFlags, userData);
3645 }

References AudioIoCallback::AudioCallback(), and AudioIO::Get().

Referenced by AudioIO::StartPortAudioStream().

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

◆ ValidateDeviceNames()

bool ValidateDeviceNames ( )

◆ wxDECLARE_EXPORTED_EVENT() [1/3]

wxDECLARE_EXPORTED_EVENT ( AUDACITY_DLL_API  ,
EVT_AUDIOIO_CAPTURE  ,
wxCommandEvent   
)

◆ wxDECLARE_EXPORTED_EVENT() [2/3]

wxDECLARE_EXPORTED_EVENT ( AUDACITY_DLL_API  ,
EVT_AUDIOIO_MONITOR  ,
wxCommandEvent   
)

◆ wxDECLARE_EXPORTED_EVENT() [3/3]

wxDECLARE_EXPORTED_EVENT ( AUDACITY_DLL_API  ,
EVT_AUDIOIO_PLAYBACK  ,
wxCommandEvent   
)

Variable Documentation

◆ ScrubPollInterval_ms

constexpr unsigned ScrubPollInterval_ms = 50
staticconstexpr

Definition at line 792 of file AudioIO.h.

Referenced by AudioThread::Entry(), and Scrubber::ScrubPollerThread::Entry().

AudioIO::Get
static AudioIO * Get()
Definition: AudioIO.cpp:505