[Stk] Questions about SineWave class

Perry Cook prc at cs.princeton.edu
Mon Sep 12 08:40:11 PDT 2016


I’m not looking at the code, but I’m pretty sure that phase refers to
the instantaneous phase, which is added to by the appropriate frequency-
related delta on each tick.  So setting it to zero will likely kill it (like
a reset).  Setting the offset might work, but I personally would just
use two SineOscs and only have to set their phase offset once (unless
you’re modifying their frequencies).

PRC


> On Sep 12, 2016, at 7:19 AM, Gary Worsham <gary.worsham at gmail.com> wrote:
> 
> 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. 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.
> 
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/stk




More information about the Stk mailing list