Updates to eguitar, ragamatic and examples project files for new RtAudio API.

This commit is contained in:
garyscavone
2023-08-04 10:37:22 -04:00
parent 7f97ab5f71
commit fd5e37863d
11 changed files with 206 additions and 236 deletions

View File

@@ -203,7 +203,6 @@ int main( int argc, char *argv[] )
int i;
#if defined(__STK_REALTIME__)
//RtAudio dac( RtAudio::UNSPECIFIED );
RtAudio *dac = 0;
#endif

View File

@@ -265,7 +265,7 @@ int main( int argc, char *argv[] )
int i;
#if defined(__STK_REALTIME__)
RtAudio dac;
RtAudio *dac = 0;
#endif
// If you want to change the default sample rate (set in Stk.h), do
@@ -294,16 +294,14 @@ int main( int argc, char *argv[] )
// If realtime output, allocate the dac here.
#if defined(__STK_REALTIME__)
if ( data.realtime ) {
dac = (RtAudio *) new RtAudio( RtAudio::UNSPECIFIED );
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
RtAudio::StreamParameters parameters;
parameters.deviceId = dac.getDefaultOutputDevice();
parameters.deviceId = dac->getDefaultOutputDevice();
parameters.nChannels = data.channels;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
catch ( RtAudioError& error ) {
error.printMessage();
if ( dac->openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data ) ) {
std::cout << dac->getErrorText() << std::endl;
goto cleanup;
}
}
@@ -335,11 +333,8 @@ int main( int argc, char *argv[] )
// If realtime output, set our callback function and start the dac.
#if defined(__STK_REALTIME__)
if ( data.realtime ) {
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac->startStream() ) {
std::cout << dac->getErrorText() << std::endl;
goto cleanup;
}
}
@@ -359,14 +354,8 @@ int main( int argc, char *argv[] )
// Shut down the output stream.
#if defined(__STK_REALTIME__)
if ( data.realtime ) {
try {
dac.closeStream();
}
catch ( RtAudioError& error ) {
error.printMessage();
}
}
if ( data.realtime )
dac->closeStream();
#endif
cleanup:
@@ -374,6 +363,7 @@ int main( int argc, char *argv[] )
for ( i=0; i<(int)data.nWvOuts; i++ ) delete data.wvout[i];
free( data.wvout );
delete data.guitar;
delete dac;
std::cout << "\nStk eguitar finished ... goodbye.\n\n";
return 0;

View File

@@ -11,76 +11,107 @@
#include <iostream>
#include <map>
int main()
{
// Create an api map.
std::map<int, std::string> apiMap;
apiMap[RtAudio::MACOSX_CORE] = "OS-X CoreAudio";
apiMap[RtAudio::WINDOWS_ASIO] = "Windows ASIO";
apiMap[RtAudio::WINDOWS_DS] = "Windows DirectSound";
apiMap[RtAudio::UNIX_JACK] = "Jack Client";
apiMap[RtAudio::LINUX_ALSA] = "Linux ALSA";
apiMap[RtAudio::LINUX_OSS] = "Linux OSS";
apiMap[RtAudio::RTAUDIO_DUMMY] = "RtAudio Dummy";
void usage( void ) {
// Error function in case of incorrect command-line
// argument specifications
std::cout << "\nuseage: audioprobe <apiname> <nRepeats>\n";
std::cout << " where apiname = an optional api (ex., 'core', default = all compiled),\n";
std::cout << " and nRepeats = an optional number of times to repeat the device query (default = 0),\n";
std::cout << " which can be used to test device (dis)connections.\n\n";
exit( 0 );
}
std::vector< RtAudio::Api > listApis()
{
std::vector< RtAudio::Api > apis;
RtAudio :: getCompiledApi( apis );
std::cout << "\nCompiled APIs:\n";
for ( unsigned int i=0; i<apis.size(); i++ )
std::cout << " " << apiMap[ apis[i] ] << std::endl;
for ( size_t i=0; i<apis.size(); i++ )
std::cout << i << ". " << RtAudio::getApiDisplayName(apis[i])
<< " (" << RtAudio::getApiName(apis[i]) << ")" << std::endl;
RtAudio audio;
return apis;
}
void listDevices( RtAudio& audio )
{
RtAudio::DeviceInfo info;
std::cout << "\nCurrent API: " << apiMap[ audio.getCurrentApi() ] << std::endl;
std::cout << "\nAPI: " << RtAudio::getApiDisplayName(audio.getCurrentApi()) << std::endl;
unsigned int devices = audio.getDeviceCount();
std::cout << "\nFound " << devices << " device(s) ...\n";
std::vector<unsigned int> devices = audio.getDeviceIds();
std::cout << "\nFound " << devices.size() << " device(s) ...\n";
for (unsigned int i=0; i<devices; i++) {
info = audio.getDeviceInfo(i);
for (unsigned int i=0; i<devices.size(); i++) {
info = audio.getDeviceInfo( devices[i] );
std::cout << "\nDevice Name = " << info.name << '\n';
if ( info.probed == false )
std::cout << "Probe Status = UNsuccessful\n";
std::cout << "Device Index = " << i << '\n';
std::cout << "Output Channels = " << info.outputChannels << '\n';
std::cout << "Input Channels = " << info.inputChannels << '\n';
std::cout << "Duplex Channels = " << info.duplexChannels << '\n';
if ( info.isDefaultOutput ) std::cout << "This is the default output device.\n";
else std::cout << "This is NOT the default output device.\n";
if ( info.isDefaultInput ) std::cout << "This is the default input device.\n";
else std::cout << "This is NOT the default input device.\n";
if ( info.nativeFormats == 0 )
std::cout << "No natively supported data formats(?)!";
else {
std::cout << "Probe Status = Successful\n";
std::cout << "Output Channels = " << info.outputChannels << '\n';
std::cout << "Input Channels = " << info.inputChannels << '\n';
std::cout << "Duplex Channels = " << info.duplexChannels << '\n';
if ( info.isDefaultOutput ) std::cout << "This is the default output device.\n";
else std::cout << "This is NOT the default output device.\n";
if ( info.isDefaultInput ) std::cout << "This is the default input device.\n";
else std::cout << "This is NOT the default input device.\n";
if ( info.nativeFormats == 0 )
std::cout << "No natively supported data formats(?)!";
else {
std::cout << "Natively supported data formats:\n";
if ( info.nativeFormats & RTAUDIO_SINT8 )
std::cout << " 8-bit int\n";
if ( info.nativeFormats & RTAUDIO_SINT16 )
std::cout << " 16-bit int\n";
if ( info.nativeFormats & RTAUDIO_SINT24 )
std::cout << " 24-bit int\n";
if ( info.nativeFormats & RTAUDIO_SINT32 )
std::cout << " 32-bit int\n";
if ( info.nativeFormats & RTAUDIO_FLOAT32 )
std::cout << " 32-bit float\n";
if ( info.nativeFormats & RTAUDIO_FLOAT64 )
std::cout << " 64-bit float\n";
std::cout << "Natively supported data formats:\n";
if ( info.nativeFormats & RTAUDIO_SINT8 )
std::cout << " 8-bit int\n";
if ( info.nativeFormats & RTAUDIO_SINT16 )
std::cout << " 16-bit int\n";
if ( info.nativeFormats & RTAUDIO_SINT24 )
std::cout << " 24-bit int\n";
if ( info.nativeFormats & RTAUDIO_SINT32 )
std::cout << " 32-bit int\n";
if ( info.nativeFormats & RTAUDIO_FLOAT32 )
std::cout << " 32-bit float\n";
if ( info.nativeFormats & RTAUDIO_FLOAT64 )
std::cout << " 64-bit float\n";
}
if ( info.sampleRates.size() < 1 )
std::cout << "No supported sample rates found!";
else {
std::cout << "Supported sample rates = ";
for (unsigned int j=0; j<info.sampleRates.size(); j++)
std::cout << info.sampleRates[j] << " ";
}
std::cout << std::endl;
if ( info.preferredSampleRate == 0 )
std::cout << "No preferred sample rate found!" << std::endl;
else
std::cout << "Preferred sample rate = " << info.preferredSampleRate << std::endl;
}
}
int main(int argc, char *argv[])
{
std::cout << "\nRtAudio Version " << RtAudio::getVersion() << std::endl;
std::vector< RtAudio::Api > apis = listApis();
// minimal command-line checking
if (argc > 3 ) usage();
unsigned int nRepeats = 0;
if ( argc > 2 ) nRepeats = (unsigned int) atoi( argv[2] );
char input;
for ( size_t api=0; api < apis.size(); api++ ) {
if (argc < 2 || apis[api] == RtAudio::getCompiledApiByName(argv[1]) ) {
RtAudio audio(apis[api]);
for ( size_t n=0; n <= nRepeats; n++ ) {
listDevices(audio);
if ( n < nRepeats ) {
std::cout << std::endl;
std::cout << "\nWaiting ... press <enter> to repeat.\n";
std::cin.get(input);
}
}
if ( info.sampleRates.size() < 1 )
std::cout << "No supported sample rates found!";
else {
std::cout << "Supported sample rates = ";
for (unsigned int j=0; j<info.sampleRates.size(); j++)
std::cout << info.sampleRates[j] << " ";
}
std::cout << std::endl;
}
}
std::cout << std::endl;
return 0;
}

View File

@@ -56,11 +56,8 @@ int main()
parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
catch ( RtAudioError& error ) {
error.printMessage();
if ( dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data ) ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -75,11 +72,8 @@ int main()
data.frequency = 220.0;
data.instrument->noteOn( data.frequency, 0.5 );
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.startStream() ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -88,12 +82,7 @@ int main()
Stk::sleep( 100 );
// Shut down the callback and output stream.
try {
dac.closeStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
}
dac.closeStream();
cleanup:
delete data.instrument;

View File

@@ -130,11 +130,8 @@ int main( int argc, char *argv[] )
parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data ) ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -149,11 +146,8 @@ int main( int argc, char *argv[] )
if ( data.messager.setScoreFile( argv[1] ) == false )
goto cleanup;
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.startStream() ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -162,12 +156,7 @@ int main( int argc, char *argv[] )
Stk::sleep( 100 );
// Shut down the output stream.
try {
dac.closeStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
}
dac.closeStream();
cleanup:
delete data.instrument;

View File

@@ -33,21 +33,15 @@ int main()
parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&sine );
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&sine ) ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
sine.setFrequency(440.0);
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.startStream() ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -57,12 +51,7 @@ int main()
std::cin.get( keyhit );
// Shut down the output stream.
try {
dac.closeStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
}
dac.closeStream();
cleanup:

View File

@@ -1,7 +1,7 @@
/******************************************/
/*
duplex.cpp
by Gary P. Scavone, 2006-2007.
by Gary P. Scavone, 2006-2019.
This program opens a duplex stream and passes
input directly through to the output.
@@ -14,24 +14,26 @@
#include <cstring>
/*
typedef signed long MY_TYPE;
#define FORMAT RTAUDIO_SINT24
typedef char MY_TYPE;
typedef char MY_TYPE;
#define FORMAT RTAUDIO_SINT8
typedef signed short MY_TYPE;
#define FORMAT RTAUDIO_SINT16
typedef signed long MY_TYPE;
#define FORMAT RTAUDIO_SINT32
typedef float MY_TYPE;
#define FORMAT RTAUDIO_FLOAT32
*/
typedef double MY_TYPE;
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
@@ -39,26 +41,52 @@ void usage( void ) {
std::cout << "\nuseage: duplex N fs <iDevice> <oDevice> <iChannelOffset> <oChannelOffset>\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 << " iDevice = optional input device index to use (default = 0),\n";
std::cout << " oDevice = optional output device index 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,
unsigned int getDeviceIndex( std::vector<std::string> deviceNames, bool isInput = false )
{
unsigned int i;
std::string keyHit;
std::cout << '\n';
for ( i=0; i<deviceNames.size(); i++ )
std::cout << " Device #" << i << ": " << deviceNames[i] << '\n';
do {
if ( isInput )
std::cout << "\nChoose an input device #: ";
else
std::cout << "\nChoose an output device #: ";
std::cin >> i;
} while ( i >= deviceNames.size() );
std::getline( std::cin, keyHit ); // used to clear out stdin
return i;
}
double streamTimePrintIncrement = 1.0; // seconds
double streamTimePrintTime = 1.0; // seconds
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 long *bytes = (unsigned long *) data;
if ( streamTime >= streamTimePrintTime ) {
std::cout << "streamTime = " << streamTime << std::endl;
streamTimePrintTime += streamTimePrintIncrement;
}
unsigned int *bytes = (unsigned int *) data;
memcpy( outputBuffer, inputBuffer, *bytes );
return 0;
}
int main(int argc, char *argv[])
int main( int argc, char *argv[] )
{
unsigned int channels, fs, bufferBytes, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0;
@@ -66,9 +94,10 @@ int main(int argc, char *argv[])
if (argc < 3 || argc > 7 ) usage();
RtAudio adac;
if ( adac.getDeviceCount() < 1 ) {
std::vector<unsigned int> deviceIds = adac.getDeviceIds();
if ( deviceIds.size() < 1 ) {
std::cout << "\nNo audio devices found!\n";
exit( 0 );
exit( 1 );
}
channels = (unsigned int) atoi(argv[1]);
@@ -88,48 +117,48 @@ int main(int argc, char *argv[])
// Set the same number of channels for both input and output.
unsigned int bufferFrames = 512;
RtAudio::StreamParameters iParams, oParams;
if ( iDevice == 0 )
iParams.deviceId = adac.getDefaultInputDevice();
else
iParams.deviceId = iDevice - 1;
iParams.nChannels = channels;
iParams.firstChannel = iOffset;
if ( oDevice == 0 )
oParams.deviceId = adac.getDefaultOutputDevice();
else
oParams.deviceId = oDevice - 1;
oParams.nChannels = channels;
oParams.firstChannel = oOffset;
if ( iDevice == 0 )
iParams.deviceId = adac.getDefaultInputDevice();
else {
if ( iDevice >= deviceIds.size() )
iDevice = getDeviceIndex( adac.getDeviceNames(), true );
iParams.deviceId = deviceIds[iDevice];
}
if ( oDevice == 0 )
oParams.deviceId = adac.getDefaultOutputDevice();
else {
if ( oDevice >= deviceIds.size() )
oDevice = getDeviceIndex( adac.getDeviceNames() );
oParams.deviceId = deviceIds[oDevice];
}
RtAudio::StreamOptions options;
//options.flags |= RTAUDIO_NONINTERLEAVED;
bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
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 );
if ( adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options ) ) {
goto cleanup;
}
if ( adac.isStreamOpen() == false ) goto cleanup;
// Test RtAudio functionality for reporting latency.
std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;
try {
adac.startStream();
if ( adac.startStream() ) goto cleanup;
char input;
std::cout << "\nRunning ... press <enter> to quit (buffer frames = " << bufferFrames << ").\n";
std::cin.get(input);
char input;
std::cout << "\nRunning ... press <enter> to quit (buffer frames = " << bufferFrames << ").\n";
std::cin.get(input);
// Stop the stream.
// Stop the stream.
if ( adac.isStreamRunning() )
adac.stopStream();
}
catch ( RtAudioError& e ) {
std::cout << '\n' << e.getMessage() << '\n' << std::endl;
goto cleanup;
}
cleanup:
if ( adac.isStreamOpen() ) adac.closeStream();

View File

@@ -79,35 +79,23 @@ int main( int argc, char *argv[] )
parameters.nChannels = grani.channelsOut();
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&grani );
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&grani ) ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.startStream() ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
// Block waiting here.
char keyhit;
std::cout << "\nPlaying ... press <enter> to quit.\n";
std::cin.get( keyhit );
// Shut down the callback and output stream.
try {
dac.closeStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
}
dac.closeStream();
cleanup:

View File

@@ -99,11 +99,8 @@ int main(int argc, char *argv[])
parameters.nChannels = ( channels == 1 ) ? 2 : channels; // Play mono files as stereo.
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&input );
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&input ) ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -113,11 +110,8 @@ int main(int argc, char *argv[])
// Resize the StkFrames object appropriately.
frames.resize( bufferFrames, channels );
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.startStream() ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -127,12 +121,7 @@ int main(int argc, char *argv[])
// By returning a non-zero value in the callback above, the stream
// is automatically stopped. But we should still close it.
try {
dac.closeStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
}
dac.closeStream();
cleanup:
return 0;

View File

@@ -130,11 +130,8 @@ int main()
parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data ) ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -154,11 +151,8 @@ int main()
if ( data.messager.startStdInput() == false )
goto cleanup;
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.startStream() ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -167,12 +161,7 @@ int main()
Stk::sleep( 100 );
// Shut down the callback and output stream.
try {
dac.closeStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
}
dac.closeStream();
cleanup:
for ( i=0; i<3; i++ ) delete instrument[i];

View File

@@ -291,11 +291,8 @@ int main( int argc, char *argv[] )
parameters.deviceId = dac.getDefaultOutputDevice();
parameters.nChannels = 2;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
catch ( RtAudioError& error ) {
error.printMessage();
if ( dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data ) ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -314,11 +311,8 @@ int main( int argc, char *argv[] )
(void) signal( SIGINT, finish );
// If realtime output, set our callback function and start the dac.
try {
dac.startStream();
}
catch ( RtAudioError &error ) {
error.printMessage();
if ( dac.startStream() ) {
std::cout << dac.getErrorText() << std::endl;
goto cleanup;
}
@@ -329,15 +323,9 @@ int main( int argc, char *argv[] )
}
// Shut down the output stream.
try {
dac.closeStream();
}
catch ( RtAudioError& error ) {
error.printMessage();
}
dac.closeStream();
cleanup:
return 0;
}