[music-dsp] lfo oscillator (saw or triangle) without branching

Heine Gundersen mail at bstrr.dk
Wed Sep 28 10:12:37 EDT 2005


a quick floor() replacement could be casting it to an int (truncating it):

phase = (int)(phase+inc);

  - Heine.

Andreas Sumerauer wrote:
> Hi,
> I was thinking about how to accellerate my LFO code (not antialiased of 
> course) and came up with this:
> 
> float lfo(float phase, float inc) // Triangular LFO with amp = 0.25
> {
>   phase = floor(phase+inc);
>   float res = fabs (phase - 0.5);
>   res += 0.25;
> }
> 
> I want to use the code inline and now I am searching for some quick and 
> dirty floor and fabs implementation. (or  are the functions inlined by 
> the compiler anyway? Then I could just leave it as it is - I am using 
> VC++ 2005 express BTW)
> 
> thanks for any comments
> 
> Andreas
> -- 
> 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 
> http://ceait.calarts.edu/mailman/listinfo/music-dsp
> 
> 



More information about the music-dsp mailing list