Added new versions of RtAudio and RtMidi, updated RtWvIn and RtWvOut for new API, updated demo project for new API.

This commit is contained in:
garyscavone
2023-08-04 09:44:26 -04:00
parent 2af2f1c816
commit 8b29e0ea6d
15 changed files with 4225 additions and 2579 deletions

View File

@@ -203,7 +203,8 @@ int main( int argc, char *argv[] )
int i;
#if defined(__STK_REALTIME__)
RtAudio dac;
//RtAudio dac( RtAudio::UNSPECIFIED );
RtAudio *dac = 0;
#endif
// If you want to change the default sample rate (set in Stk.h), do
@@ -254,16 +255,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;
}
}
@@ -279,11 +278,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;
}
}
@@ -303,14 +299,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:
@@ -319,6 +309,7 @@ int main( int argc, char *argv[] )
free( data.wvout );
delete data.voicer;
delete dac;
for ( i=0; i<data.nVoices; i++ ) delete data.instrument[i];
free( data.instrument );