Audacity  2.2.2
Classes | Macros | Typedefs | Functions | Variables
AudioIO.h File Reference
#include "portaudio.h"
#include "Audacity.h"
#include "Experimental.h"
#include "MemoryX.h"
#include <utility>
#include <vector>
#include <wx/atomic.h>
#include <wx/weakref.h>
#include <wx/event.h>
#include <wx/string.h>
#include <wx/thread.h>
#include "SampleFormat.h"

Go to the source code of this file.

Classes

class  AudioIOStartStreamOptions
 struct holding stream options, including a pointer to the TimeTrack and AudioIOListener and whether the playback is looped. More...
 
class  AudioIO
 AudioIO uses the PortAudio library to play and record sound. More...
 

Macros

#define BAD_STREAM_TIME   (-DBL_MAX)
 
#define MAX_MIDI_BUFFER_SIZE   5000
 
#define DEFAULT_SYNTH_LATENCY   5
 
#define DEFAULT_LATENCY_DURATION   100.0
 
#define DEFAULT_LATENCY_CORRECTION   -130.0
 
#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 > >
 

Functions

void InitAudioIO ()
 
void DeinitAudioIO ()
 
wxString DeviceName (const PaDeviceInfo *info)
 
wxString HostName (const PaDeviceInfo *info)
 
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)
 

Variables

AUDACITY_DLL_API AudioIOgAudioIO
 

Macro Definition Documentation

#define AUDIO_IO_GB_MIDI_WORKAROUND

Definition at line 145 of file AudioIO.h.

#define BAD_STREAM_TIME   (-DBL_MAX)
#define DEFAULT_LATENCY_CORRECTION   -130.0
#define DEFAULT_LATENCY_DURATION   100.0
#define DEFAULT_SYNTH_LATENCY   5

Definition at line 82 of file AudioIO.h.

#define MAX_MIDI_BUFFER_SIZE   5000

Definition at line 81 of file AudioIO.h.

#define USE_MIDI_THREAD

Definition at line 109 of file AudioIO.h.

Referenced by audacityAudioCallback().

Typedef Documentation

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

Definition at line 65 of file AudioIO.h.

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

Definition at line 66 of file AudioIO.h.

Function Documentation

void DeinitAudioIO ( )

Definition at line 1149 of file AudioIO.cpp.

Referenced by AudacityApp::OnExit().

1150 {
1151  ugAudioIO.reset();
1152 }
std::unique_ptr< AudioIO > ugAudioIO
Definition: AudioIO.cpp:481
wxString DeviceName ( const PaDeviceInfo *  info)

Definition at line 1154 of file AudioIO.cpp.

Referenced by AudioIO::GetDeviceInfo(), AudioIO::getPlayDevIndex(), AudioIO::getRecordDevIndex(), and InitAudioIO().

1155 {
1156  wxString infoName = wxSafeConvertMB2WX(info->name);
1157 
1158  return infoName;
1159 }
wxString HostName ( const PaDeviceInfo *  info)

Definition at line 1161 of file AudioIO.cpp.

Referenced by AudioIO::GetDeviceInfo(), and InitAudioIO().

1162 {
1163  wxString hostapiName = wxSafeConvertMB2WX(Pa_GetHostApiInfo(info->hostApi)->name);
1164 
1165  return hostapiName;
1166 }
void InitAudioIO ( )

Definition at line 1116 of file AudioIO.cpp.

References DeviceName(), gAudioIO, AudioIO::getPlayDevIndex(), AudioIO::getRecordDevIndex(), gPrefs, HostName(), AudioIO::mThread, and safenew.

Referenced by AudacityApp::OnInit().

1117 {
1118  ugAudioIO.reset(safenew AudioIO());
1119  gAudioIO = ugAudioIO.get();
1120  gAudioIO->mThread->Run();
1121 #ifdef EXPERIMENTAL_MIDI_OUT
1122 #ifdef USE_MIDI_THREAD
1123  gAudioIO->mMidiThread->Run();
1124 #endif
1125 #endif
1126 
1127  // Make sure device prefs are initialized
1128  if (gPrefs->Read(wxT("AudioIO/RecordingDevice"), wxT("")) == wxT("")) {
1129  int i = AudioIO::getRecordDevIndex();
1130  const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
1131  if (info) {
1132  gPrefs->Write(wxT("/AudioIO/RecordingDevice"), DeviceName(info));
1133  gPrefs->Write(wxT("/AudioIO/Host"), HostName(info));
1134  }
1135  }
1136 
1137  if (gPrefs->Read(wxT("AudioIO/PlaybackDevice"), wxT("")) == wxT("")) {
1138  int i = AudioIO::getPlayDevIndex();
1139  const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
1140  if (info) {
1141  gPrefs->Write(wxT("/AudioIO/PlaybackDevice"), DeviceName(info));
1142  gPrefs->Write(wxT("/AudioIO/Host"), HostName(info));
1143  }
1144  }
1145 
1146  gPrefs->Flush();
1147 }
AudioIO uses the PortAudio library to play and record sound.
Definition: AudioIO.h:147
AudacityPrefs * gPrefs
Definition: Prefs.cpp:73
std::unique_ptr< AudioIO > ugAudioIO
Definition: AudioIO.cpp:481
wxString DeviceName(const PaDeviceInfo *info)
Definition: AudioIO.cpp:1154
static int getPlayDevIndex(const wxString &devName=wxEmptyString)
get the index of the device selected in the preferences.
Definition: AudioIO.cpp:3356
wxString HostName(const PaDeviceInfo *info)
Definition: AudioIO.cpp:1161
#define safenew
Definition: Audacity.h:230
std::unique_ptr< AudioThread > mThread
Definition: AudioIO.h:634
AudioIO * gAudioIO
Definition: AudioIO.cpp:482
static int getRecordDevIndex(const wxString &devName=wxEmptyString)
get the index of the supplied (named) recording device, or the device selected in the preferences if ...
Definition: AudioIO.cpp:3413
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   
)

Variable Documentation

AUDACITY_DLL_API AudioIO* gAudioIO

Definition at line 482 of file AudioIO.cpp.