mirror of
https://github.com/thestk/stk
synced 2026-01-19 07:31:52 +00:00
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:
@@ -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( ¶meters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
|
||||
}
|
||||
catch ( RtAudioError& error ) {
|
||||
error.printMessage();
|
||||
if ( dac->openStream( ¶meters, 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 );
|
||||
|
||||
Reference in New Issue
Block a user