[Stk] Polyphonic bug in STK's demo.cpp
Casey Muller
caseymrm@mrl.nyu.edu
Sat, 22 Oct 2005 15:59:04 -0400 (EDT)
Hi,
I recently grabbed STK to make a simple sound server that I could address
over the network. I was pleased to find out I could just use the demo app
with -or -is.
However, I couldn't seem to get polyphony to work from a socket, which I
eventually traced back to demo.cpp's processMessage( TickData* data ).
I don't know if it's worth submitting a patch, but other people may be
wanting the same thing as me, and of course example code often gets
copied into apps.
Anyway, the problem is just that the 'channel' gets parsed into the
TickData structure properly, but then never gets passed into the noteOn,
noteOff, setFreq, controlChange functions in processMessage. So
everything ends up in the default channel, and when (for instance) you
use two channels and then setFrequency each in turn, the pitch goes
back and forth like an old videogame instead of being polyphonic.
The simple fix is just to pass data.channel into those functions to
override the default of 0.
I've included a diff below, but it's pretty straightforward.
Anyway, just thought I'd mention it. Thanks for the library, it saved me a
lot of time. Philip Davidson is my officemate here, so I know I'm
underusing its capabilities ;-)
Casey
diff of demo.cpp:
78c78
< data->voicer->noteOff( value1, 64.0 );
---
> data->voicer->noteOff( value1, 64.0, data->message.channel );
80c80
< data->voicer->noteOn( value1, value2 );
---
> data->voicer->noteOn( value1, value2, data->message.channel );
84c84
< data->voicer->noteOff( value1, value2 );
---
> data->voicer->noteOff( value1, value2, data->message.channel );
93c93
< data->voicer->setFrequency( value2 );
---
> data->voicer->setFrequency( value2, data->message.channel );
95c95
< data->voicer->controlChange( (int) value1, value2 );
---
> data->voicer->controlChange( (int) value1, value2,
data->message.channel );
99c99
< data->voicer->controlChange( 128, value1 );
---
> data->voicer->controlChange( 128, value1, data->message.channel );
103c103
< data->voicer->setFrequency( value1 );
---
> data->voicer->setFrequency( value1, data->message.channel );
107c107
< data->voicer->pitchBend( value1 );
---
> data->voicer->pitchBend( value1, data->message.channel );
127c127
< data->voicer->addInstrument( data->instrument[i] );
---
> data->voicer->addInstrument( data->instrument[i],
data->message.channel );
222c222
< data.voicer->addInstrument( data.instrument[i] );
---
> data.voicer->addInstrument( data.instrument[i], i );