Version 4.3.0

This commit is contained in:
Gary Scavone
2009-03-24 23:02:15 -04:00
committed by Stephen Sinclair
parent 2cbce2d8bd
commit 27d9b79dc7
271 changed files with 22219 additions and 8834 deletions

View File

@@ -20,12 +20,13 @@ struct TickData {
// This tick() function handles sample computation only. It will be
// called automatically when the system needs a new buffer of audio
// samples.
int tick(char *buffer, int bufferSize, void *dataPointer)
int tick( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
double streamTime, RtAudioStreamStatus status, void *userData )
{
TickData *data = (TickData *) dataPointer;
register StkFloat *samples = (StkFloat *) buffer;
TickData *data = (TickData *) userData;
register StkFloat *samples = (StkFloat *) outputBuffer;
for ( int i=0; i<bufferSize; i++ ) {
for ( unsigned int i=0; i<nBufferFrames; i++ ) {
*samples++ = data->instrument->tick();
if ( ++data->counter % 2000 == 0 ) {
data->scaler += 0.025;
@@ -46,15 +47,18 @@ int main()
Stk::setRawwavePath( "../../rawwaves/" );
TickData data;
RtAudio *dac = 0;
RtAudio dac;
// Figure out how many bytes in an StkFloat and setup the RtAudio object.
// Figure out how many bytes in an StkFloat and setup the RtAudio stream.
RtAudio::StreamParameters parameters;
parameters.deviceId = dac.getDefaultOutputDevice();
parameters.nChannels = 1;
RtAudioFormat format = ( sizeof(StkFloat) == 8 ) ? RTAUDIO_FLOAT64 : RTAUDIO_FLOAT32;
int bufferSize = RT_BUFFER_SIZE;
unsigned int bufferFrames = RT_BUFFER_SIZE;
try {
dac = new RtAudio(0, 1, 0, 0, format, (int)Stk::sampleRate(), &bufferSize, 4);
dac.openStream( &parameters, NULL, format, (unsigned int)Stk::sampleRate(), &bufferFrames, &tick, (void *)&data );
}
catch (RtError& error) {
catch ( RtError& error ) {
error.printMessage();
goto cleanup;
}
@@ -63,7 +67,7 @@ int main()
// Define and load the BeeThree instrument
data.instrument = new BeeThree();
}
catch (StkError &) {
catch ( StkError & ) {
goto cleanup;
}
@@ -71,10 +75,9 @@ int main()
data.instrument->noteOn( data.frequency, 0.5 );
try {
dac->setStreamCallback(&tick, (void *)&data);
dac->startStream();
dac.startStream();
}
catch (RtError &error) {
catch ( RtError &error ) {
error.printMessage();
goto cleanup;
}
@@ -85,16 +88,14 @@ int main()
// Shut down the callback and output stream.
try {
dac->cancelStreamCallback();
dac->closeStream();
dac.closeStream();
}
catch (RtError &error) {
catch ( RtError &error ) {
error.printMessage();
}
cleanup:
delete data.instrument;
delete dac;
return 0;
}