/******************************************/
/*
testall.cpp
- by Gary P. Scavone, 2007
+ by Gary P. Scavone, 2007-2008
This program will make a variety of calls
to extensively test RtAudio functionality.
#include "RtAudio.h"
#include <iostream>
+#include <cstdlib>
+#include <cstring>
#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 <device> <channelOffset>\n";
+ std::cout << "\nuseage: testall N fs <iDevice> <oDevice> <iChannelOffset> <oChannelOffset>\n";
std::cout << " where N = number of channels,\n";
std::cout << " fs = the sample rate,\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";
+ 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 );
}
// a simple buffer copy operation here.
if ( status ) std::cout << "Stream over/underflow detected." << std::endl;
- unsigned long *bytes = (unsigned long *) data;
+ unsigned int *bytes = (unsigned int *) data;
memcpy( outputBuffer, inputBuffer, *bytes );
return 0;
}
int main( int argc, char *argv[] )
{
- unsigned int bufferFrames, fs, device = 0, offset = 0;
+ unsigned int bufferFrames, fs, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0;
char input;
// minimal command-line checking
- if (argc < 3 || argc > 5 ) usage();
+ if (argc < 3 || argc > 7 ) usage();
RtAudio dac;
if ( dac.getDeviceCount() < 1 ) {
channels = (unsigned int) atoi( argv[1] );
fs = (unsigned int) atoi( argv[2] );
if ( argc > 3 )
- device = (unsigned int) atoi( argv[3] );
+ iDevice = (unsigned int) atoi( argv[3] );
if ( argc > 4 )
- offset = (unsigned int) atoi( argv[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 ) );
dac.showWarnings( true );
// Set our stream parameters for output only.
- bufferFrames = 256;
+ bufferFrames = 512;
RtAudio::StreamParameters oParams, iParams;
- oParams.deviceId = device;
+ oParams.deviceId = oDevice;
oParams.nChannels = channels;
- oParams.firstChannel = offset;
+ oParams.firstChannel = oOffset;
RtAudio::StreamOptions options;
options.flags = RTAUDIO_HOG_DEVICE;
std::cout << "Playing again ... press <enter> to close the stream.\n";
std::cin.get( input );
}
- catch ( RtError& e ) {
+ catch ( RtAudioError& e ) {
e.printMessage();
goto cleanup;
}
std::cout << "\nPlaying ... press <enter> to stop.\n";
std::cin.get( input );
}
- catch ( RtError& e ) {
+ catch ( RtAudioError& e ) {
e.printMessage();
goto cleanup;
}
// Now open a duplex stream.
unsigned int bufferBytes;
- iParams.deviceId = device;
+ iParams.deviceId = iDevice;
iParams.nChannels = channels;
- iParams.firstChannel = offset;
+ iParams.firstChannel = iOffset;
options.flags = RTAUDIO_NONINTERLEAVED;
try {
dac.openStream( &oParams, &iParams, RTAUDIO_SINT32, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
std::cout << "\nRunning ... press <enter> to stop.\n";
std::cin.get( input );
}
- catch ( RtError& e ) {
+ catch ( RtAudioError& e ) {
e.printMessage();
}