[Stk] Questions about SineWave class

Gary Worsham gary.worsham at gmail.com
Mon Sep 12 07:19:44 PDT 2016


Finally, an actual Stk question!

Looks like I set the frequency with setFrequency, and the rate at which the
read back value changes with setRate?  I'm using the LFO to slowly change
the center frequency of a BiQuad filter, and doing so at sample rate within
the tick() method.

By the way, it sounds great!

Nothing particularly wrong with this.

Now I'd like to get simultaneous sin and cos off this filter.  I see there
are addPhase and addPhaseOffset methods, which are described very subtly
different, but I cannot actually tell what the difference between them is.

Seems like to get cos immediately after sin I'd need to add Phase or the
Phase offset, do another tick, and read the lastOut.  Then I'd need to set
the phase offset back to zero for the nest time around reading the sin
value.

Is this anywhere close to being correct?

GSW






void stk::SineWave::setRate ( StkFloat  rate ) inline

Set the data read rate in samples. The rate can be negative.

If the rate value is negative, the data is read in reverse order.
41 { rate_ = rate; };
void stk::SineWave::setFrequency ( StkFloat  frequency )

Set the data interpolation rate based on a looping frequency.

This function determines the interpolation rate based on the file size and
the current Stk::sampleRate
<https://ccrma.stanford.edu/software/stk/classstk_1_1Stk.html#a5fbe37000a611ce56075ee7d8936472d>.
The *frequency* value corresponds to file cycles per second. The frequency
can be negative, in which case the loop is read in reverse order.
void stk::SineWave::addPhase ( StkFloat  phase )

Increment the read pointer by a normalized *phase* value.

This function increments the read pointer by a normalized phase value, such
that *phase* = 1.0 corresponds to a 360 degree phase shift. Positive or
negative values are possible.
void stk::SineWave::addPhaseOffset ( StkFloat  phaseOffset )

Add a normalized phase offset to the read pointer.

A *phaseOffset* = 1.0 corresponds to a 360 degree phase offset. Positive or
negative values are possible.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/stk/attachments/20160912/e989ec6f/attachment.html>


More information about the Stk mailing list