49#define RTAUDIO_VERSION_MAJOR 6
50#define RTAUDIO_VERSION_MINOR 0
51#define RTAUDIO_VERSION_PATCH 1
52#define RTAUDIO_VERSION_BETA 0
54#define RTAUDIO_TOSTRING2(n) #n
55#define RTAUDIO_TOSTRING(n) RTAUDIO_TOSTRING2(n)
57#if RTAUDIO_VERSION_BETA > 0
58 #define RTAUDIO_VERSION RTAUDIO_TOSTRING(RTAUDIO_VERSION_MAJOR) \
59 "." RTAUDIO_TOSTRING(RTAUDIO_VERSION_MINOR) \
60 "." RTAUDIO_TOSTRING(RTAUDIO_VERSION_PATCH) \
61 "beta" RTAUDIO_TOSTRING(RTAUDIO_VERSION_BETA)
63 #define RTAUDIO_VERSION RTAUDIO_TOSTRING(RTAUDIO_VERSION_MAJOR) \
64 "." RTAUDIO_TOSTRING(RTAUDIO_VERSION_MINOR) \
65 "." RTAUDIO_TOSTRING(RTAUDIO_VERSION_PATCH)
68#if defined _WIN32 || defined __CYGWIN__
69 #if defined(RTAUDIO_EXPORT)
70 #define RTAUDIO_DLL_PUBLIC __declspec(dllexport)
72 #define RTAUDIO_DLL_PUBLIC
76 #define RTAUDIO_DLL_PUBLIC __attribute__( (visibility( "default" )) )
78 #define RTAUDIO_DLL_PUBLIC
223 unsigned int nFrames,
249 const std::string &errorText )>
290 unsigned int outputChannels{};
291 unsigned int inputChannels{};
292 unsigned int duplexChannels{};
293 bool isDefaultOutput{
false};
294 bool isDefaultInput{
false};
296 unsigned int currentSampleRate{};
297 unsigned int preferredSampleRate{};
304 unsigned int deviceId{};
305 unsigned int nChannels{};
306 unsigned int firstChannel{};
370 unsigned int numberOfBuffers{};
452 unsigned int getDeviceCount(
void );
465 std::vector<unsigned int> getDeviceIds(
void );
475 std::vector<std::string> getDeviceNames(
void );
499 unsigned int getDefaultOutputDevice(
void );
508 unsigned int getDefaultInputDevice(
void );
560 void closeStream(
void );
592 const std::string getErrorText(
void );
595 bool isStreamOpen(
void )
const;
598 bool isStreamRunning(
void )
const;
608 double getStreamTime(
void );
611 void setStreamTime(
double time );
622 long getStreamLatency(
void );
630 unsigned int getStreamSampleRate(
void );
641 void showWarnings(
bool value =
true );
659 typedef uintptr_t ThreadHandle;
660 typedef CRITICAL_SECTION StreamMutex;
667 typedef pthread_t ThreadHandle;
668 typedef pthread_mutex_t StreamMutex;
673#if !(defined(__WINDOWS_DS__) || defined(__WINDOWS_ASIO__) || defined(__WINDOWS_WASAPI__) \
674 || defined(__LINUX_ALSA__) || defined(__LINUX_PULSE__) || defined(__UNIX_JACK__) \
675 || defined(__LINUX_OSS__) || defined(__MACOSX_CORE__))
677 #define __RTAUDIO_DUMMY__
686 ThreadHandle thread{};
690 bool isRunning{
false};
691 bool doRealtime{
false};
693 bool deviceDisconnected{
false};
719 S24& operator = (
const int& i ) {
720 c3[0] = (
unsigned char)(i & 0x000000ff);
721 c3[1] = (
unsigned char)((i & 0x0000ff00) >> 8);
722 c3[2] = (
unsigned char)((i & 0x00ff0000) >> 16);
726 S24(
const double& d ) { *
this = (int) d; }
727 S24(
const float& f ) { *
this = (int) f; }
728 S24(
const signed short& s ) { *
this = (int) s; }
729 S24(
const char& c ) { *
this = (int) c; }
732 int i = c3[0] | (c3[1] << 8) | (c3[2] << 16);
733 if (i & 0x800000) i |= ~0xffffff;
739#if defined( HAVE_GETTIMEOFDAY )
740 #include <sys/time.h>
745class RTAUDIO_DLL_PUBLIC RtApi
752 unsigned int getDeviceCount(
void );
753 std::vector<unsigned int> getDeviceIds(
void );
754 std::vector<std::string> getDeviceNames(
void );
756 virtual unsigned int getDefaultInputDevice(
void );
757 virtual unsigned int getDefaultOutputDevice(
void );
763 virtual void closeStream(
void );
767 const std::string getErrorText(
void )
const {
return errorText_; }
768 long getStreamLatency(
void );
769 unsigned int getStreamSampleRate(
void );
770 virtual double getStreamTime(
void )
const {
return stream_.streamTime; }
771 virtual void setStreamTime(
double time );
772 bool isStreamOpen(
void )
const {
return stream_.state != STREAM_CLOSED; }
773 bool isStreamRunning(
void )
const {
return stream_.state == STREAM_RUNNING; }
775 void showWarnings(
bool value ) { showWarnings_ = value; }
780 static const unsigned int MAX_SAMPLE_RATES;
781 static const unsigned int SAMPLE_RATES[];
783 enum { FAILURE, SUCCESS };
804 std::vector<int> inOffset;
805 std::vector<int> outOffset;
810 unsigned int deviceId[2];
816 bool doConvertBuffer[2];
817 bool userInterleaved;
818 bool deviceInterleaved[2];
820 unsigned int sampleRate;
821 unsigned int bufferSize;
822 unsigned int nBuffers;
823 unsigned int nUserChannels[2];
824 unsigned int nDeviceChannels[2];
825 unsigned int channelOffset[2];
826 unsigned long latency[2];
830 CallbackInfo callbackInfo;
831 ConvertInfo convertInfo[2];
834#if defined(HAVE_GETTIMEOFDAY)
835 struct timeval lastTickTimestamp;
839 :apiHandle(0), deviceBuffer(0) {}
843 typedef signed short Int16;
844 typedef signed int Int32;
845 typedef float Float32;
846 typedef double Float64;
848 std::ostringstream errorStream_;
849 std::string errorText_;
852 std::vector<RtAudio::DeviceInfo> deviceList_;
853 unsigned int currentDeviceId_;
864 virtual void probeDevices(
void );
873 virtual bool probeDeviceOpen(
unsigned int deviceId, StreamMode mode,
unsigned int channels,
874 unsigned int firstChannel,
unsigned int sampleRate,
879 void tickStreamTime(
void );
882 void clearStreamInfo();
891 void convertBuffer(
char *outBuffer,
char *inBuffer, ConvertInfo &info );
894 void byteSwapBuffer(
char *buffer,
unsigned int samples,
RtAudioFormat format );
900 void setConvertInfo( StreamMode mode,
unsigned int firstChannel );
909inline RtAudio::Api RtAudio :: getCurrentApi(
void ) {
return rtapi_->getCurrentApi(); }
910inline unsigned int RtAudio :: getDeviceCount(
void ) {
return rtapi_->getDeviceCount(); }
911inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo(
unsigned int deviceId ) {
return rtapi_->getDeviceInfo( deviceId ); }
912inline std::vector<unsigned int> RtAudio :: getDeviceIds(
void ) {
return rtapi_->getDeviceIds(); }
913inline std::vector<std::string> RtAudio :: getDeviceNames(
void ) {
return rtapi_->getDeviceNames(); }
914inline unsigned int RtAudio :: getDefaultInputDevice(
void ) {
return rtapi_->getDefaultInputDevice(); }
915inline unsigned int RtAudio :: getDefaultOutputDevice(
void ) {
return rtapi_->getDefaultOutputDevice(); }
916inline void RtAudio :: closeStream(
void ) {
return rtapi_->closeStream(); }
920inline const std::string RtAudio :: getErrorText(
void ) {
return rtapi_->getErrorText(); }
921inline bool RtAudio :: isStreamOpen(
void )
const {
return rtapi_->isStreamOpen(); }
922inline bool RtAudio :: isStreamRunning(
void )
const {
return rtapi_->isStreamRunning(); }
923inline long RtAudio :: getStreamLatency(
void ) {
return rtapi_->getStreamLatency(); }
924inline unsigned int RtAudio :: getStreamSampleRate(
void ) {
return rtapi_->getStreamSampleRate(); }
925inline double RtAudio :: getStreamTime(
void ) {
return rtapi_->getStreamTime(); }
926inline void RtAudio :: setStreamTime(
double time ) {
return rtapi_->setStreamTime( time ); }
927inline void RtAudio :: setErrorCallback(
RtAudioErrorCallback errorCallback ) { rtapi_->setErrorCallback( errorCallback ); }
928inline void RtAudio :: showWarnings(
bool value ) { rtapi_->showWarnings( value ); }
unsigned int RtAudioStreamFlags
RtAudio stream option flags.
Definition RtAudio.h:159
std::function< void(RtAudioErrorType type, const std::string &errorText)> RtAudioErrorCallback
RtAudio error callback function prototype.
Definition RtAudio.h:250
unsigned int RtAudioStreamStatus
RtAudio stream status (over- or underflow) flags.
Definition RtAudio.h:178
int(* RtAudioCallback)(void *outputBuffer, void *inputBuffer, unsigned int nFrames, double streamTime, RtAudioStreamStatus status, void *userData)
RtAudio callback function prototype.
Definition RtAudio.h:222
unsigned long RtAudioFormat
RtAudio data format type.
Definition RtAudio.h:105
RtAudioErrorType
Definition RtAudio.h:228
@ RTAUDIO_DEVICE_DISCONNECT
Definition RtAudio.h:234
@ RTAUDIO_DRIVER_ERROR
Definition RtAudio.h:238
@ RTAUDIO_NO_ERROR
Definition RtAudio.h:229
@ RTAUDIO_INVALID_PARAMETER
Definition RtAudio.h:236
@ RTAUDIO_INVALID_DEVICE
Definition RtAudio.h:233
@ RTAUDIO_SYSTEM_ERROR
Definition RtAudio.h:239
@ RTAUDIO_WARNING
Definition RtAudio.h:230
@ RTAUDIO_THREAD_ERROR
Definition RtAudio.h:240
@ RTAUDIO_INVALID_USE
Definition RtAudio.h:237
@ RTAUDIO_UNKNOWN_ERROR
Definition RtAudio.h:231
@ RTAUDIO_NO_DEVICES_FOUND
Definition RtAudio.h:232
@ RTAUDIO_MEMORY_ERROR
Definition RtAudio.h:235
Realtime audio i/o C++ classes.
Definition RtAudio.h:268
static RtAudio::Api getCompiledApiByDisplayName(const std::string &name)
Return the compiled audio API having the given display name.
static std::string getApiName(RtAudio::Api api)
Return the name of a specified compiled audio API.
static std::string getApiDisplayName(RtAudio::Api api)
Return the display name of a specified compiled audio API.
RtAudioErrorType openStream(RtAudio::StreamParameters *outputParameters, RtAudio::StreamParameters *inputParameters, RtAudioFormat format, unsigned int sampleRate, unsigned int *bufferFrames, RtAudioCallback callback, void *userData=NULL, RtAudio::StreamOptions *options=NULL)
A public function for opening a stream with the specified parameters.
~RtAudio()
The destructor.
static RtAudio::Api getCompiledApiByName(const std::string &name)
Return the compiled audio API having the given name.
Api
Audio API specifier arguments.
Definition RtAudio.h:272
@ WINDOWS_ASIO
Definition RtAudio.h:279
@ WINDOWS_DS
Definition RtAudio.h:281
@ LINUX_OSS
Definition RtAudio.h:278
@ UNIX_JACK
Definition RtAudio.h:276
@ MACOSX_CORE
Definition RtAudio.h:274
@ UNSPECIFIED
Definition RtAudio.h:273
@ LINUX_ALSA
Definition RtAudio.h:275
@ RTAUDIO_DUMMY
Definition RtAudio.h:282
@ WINDOWS_WASAPI
Definition RtAudio.h:280
@ LINUX_PULSE
Definition RtAudio.h:277
RtAudio(RtAudio::Api api=UNSPECIFIED, RtAudioErrorCallback &&errorCallback=0)
The class constructor.
static void getCompiledApi(std::vector< RtAudio::Api > &apis)
A static function to determine the available compiled audio APIs.
static std::string getVersion(void)
A static function to determine the current RtAudio version.
The public device information structure for returning queried values.
Definition RtAudio.h:287
std::string name
Definition RtAudio.h:289
std::vector< unsigned int > sampleRates
Definition RtAudio.h:295
The structure for specifying stream options.
Definition RtAudio.h:368
std::string streamName
Definition RtAudio.h:371
The structure for specifying input or output stream parameters.
Definition RtAudio.h:302