[music-dsp] Sliding frequency notes

robert bristow-johnson rbj at audioimagination.com
Thu Sep 16 13:23:46 EDT 2010


more of a brain fart on my part, not a typo:

On Sep 16, 2010, at 1:02 PM, robert bristow-johnson wrote:

>
> On Sep 16, 2010, at 12:29 PM, Alan Wolfe wrote:
>
>> typo... here's the correct sine generator :P
>>
>> CurrentSampleValue = sin((Frequency / SampleRate) * 2PI *  
>> CurrentSample) * Volume
>
> one thing to keep in mind is that whether the frequency is varying  
> or not, it's the time derivative of the stuff inside the sin()  
> function that is the instantaneous frequency, not what multiplies  
> the time index.

i should not imply that "what multiplies the time index" cannot be the  
instantaneous frequency whether it varies or not.  of course if the  
frequency is constant, both the time derivative of w0*t and what  
multiplies t are the same number.  but, in general, you integrate w0  
to get phase, don't just multiply it by t.

>
>    Phase = Phase + TWOPI*Frequency/SampleRate;
>
>    if (Phase >= PI)  Phase = Phase - TWOPI;
>    if (Phase < -PI)  Phase = Phase + TWOPI;  // perhaps not necessary
>
>    CurrentSampleValue = Volume * sin(Phase);
>

--

r b-j                  rbj at audioimagination.com

"Imagination is more important than knowledge."






More information about the music-dsp mailing list