[Stk] Drum noteOn?

Beinan Li li.beinan at gmail.com
Sun Apr 12 00:06:18 PDT 2009


This is an old problem I encountered.
The original drum sample mapping in STK is kinda confusing at first glance;
Just try to look at the drummer.cpp drum mapping code more closely,

Three relevant traces to keep in mind:
1. The arrays $genMIDIMap and $waveNames,
    genMIDIMap[i] refers to an index in waveNames,
    you can change the mapping to your own scheme.
2. Line 88, your input noteOn instrument index is mapped to $noteNumber in a
non-linear way
3. Line 126, finally $noteNumber is used as genMIDIMap index to address
waveNames, tadah...

Best,
Beinan



On Sat, Apr 11, 2009 at 6:46 PM, Ryan Compton <rcompton at math.ucla.edu>wrote:

> Hi,
>
> I started using STK the other day and can't seem to figure out how to
> use the noteOn for a Drummer.
>
> The following code plays a guitar just fine:
>
> Plucked *guitar = new Plucked(220.0); //build a guitar
> StkFrames *sound(22050,1); //setup a half second of noise
> guitar->noteOn(220.0 , .7); //play a note
> guitar->noteOff(.01); //unplay a note
> guitar->tick(*sound); //tick the frame into *sound
> output.tick( *sound); //tick the *sound into output
>
> This code makes a "d'oh!":
>
> Drummer *whack = new Drummer(); //build a drum
> StkFrames *sound(22050,1); //setup a half second of noise
> whack->noteOn(42 , .7); //play a note
> whack->noteOff(.01); //unplay a note
> whack->tick(*sound); //tick the frame into *sound
> output.tick( *sound); //tick the *sound into output
>
> I know I'm supposed to use MIDI numbers to specify which drum, but
> whatever MIDI number I use will just produce a "d'oh!".
>
> Thanks and d'oh,
> Ryan
>
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://ccrma-mail.stanford.edu/pipermail/stk/attachments/20090412/7dab9772/attachment.html 


More information about the Stk mailing list