mirror of
https://github.com/thestk/stk
synced 2026-01-11 12:01: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:
@@ -40,10 +40,10 @@ void midiCallback( double deltatime, std::vector< unsigned char > *bytes, void *
|
||||
// Parse the MIDI bytes ... only keep MIDI channel messages.
|
||||
if ( bytes->at(0) > 239 ) return;
|
||||
|
||||
register long type = bytes->at(0) & 0xF0;
|
||||
register int channel = bytes->at(0) & 0x0F;
|
||||
register long databyte1 = bytes->at(1);
|
||||
register long databyte2 = 0;
|
||||
long type = bytes->at(0) & 0xF0;
|
||||
int channel = bytes->at(0) & 0x0F;
|
||||
long databyte1 = bytes->at(1);
|
||||
long databyte2 = 0;
|
||||
if ( ( type != 0xC0 ) && ( type != 0xD0 ) ) {
|
||||
if ( bytes->size() < 3 ) return;
|
||||
databyte2 = bytes->at(2);
|
||||
|
||||
@@ -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