Main Archive Specials Wiki | FAQ Links Submit Forum

 Another cheap sinusoidal LFOReferences : Posted by info[at]e-phonic[dot]comNotes : Some pseudo code for a easy to calculate LFO. You can even make a rough triangle wave out of this by substracting the output of 2 of these with different phases. PJ Code : r = the rate 0..1 -------------- p += r if(p > 1) p -= 2; out = p*(1-abs(p)); --------------

 CommentsAdded on : 10/06/04 by music-dsp[ AT ]umminger[ DOT ]comComment : Slick! I like it! Sincerely, Frederick UmmingerAdded on : 23/02/05 by balazs[ DOT ]szoradi[ AT ]essnet[ DOT ]seComment : Great! just what I wanted a fast trinagle lfo. :D float rate = 0..1; float phase1 = 0; float phase2 = 0.1f; --------------- phase1 += rate; if (phase1>1) phase1 -= 2; phase2 += rate; if (phase2>1) phase2 -= 2; out = (phase1*(1-abs(phase1)) - phase2*(1-abs(phase2))) * 10; ---------------Added on : 02/08/06 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]huComment : Nice! If you want the output range to be between -1..1 then use: -------------- p += r if(p > 2) p -= 4; out = p*(2-abs(p)); --------------              Added on : 03/08/06 by scoofy[ AT ]inf[ DOT ]elte[ DOT ]huComment : A better way of making a triangle LFO (out range is -1..1): rate = 0..1; p = -1; {     p += rate;     if (p>1) p -= 4.0f;     out = abs(-(abs(p)-2))-1; }               Added on : 10/11/13 by ignasi[ AT ]telenoika[ DOT ]netComment : /* this goes from -1 to +1 */ #include #include using namespace std; int main(int argc, char *argv[]) {          //r = the rate 0..1     float r = 0.5f;     float p = 0.f;     float result=0.f;     //--------------     for(int i=1;i<=2048;i++){     p += r;     if(p > 1) p -= 2;     result = 4*p*(1-fabs(p));     cout << result;     cout <<"\r";     }     }

 Add your own comment Comments are displayed in fixed width, no HTML code allowed! Email: Comment: Are you human?

Site created and maintained by Bram
Graphic design by line.out | Server sponsered by fxpansion