rtaudio-4.1.1~ds0.orig/0000755000175000017500000000000012331225362014607 5ustar alessioalessiortaudio-4.1.1~ds0.orig/librtaudio.pc.in0000644000175000017500000000053412326776523017716 0ustar alessioalessioprefix=@prefix@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${prefix}/include Name: librtaudio Description: RtAudio - a set of C++ classes that provide a common API for realtime audio input/output Version: 4.1.1 Requires: @req@ Libs: -L${libdir} -lrtaudio Libs.private: -lpthread Cflags: -pthread -I${includedir} @CPPFLAGS@rtaudio-4.1.1~ds0.orig/readme0000644000175000017500000000673312326776523016016 0ustar alessioalessioRtAudio - a set of C++ classes that provide a common API for realtime audio input/output across Linux (native ALSA, JACK, PulseAudio and OSS), Macintosh OS X (CoreAudio and JACK), and Windows (DirectSound, ASIO and WASAPI) operating systems. By Gary P. Scavone, 2001-2014. This distribution of RtAudio contains the following: doc: RtAudio documentation (see doc/html/index.html) tests: example RtAudio programs include: header and source files necessary for ASIO, DS & OSS compilation tests/Windows: Visual C++ .net test program workspace and projects OVERVIEW: RtAudio is a set of C++ classes that provides a common API (Application Programming Interface) for realtime audio input/output across Linux (native ALSA, JACK, and OSS), Macintosh OS X, SGI, and Windows (DirectSound, ASIO and WASAPI) operating systems. RtAudio significantly simplifies the process of interacting with computer audio hardware. It was designed with the following objectives: - object-oriented C++ design - simple, common API across all supported platforms - only one source and one header file for easy inclusion in programming projects - allow simultaneous multi-api support - support dynamic connection of devices - provide extensive audio device parameter control - allow audio device capability probing - automatic internal conversion for data format, channel number compensation, (de)interleaving, and byte-swapping RtAudio incorporates the concept of audio streams, which represent audio output (playback) and/or input (recording). Available audio devices and their capabilities can be enumerated and then specified when opening a stream. Where applicable, multiple API support can be compiled and a particular API specified when creating an RtAudio instance. See the \ref apinotes section for information specific to each of the supported audio APIs. FURTHER READING: For complete documentation on RtAudio, see the doc directory of the distribution or surf to http://www.music.mcgill.ca/~gary/rtaudio/. LEGAL AND ETHICAL: The RtAudio license is similar to the MIT License. RtAudio: a set of realtime audio i/o C++ classes Copyright (c) 2001-2014 Gary P. Scavone Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Any person wishing to distribute modifications to the Software is asked to send the modifications to the original developer so that they can be incorporated into the canonical version. This is, however, not a binding provision of this license. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. rtaudio-4.1.1~ds0.orig/tests/0000755000175000017500000000000012331225362015751 5ustar alessioalessiortaudio-4.1.1~ds0.orig/tests/teststops.cpp0000644000175000017500000001722512326776523020552 0ustar alessioalessio/******************************************/ /* teststop.cpp by Gary P. Scavone, 2011 This program starts and stops an RtAudio stream many times in succession and in different ways to to test its functionality. */ /******************************************/ #include "RtAudio.h" #include #include #include #include #define PULSE_RATE 0.01 // seconds #define RUNTIME 0.4 // seconds #define PAUSETIME 0.1 // seconds #define REPETITIONS 10 // Platform-dependent sleep routines. #if defined( __WINDOWS_ASIO__ ) || defined( __WINDOWS_DS__ ) || defined( __WINDOWS_WASAPI__ ) #include #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) #else // Unix variants #include #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) #endif void usage( void ) { // Error function in case of incorrect command-line // argument specifications std::cout << "\nuseage: teststops N fs \n"; std::cout << " where N = number of channels,\n"; std::cout << " fs = the sample rate,\n"; std::cout << " iDevice = optional input device to use (default = 0),\n"; std::cout << " oDevice = optional output device to use (default = 0),\n"; std::cout << " iChannelOffset = an optional input channel offset (default = 0),\n"; std::cout << " and oChannelOffset = optional output channel offset (default = 0).\n\n"; exit( 0 ); } struct MyData { unsigned int channels; unsigned int pulseCount; unsigned int frameCounter; unsigned int nFrames; unsigned int returnValue; }; // Interleaved buffers int pulse( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames, double /*streamTime*/, RtAudioStreamStatus status, void *mydata ) { // Write out a pulse signal and ignore the input buffer. unsigned int i, j; float sample; float *buffer = (float *) outputBuffer; MyData *data = (MyData *) mydata; if ( status ) std::cout << "Stream over/underflow detected!" << std::endl; for ( i=0; iframeCounter % data->pulseCount == 0 ) sample = 0.9; else sample = 0.0; for ( j=0; jchannels; j++ ) *buffer++ = sample; data->frameCounter++; } if ( data->frameCounter >= data->nFrames ) return data->returnValue; else return 0; } int main( int argc, char *argv[] ) { unsigned int bufferFrames, fs, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0; unsigned int runtime, pausetime; char input; // minimal command-line checking if (argc < 3 || argc > 7 ) usage(); RtAudio *adc = new RtAudio(); if ( adc->getDeviceCount() < 1 ) { std::cout << "\nNo audio devices found!\n"; exit( 1 ); } MyData mydata; mydata.channels = (unsigned int) atoi( argv[1] ); fs = (unsigned int) atoi( argv[2] ); if ( argc > 3 ) iDevice = (unsigned int) atoi( argv[3] ); if ( argc > 4 ) oDevice = (unsigned int) atoi(argv[4]); if ( argc > 5 ) iOffset = (unsigned int) atoi(argv[5]); if ( argc > 6 ) oOffset = (unsigned int) atoi(argv[6]); // Let RtAudio print messages to stderr. adc->showWarnings( true ); runtime = RUNTIME * 1000; pausetime = PAUSETIME * 1000; // Set our stream parameters for a duplex stream. bufferFrames = 512; RtAudio::StreamParameters oParams, iParams; oParams.deviceId = oDevice; oParams.nChannels = mydata.channels; oParams.firstChannel = oOffset; iParams.deviceId = iDevice; iParams.nChannels = mydata.channels; iParams.firstChannel = iOffset; if ( iDevice == 0 ) iParams.deviceId = adc->getDefaultInputDevice(); if ( oDevice == 0 ) oParams.deviceId = adc->getDefaultOutputDevice(); // First, test external stopStream() calls. mydata.pulseCount = PULSE_RATE * fs; mydata.nFrames = 50 * fs; mydata.returnValue = 0; try { adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata ); std::cout << "Press to start test.\n"; std::cin.get( input ); for (int i=0; istartStream(); std::cout << "Stream started ... "; SLEEP( runtime ); adc->stopStream(); std::cout << "stream externally stopped.\n"; SLEEP( pausetime ); } } catch ( RtAudioError& e ) { e.printMessage(); goto cleanup; } adc->closeStream(); // Next, test internal stopStream() calls. mydata.nFrames = (unsigned int) (RUNTIME * fs); mydata.returnValue = 1; try { adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata ); std::cin.clear(); fflush(stdin); std::cout << "\nPress to continue test.\n"; std::cin.get( input ); for (int i=0; istartStream(); std::cout << "Stream started ... "; while ( adc->isStreamRunning() ) SLEEP( 5 ); std::cout << "stream stopped via callback return value = 1.\n"; SLEEP( pausetime ); } } catch ( RtAudioError& e ) { e.printMessage(); goto cleanup; } adc->closeStream(); // Test internal abortStream() calls. mydata.returnValue = 2; try { adc->openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata ); std::cin.clear(); fflush(stdin); std::cout << "\nPress to continue test.\n"; std::cin.get( input ); for (int i=0; istartStream(); std::cout << "Stream started ... "; while ( adc->isStreamRunning() ) SLEEP( 5 ); std::cout << "stream aborted via callback return value = 2.\n"; SLEEP( pausetime ); } } catch ( RtAudioError& e ) { e.printMessage(); goto cleanup; } adc->closeStream(); // Test consecutive stream re-opening. mydata.returnValue = 0; mydata.nFrames = 50 * fs; try { std::cin.clear(); fflush(stdin); std::cout << "\nPress to continue test.\n"; std::cin.get( input ); for (int i=0; iopenStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata ); mydata.frameCounter = 0; adc->startStream(); std::cout << "New stream started ... "; SLEEP( runtime ); adc->stopStream(); adc->closeStream(); std::cout << "stream stopped externally and closed.\n"; SLEEP( pausetime ); } } catch ( RtAudioError& e ) { e.printMessage(); goto cleanup; } delete adc; adc = 0; // Test consecutive RtAudio creating and deletion. try { std::cin.clear(); fflush(stdin); std::cout << "\nPress to continue test.\n"; std::cin.get( input ); for (int i=0; iopenStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &pulse, (void *)&mydata ); mydata.frameCounter = 0; adc->startStream(); std::cout << "New instance and stream started ... "; SLEEP( runtime ); adc->stopStream(); adc->closeStream(); delete adc; adc = 0; std::cout << "stream stopped and instance deleted.\n"; SLEEP( pausetime ); } } catch ( RtAudioError& e ) { e.printMessage(); goto cleanup; } cleanup: if ( adc && adc->isStreamOpen() ) adc->closeStream(); if ( adc ) delete adc; return 0; } rtaudio-4.1.1~ds0.orig/tests/testall.cpp0000644000175000017500000001476112326776523020154 0ustar alessioalessio/******************************************/ /* testall.cpp by Gary P. Scavone, 2007-2008 This program will make a variety of calls to extensively test RtAudio functionality. */ /******************************************/ #include "RtAudio.h" #include #include #include #define BASE_RATE 0.005 #define TIME 1.0 void usage( void ) { // Error function in case of incorrect command-line // argument specifications std::cout << "\nuseage: testall N fs \n"; std::cout << " where N = number of channels,\n"; std::cout << " fs = the sample rate,\n"; std::cout << " iDevice = optional input device to use (default = 0),\n"; std::cout << " oDevice = optional output device to use (default = 0),\n"; std::cout << " iChannelOffset = an optional input channel offset (default = 0),\n"; std::cout << " and oChannelOffset = optional output channel offset (default = 0).\n\n"; exit( 0 ); } unsigned int channels; // Interleaved buffers int sawi( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames, double /*streamTime*/, RtAudioStreamStatus status, void *data ) { unsigned int i, j; extern unsigned int channels; double *buffer = (double *) outputBuffer; double *lastValues = (double *) data; if ( status ) std::cout << "Stream underflow detected!" << std::endl; for ( i=0; i= 1.0 ) lastValues[j] -= 2.0; } } return 0; } // Non-interleaved buffers int sawni( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames, double /*streamTime*/, RtAudioStreamStatus status, void *data ) { unsigned int i, j; extern unsigned int channels; double *buffer = (double *) outputBuffer; double *lastValues = (double *) data; if ( status ) std::cout << "Stream underflow detected!" << std::endl; float increment; for ( j=0; j= 1.0 ) lastValues[j] -= 2.0; } } return 0; } int inout( void *outputBuffer, void *inputBuffer, unsigned int /*nBufferFrames*/, double /*streamTime*/, RtAudioStreamStatus status, void *data ) { // Since the number of input and output channels is equal, we can do // a simple buffer copy operation here. if ( status ) std::cout << "Stream over/underflow detected." << std::endl; unsigned int *bytes = (unsigned int *) data; memcpy( outputBuffer, inputBuffer, *bytes ); return 0; } int main( int argc, char *argv[] ) { unsigned int bufferFrames, fs, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0; char input; // minimal command-line checking if (argc < 3 || argc > 7 ) usage(); RtAudio dac; if ( dac.getDeviceCount() < 1 ) { std::cout << "\nNo audio devices found!\n"; exit( 1 ); } channels = (unsigned int) atoi( argv[1] ); fs = (unsigned int) atoi( argv[2] ); if ( argc > 3 ) iDevice = (unsigned int) atoi( argv[3] ); if ( argc > 4 ) oDevice = (unsigned int) atoi(argv[4]); if ( argc > 5 ) iOffset = (unsigned int) atoi(argv[5]); if ( argc > 6 ) oOffset = (unsigned int) atoi(argv[6]); double *data = (double *) calloc( channels, sizeof( double ) ); // Let RtAudio print messages to stderr. dac.showWarnings( true ); // Set our stream parameters for output only. bufferFrames = 512; RtAudio::StreamParameters oParams, iParams; oParams.deviceId = oDevice; oParams.nChannels = channels; oParams.firstChannel = oOffset; if ( oDevice == 0 ) oParams.deviceId = dac.getDefaultOutputDevice(); RtAudio::StreamOptions options; options.flags = RTAUDIO_HOG_DEVICE; try { dac.openStream( &oParams, NULL, RTAUDIO_FLOAT64, fs, &bufferFrames, &sawi, (void *)data, &options ); std::cout << "\nStream latency = " << dac.getStreamLatency() << std::endl; // Start the stream dac.startStream(); std::cout << "\nPlaying ... press to stop.\n"; std::cin.get( input ); // Stop the stream dac.stopStream(); // Restart again std::cout << "Press to restart.\n"; std::cin.get( input ); dac.startStream(); // Test abort function std::cout << "Playing again ... press to abort.\n"; std::cin.get( input ); dac.abortStream(); // Restart another time std::cout << "Press to restart again.\n"; std::cin.get( input ); dac.startStream(); std::cout << "Playing again ... press to close the stream.\n"; std::cin.get( input ); } catch ( RtAudioError& e ) { e.printMessage(); goto cleanup; } if ( dac.isStreamOpen() ) dac.closeStream(); // Test non-interleaved functionality options.flags = RTAUDIO_NONINTERLEAVED; try { dac.openStream( &oParams, NULL, RTAUDIO_FLOAT64, fs, &bufferFrames, &sawni, (void *)data, &options ); std::cout << "Press to start non-interleaved playback.\n"; std::cin.get( input ); // Start the stream dac.startStream(); std::cout << "\nPlaying ... press to stop.\n"; std::cin.get( input ); } catch ( RtAudioError& e ) { e.printMessage(); goto cleanup; } if ( dac.isStreamOpen() ) dac.closeStream(); // Now open a duplex stream. unsigned int bufferBytes; iParams.deviceId = iDevice; iParams.nChannels = channels; iParams.firstChannel = iOffset; if ( iDevice == 0 ) iParams.deviceId = dac.getDefaultInputDevice(); options.flags = RTAUDIO_NONINTERLEAVED; try { dac.openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options ); bufferBytes = bufferFrames * channels * 4; std::cout << "Press to start duplex operation.\n"; std::cin.get( input ); // Start the stream dac.startStream(); std::cout << "\nRunning ... press to stop.\n"; std::cin.get( input ); // Stop the stream dac.stopStream(); std::cout << "\nStopped ... press to restart.\n"; std::cin.get( input ); // Restart the stream dac.startStream(); std::cout << "\nRunning ... press to stop.\n"; std::cin.get( input ); } catch ( RtAudioError& e ) { e.printMessage(); } cleanup: if ( dac.isStreamOpen() ) dac.closeStream(); free( data ); return 0; } rtaudio-4.1.1~ds0.orig/tests/audioprobe.cpp0000644000175000017500000000620612326776523020630 0ustar alessioalessio/******************************************/ /* audioprobe.cpp by Gary P. Scavone, 2001 Probe audio system and prints device info. */ /******************************************/ #include "RtAudio.h" #include #include int main() { // Create an api map. std::map apiMap; apiMap[RtAudio::MACOSX_CORE] = "OS-X Core Audio"; apiMap[RtAudio::WINDOWS_ASIO] = "Windows ASIO"; apiMap[RtAudio::WINDOWS_DS] = "Windows Direct Sound"; apiMap[RtAudio::WINDOWS_WASAPI] = "Windows WASAPI"; apiMap[RtAudio::UNIX_JACK] = "Jack Client"; apiMap[RtAudio::LINUX_ALSA] = "Linux ALSA"; apiMap[RtAudio::LINUX_PULSE] = "Linux PulseAudio"; apiMap[RtAudio::LINUX_OSS] = "Linux OSS"; apiMap[RtAudio::RTAUDIO_DUMMY] = "RtAudio Dummy"; std::vector< RtAudio::Api > apis; RtAudio :: getCompiledApi( apis ); std::cout << "\nRtAudio Version " << RtAudio::getVersion() << std::endl; std::cout << "\nCompiled APIs:\n"; for ( unsigned int i=0; i #include #include #include /* typedef char MY_TYPE; #define FORMAT RTAUDIO_SINT8 */ typedef signed short MY_TYPE; #define FORMAT RTAUDIO_SINT16 /* typedef S24 MY_TYPE; #define FORMAT RTAUDIO_SINT24 typedef signed long MY_TYPE; #define FORMAT RTAUDIO_SINT32 typedef float MY_TYPE; #define FORMAT RTAUDIO_FLOAT32 typedef double MY_TYPE; #define FORMAT RTAUDIO_FLOAT64 */ // Platform-dependent sleep routines. #if defined( __WINDOWS_ASIO__ ) || defined( __WINDOWS_DS__ ) || defined( __WINDOWS_WASAPI__ ) #include #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) #else // Unix variants #include #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) #endif void usage( void ) { // Error function in case of incorrect command-line // argument specifications std::cout << "\nuseage: record N fs \n"; std::cout << " where N = number of channels,\n"; std::cout << " fs = the sample rate,\n"; std::cout << " duration = optional time in seconds to record (default = 2.0),\n"; std::cout << " device = optional device to use (default = 0),\n"; std::cout << " and channelOffset = an optional channel offset on the device (default = 0).\n\n"; exit( 0 ); } struct InputData { MY_TYPE* buffer; unsigned long bufferBytes; unsigned long totalFrames; unsigned long frameCounter; unsigned int channels; }; // Interleaved buffers int input( void * /*outputBuffer*/, void *inputBuffer, unsigned int nBufferFrames, double /*streamTime*/, RtAudioStreamStatus /*status*/, void *data ) { InputData *iData = (InputData *) data; // Simply copy the data to our allocated buffer. unsigned int frames = nBufferFrames; if ( iData->frameCounter + nBufferFrames > iData->totalFrames ) { frames = iData->totalFrames - iData->frameCounter; iData->bufferBytes = frames * iData->channels * sizeof( MY_TYPE ); } unsigned long offset = iData->frameCounter * iData->channels; memcpy( iData->buffer+offset, inputBuffer, iData->bufferBytes ); iData->frameCounter += frames; if ( iData->frameCounter >= iData->totalFrames ) return 2; return 0; } int main( int argc, char *argv[] ) { unsigned int channels, fs, bufferFrames, device = 0, offset = 0; double time = 2.0; FILE *fd; // minimal command-line checking if ( argc < 3 || argc > 6 ) usage(); RtAudio adc; if ( adc.getDeviceCount() < 1 ) { std::cout << "\nNo audio devices found!\n"; exit( 1 ); } channels = (unsigned int) atoi( argv[1] ); fs = (unsigned int) atoi( argv[2] ); if ( argc > 3 ) time = (double) atof( argv[3] ); if ( argc > 4 ) device = (unsigned int) atoi( argv[4] ); if ( argc > 5 ) offset = (unsigned int) atoi( argv[5] ); // Let RtAudio print messages to stderr. adc.showWarnings( true ); // Set our stream parameters for input only. bufferFrames = 512; RtAudio::StreamParameters iParams; if ( device == 0 ) iParams.deviceId = adc.getDefaultInputDevice(); else iParams.deviceId = device; iParams.nChannels = channels; iParams.firstChannel = offset; InputData data; data.buffer = 0; try { adc.openStream( NULL, &iParams, FORMAT, fs, &bufferFrames, &input, (void *)&data ); } catch ( RtAudioError& e ) { std::cout << '\n' << e.getMessage() << '\n' << std::endl; goto cleanup; } data.bufferBytes = bufferFrames * channels * sizeof( MY_TYPE ); data.totalFrames = (unsigned long) (fs * time); data.frameCounter = 0; data.channels = channels; unsigned long totalBytes; totalBytes = data.totalFrames * channels * sizeof( MY_TYPE ); // Allocate the entire data buffer before starting stream. data.buffer = (MY_TYPE*) malloc( totalBytes ); if ( data.buffer == 0 ) { std::cout << "Memory allocation error ... quitting!\n"; goto cleanup; } try { adc.startStream(); } catch ( RtAudioError& e ) { std::cout << '\n' << e.getMessage() << '\n' << std::endl; goto cleanup; } std::cout << "\nRecording for " << time << " seconds ... writing file 'record.raw' (buffer frames = " << bufferFrames << ")." << std::endl; while ( adc.isStreamRunning() ) { SLEEP( 100 ); // wake every 100 ms to check if we're done } // Now write the entire data to the file. fd = fopen( "record.raw", "wb" ); fwrite( data.buffer, sizeof( MY_TYPE ), data.totalFrames * channels, fd ); fclose( fd ); cleanup: if ( adc.isStreamOpen() ) adc.closeStream(); if ( data.buffer ) free( data.buffer ); return 0; } rtaudio-4.1.1~ds0.orig/tests/Makefile.in0000644000175000017500000000307612326776523020042 0ustar alessioalessio### Do not edit -- Generated by 'configure --with-whatever' from Makefile.in ### RtAudio tests Makefile - for various flavors of unix and MinGW PROGRAMS = audioprobe playsaw playraw record duplex testall teststops RM = /bin/rm SRC_PATH = .. INCLUDE = .. OBJECT_PATH = @object_path@ vpath %.o $(OBJECT_PATH) OBJECTS = RtAudio.o @objects@ CC = @CXX@ DEFS = @CPPFLAGS@ CFLAGS = @CXXFLAGS@ CFLAGS += -I$(INCLUDE) -I../include LIBRARY = @LIBS@ %.o : $(SRC_PATH)/%.cpp $(CC) $(CFLAGS) $(DEFS) -c $(<) -o $(OBJECT_PATH)/$@ %.o : ../include/%.cpp $(CC) $(CFLAGS) $(DEFS) -c $(<) -o $(OBJECT_PATH)/$@ all : $(PROGRAMS) audioprobe : audioprobe.cpp $(OBJECTS) $(CC) $(CFLAGS) $(DEFS) -o audioprobe audioprobe.cpp $(OBJECT_PATH)/*.o $(LIBRARY) playsaw : playsaw.cpp $(OBJECTS) $(CC) $(CFLAGS) $(DEFS) -o playsaw playsaw.cpp $(OBJECT_PATH)/*.o $(LIBRARY) playraw : playraw.cpp $(OBJECTS) $(CC) $(CFLAGS) $(DEFS) -o playraw playraw.cpp $(OBJECT_PATH)/*.o $(LIBRARY) record : record.cpp $(OBJECTS) $(CC) $(CFLAGS) $(DEFS) -o record record.cpp $(OBJECT_PATH)/*.o $(LIBRARY) duplex : duplex.cpp $(OBJECTS) $(CC) $(CFLAGS) $(DEFS) -o duplex duplex.cpp $(OBJECT_PATH)/*.o $(LIBRARY) testall : testall.cpp $(OBJECTS) $(CC) $(CFLAGS) $(DEFS) -o testall testall.cpp $(OBJECT_PATH)/*.o $(LIBRARY) teststops : teststops.cpp $(OBJECTS) $(CC) $(CFLAGS) $(DEFS) -o teststops teststops.cpp $(OBJECT_PATH)/*.o $(LIBRARY) clean : $(RM) -f $(OBJECT_PATH)/*.o $(RM) -f $(PROGRAMS) $(RM) -f *.raw *~ *.exe $(RM) -fR *.dSYM distclean: clean $(RM) -f Makefile strip : strip $(PROGRAMS) rtaudio-4.1.1~ds0.orig/tests/playraw.cpp0000644000175000017500000001001612326776523020150 0ustar alessioalessio/******************************************/ /* playraw.cpp by Gary P. Scavone, 2007 Play a specified raw file. It is necessary that the file be of the same data format as defined below. */ /******************************************/ #include "RtAudio.h" #include #include #include #include /* typedef char MY_TYPE; #define FORMAT RTAUDIO_SINT8 #define SCALE 127.0 */ typedef signed short MY_TYPE; #define FORMAT RTAUDIO_SINT16 #define SCALE 32767.0 /* typedef S24 MY_TYPE; #define FORMAT RTAUDIO_SINT24 #define SCALE 8388607.0 typedef signed int MY_TYPE; #define FORMAT RTAUDIO_SINT32 #define SCALE 2147483647.0 typedef float MY_TYPE; #define FORMAT RTAUDIO_FLOAT32 #define SCALE 1.0; typedef double MY_TYPE; #define FORMAT RTAUDIO_FLOAT64 #define SCALE 1.0; */ // Platform-dependent sleep routines. #if defined( __WINDOWS_ASIO__ ) || defined( __WINDOWS_DS__ ) || defined( __WINDOWS_WASAPI__ ) #include #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) #else // Unix variants #include #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) #endif void usage( void ) { // Error function in case of incorrect command-line // argument specifications std::cout << "\nuseage: playraw N fs file \n"; std::cout << " where N = number of channels,\n"; std::cout << " fs = the sample rate, \n"; std::cout << " file = the raw file to play,\n"; std::cout << " device = optional device to use (default = 0),\n"; std::cout << " and channelOffset = an optional channel offset on the device (default = 0).\n\n"; exit( 0 ); } struct OutputData { FILE *fd; unsigned int channels; }; // Interleaved buffers int output( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrames, double /*streamTime*/, RtAudioStreamStatus /*status*/, void *data ) { OutputData *oData = (OutputData*) data; // In general, it's not a good idea to do file input in the audio // callback function but I'm doing it here because I don't know the // length of the file we are reading. unsigned int count = fread( outputBuffer, oData->channels * sizeof( MY_TYPE ), nBufferFrames, oData->fd); if ( count < nBufferFrames ) { unsigned int bytes = (nBufferFrames - count) * oData->channels * sizeof( MY_TYPE ); unsigned int startByte = count * oData->channels * sizeof( MY_TYPE ); memset( (char *)(outputBuffer)+startByte, 0, bytes ); return 1; } return 0; } int main( int argc, char *argv[] ) { unsigned int channels, fs, bufferFrames, device = 0, offset = 0; char *file; // minimal command-line checking if ( argc < 4 || argc > 6 ) usage(); RtAudio dac; if ( dac.getDeviceCount() < 1 ) { std::cout << "\nNo audio devices found!\n"; exit( 0 ); } channels = (unsigned int) atoi( argv[1]) ; fs = (unsigned int) atoi( argv[2] ); file = argv[3]; if ( argc > 4 ) device = (unsigned int) atoi( argv[4] ); if ( argc > 5 ) offset = (unsigned int) atoi( argv[5] ); OutputData data; data.fd = fopen( file, "rb" ); if ( !data.fd ) { std::cout << "Unable to find or open file!\n"; exit( 1 ); } // Set our stream parameters for output only. bufferFrames = 512; RtAudio::StreamParameters oParams; oParams.deviceId = device; oParams.nChannels = channels; oParams.firstChannel = offset; if ( device == 0 ) oParams.deviceId = dac.getDefaultOutputDevice(); data.channels = channels; try { dac.openStream( &oParams, NULL, FORMAT, fs, &bufferFrames, &output, (void *)&data ); dac.startStream(); } catch ( RtAudioError& e ) { std::cout << '\n' << e.getMessage() << '\n' << std::endl; goto cleanup; } std::cout << "\nPlaying raw file " << file << " (buffer frames = " << bufferFrames << ")." << std::endl; while ( 1 ) { SLEEP( 100 ); // wake every 100 ms to check if we're done if ( dac.isStreamRunning() == false ) break; } cleanup: fclose( data.fd ); dac.closeStream(); return 0; } rtaudio-4.1.1~ds0.orig/tests/CMakeLists.txt0000644000175000017500000000136712326776523020536 0ustar alessioalessioinclude_directories(..) if (WIN32) include_directories(../include) endif (WIN32) add_executable(audioprobe audioprobe.cpp) target_link_libraries(audioprobe rtaudio_static ${LINKLIBS}) add_executable(playsaw playsaw.cpp) target_link_libraries(playsaw rtaudio_static ${LINKLIBS}) add_executable(playraw playraw.cpp) target_link_libraries(playraw rtaudio_static ${LINKLIBS}) add_executable(record record.cpp) target_link_libraries(record rtaudio_static ${LINKLIBS}) add_executable(duplex duplex.cpp) target_link_libraries(duplex rtaudio_static ${LINKLIBS}) add_executable(testall testall.cpp) target_link_libraries(testall rtaudio_static ${LINKLIBS}) add_executable(teststops teststops.cpp) target_link_libraries(teststops rtaudio_static ${LINKLIBS}) rtaudio-4.1.1~ds0.orig/tests/Debug/0000755000175000017500000000000012326776523017015 5ustar alessioalessiortaudio-4.1.1~ds0.orig/tests/Debug/.placeholder0000644000175000017500000000000012326776523021266 0ustar alessioalessiortaudio-4.1.1~ds0.orig/tests/duplex.cpp0000644000175000017500000000753312326776523020004 0ustar alessioalessio/******************************************/ /* duplex.cpp by Gary P. Scavone, 2006-2007. This program opens a duplex stream and passes input directly through to the output. */ /******************************************/ #include "RtAudio.h" #include #include #include /* typedef char MY_TYPE; #define FORMAT RTAUDIO_SINT8 */ typedef signed short MY_TYPE; #define FORMAT RTAUDIO_SINT16 /* typedef S24 MY_TYPE; #define FORMAT RTAUDIO_SINT24 typedef signed long MY_TYPE; #define FORMAT RTAUDIO_SINT32 typedef float MY_TYPE; #define FORMAT RTAUDIO_FLOAT32 typedef double MY_TYPE; #define FORMAT RTAUDIO_FLOAT64 */ void usage( void ) { // Error function in case of incorrect command-line // argument specifications std::cout << "\nuseage: duplex N fs \n"; std::cout << " where N = number of channels,\n"; std::cout << " fs = the sample rate,\n"; std::cout << " iDevice = optional input device to use (default = 0),\n"; std::cout << " oDevice = optional output device to use (default = 0),\n"; std::cout << " iChannelOffset = an optional input channel offset (default = 0),\n"; std::cout << " and oChannelOffset = optional output channel offset (default = 0).\n\n"; exit( 0 ); } int inout( void *outputBuffer, void *inputBuffer, unsigned int /*nBufferFrames*/, double /*streamTime*/, RtAudioStreamStatus status, void *data ) { // Since the number of input and output channels is equal, we can do // a simple buffer copy operation here. if ( status ) std::cout << "Stream over/underflow detected." << std::endl; unsigned int *bytes = (unsigned int *) data; memcpy( outputBuffer, inputBuffer, *bytes ); return 0; } int main( int argc, char *argv[] ) { unsigned int channels, fs, bufferBytes, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0; // Minimal command-line checking if (argc < 3 || argc > 7 ) usage(); RtAudio adac; if ( adac.getDeviceCount() < 1 ) { std::cout << "\nNo audio devices found!\n"; exit( 1 ); } channels = (unsigned int) atoi(argv[1]); fs = (unsigned int) atoi(argv[2]); if ( argc > 3 ) iDevice = (unsigned int) atoi(argv[3]); if ( argc > 4 ) oDevice = (unsigned int) atoi(argv[4]); if ( argc > 5 ) iOffset = (unsigned int) atoi(argv[5]); if ( argc > 6 ) oOffset = (unsigned int) atoi(argv[6]); // Let RtAudio print messages to stderr. adac.showWarnings( true ); // Set the same number of channels for both input and output. unsigned int bufferFrames = 512; RtAudio::StreamParameters iParams, oParams; iParams.deviceId = iDevice; iParams.nChannels = channels; iParams.firstChannel = iOffset; oParams.deviceId = oDevice; oParams.nChannels = channels; oParams.firstChannel = oOffset; if ( iDevice == 0 ) iParams.deviceId = adac.getDefaultInputDevice(); if ( oDevice == 0 ) oParams.deviceId = adac.getDefaultOutputDevice(); RtAudio::StreamOptions options; //options.flags |= RTAUDIO_NONINTERLEAVED; try { adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options ); } catch ( RtAudioError& e ) { std::cout << '\n' << e.getMessage() << '\n' << std::endl; exit( 1 ); } bufferBytes = bufferFrames * channels * sizeof( MY_TYPE ); // Test RtAudio functionality for reporting latency. std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl; try { adac.startStream(); char input; std::cout << "\nRunning ... press to quit (buffer frames = " << bufferFrames << ").\n"; std::cin.get(input); // Stop the stream. adac.stopStream(); } catch ( RtAudioError& e ) { std::cout << '\n' << e.getMessage() << '\n' << std::endl; goto cleanup; } cleanup: if ( adac.isStreamOpen() ) adac.closeStream(); return 0; } rtaudio-4.1.1~ds0.orig/tests/playsaw.cpp0000644000175000017500000001347512326776523020165 0ustar alessioalessio/******************************************/ /* playsaw.cpp by Gary P. Scavone, 2006 This program will output sawtooth waveforms of different frequencies on each channel. */ /******************************************/ #include "RtAudio.h" #include #include /* typedef char MY_TYPE; #define FORMAT RTAUDIO_SINT8 #define SCALE 127.0 */ typedef signed short MY_TYPE; #define FORMAT RTAUDIO_SINT16 #define SCALE 32767.0 /* typedef S24 MY_TYPE; #define FORMAT RTAUDIO_SINT24 #define SCALE 8388607.0 typedef signed long MY_TYPE; #define FORMAT RTAUDIO_SINT32 #define SCALE 2147483647.0 typedef float MY_TYPE; #define FORMAT RTAUDIO_FLOAT32 #define SCALE 1.0 typedef double MY_TYPE; #define FORMAT RTAUDIO_FLOAT64 #define SCALE 1.0 */ // Platform-dependent sleep routines. #if defined( __WINDOWS_ASIO__ ) || defined( __WINDOWS_DS__ ) || defined( __WINDOWS_WASAPI__ ) #include #define SLEEP( milliseconds ) Sleep( (DWORD) milliseconds ) #else // Unix variants #include #define SLEEP( milliseconds ) usleep( (unsigned long) (milliseconds * 1000.0) ) #endif #define BASE_RATE 0.005 #define TIME 1.0 void usage( void ) { // Error function in case of incorrect command-line // argument specifications std::cout << "\nuseage: playsaw N fs