[music-dsp] oscillators

Chris Parsons chris at courtsmart.com
Wed Oct 17 11:34:59 EDT 2001


I guess it all depends on what you want to use the oscillator for, and if
changing the frequency over time is required.  I was also under the
impression that drift over time would occur with this algorithm, but again
it's going to depend on the requirements as to whether on not this is
critical to the application.


-----Original Message-----
From: Belcham, Robin [BSS Audio UK] [mailto:Robin.Belcham at bss.co.uk]
Sent: Wednesday, October 17, 2001 10:42 AM
To: 'music-dsp at shoko.calarts.edu'
Subject: RE: [music-dsp] oscillators


Aren't there problems with this implementation when changing the frequency -
i.e you get a discontinuity when resetting the taps? I was also under the
impression that this type of oscillator drifts over time. I'm currently
looking at implementing a 2nd order waveguide oscillator (Smith, J. O. and
Cook, P., "The Second Order Digital Waveguide Oscillator"
(http://www-ccrma.stanford.edu/~jos)) to provide a solution that can have
frequency changing over time without having to re-start the oscillator.

Please correct me if I'm wrong.

Rob Belcham


-----Original Message-----
From: Wolfgang Schneider [mailto:wschneider at nexoft.de]
Sent: 17 October 2001 15:15
To: music-dsp at shoko.calarts.edu
Subject: Re: [music-dsp] oscillators


> Probably the most efficient thing to do would be to generate 1 360 degree
> phase loop of the sine wave to RAM.  From there you can just read it over
> and over again to generate a continuous wave.  It doesn't take very long
at
> all to generate so you can regenerate as your conditions change (i.e.
> frequency, amplitude).

first of all: lookup tables are generally a very BAD idea nowadays. The
bottleneck 
in the very most cases is not anymore processor speed, but memory bandwidth
and cache pollution. A sine oscillator can be calculated highly effective by
something like this:

init:
fSin = 0.0f;
fCos = 1.0f;
coef = 2.0 * sin(pi * oscFreq / sampleRate);

loop
{
     fSin -= coef * fCos;
     fCos += coef * fSin;
}

which is about the fastest way you can go. Frequency changes require 
recalculation of the coefficient, which means a "real" sin() function has
to be called. You can easily see, that this is still significantly less work
than re-filling a lookup table, which, btw, hardly anybody would do to 
achieve frequency changes - instead you'd be resampling / interpolating.
But after all this, the cases in which a lookup-table is more efficient
than immediate calculation are rare, and will become more rare as 
processors get faster every minute, while memory doesn't. 



bye
    Wolfgang





dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links
http://shoko.calarts.edu/musicdsp/

dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links
http://shoko.calarts.edu/musicdsp/

dupswapdrop -- the music-dsp mailing list and website: subscription info,
FAQ, source code archive, list archive, book reviews, dsp links
http://shoko.calarts.edu/musicdsp/




More information about the music-dsp mailing list