[Stk] Sequencing with the STK

Stephen Sinclair sinclair at music.mcgill.ca
Sun Sep 19 16:47:34 PDT 2010


On Sun, Sep 19, 2010 at 2:02 PM, Morgan Packard
<morgan at morganpackard.com> wrote:
> Thanks Steve,
> I'll admit, much of this is over my head. But my head is rising, bit by bit.
> My interest in STK is mainly for iPhone development. So speed is definitely
> important! I'm looking for a set of low-level components that are designed
> to be easily pluggable, and as efficient as possible. I realize that's not

What I'm not clear on yet is whether you want them "pluggable"
components to be connected at compile time or at run time?

If the latter, there's no logical way to get this inlining
optimization anyways, so I wouldn't worry about it.
Carlos's example in his post of having a set of classes with tick()
virtual functions is a good explanation of how to go about this.
(However, his AudioNode class actually sounds a lot like the
definition of stk::Instrmnt anyways, but perhaps generalized for his
particular requirements.)

To make things clear, here's how to feed a sinusoid into a reverb:

at initialization:
SineWave *sw = new SineWav();
JCRev *rev = new JCRev();

in the audio callback, assuming pSample points to the first item in a
one-channel sample buffer of length n:

for (i=0; i<n; i++) {
   *pSample++ = rev->tick( sw->tick() );
}

On the other hand, if you wanted this graph to change at run-time,
then, say that  'rev' and 'sw' would be pointers to some class with a
tick() virtual function, as Carlos explained, and a next() function to
iterate the list, and then you'd do:

for (i=0; i<n; i++) {
  StkFloat f = 0;
  obj = firstObject;
  while (obj) {
      f = obj->tick(f);
      obj = obj->next();
  }
  *pSample++ = f
}

Steve



More information about the Stk mailing list