home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 March / PCWorld_2007-03_cd.bin / audio-video / reaper / reaper174-install.exe / Effects / SStillwell / chorus_stereo < prev    next >
Text File  |  2007-01-19  |  2KB  |  101 lines

  1. // This effect Copyright (C) 2004 and later Cockos Incorporated
  2. // License: GPL - http://www.gnu.org/licenses/gpl.html
  3.  
  4.  
  5. desc:chorus
  6.  
  7. slider1:15<1,500>chorus length (ms)
  8. slider2:1<1,8,1>number of voices
  9. slider3:0.5<0,16,0.01>rate (hz) 0 for beatsync
  10. slider4:0.7<0,1>pitch fudge factor
  11. slider5:-6<-100,12,1>wet mix (dB)
  12. slider6:-6<-100,12,1>dry mix (dB)
  13. slider7:0.0<-1,1,0.01>channel rate offset (hz)
  14. slider8:0.25<0.0625,4,0.0625>beat sync (fraction of whole note)
  15.  
  16. @init
  17.  
  18. bpos=0;
  19.  
  20. @slider
  21.  
  22. numvoices=min(16,max(slider2,1));
  23. choruslen=slider1*srate*0.001;
  24.  
  25. i0=0;
  26. i1=0;
  27. i=0;
  28. loop(numvoices, 
  29.   i0[0]=(i+1)/numvoices*$pi; 
  30.   i1[0]=(i+1)/numvoices*$pi;
  31.   i+=1; 
  32. );
  33. bufofs0=32768;
  34. bufofs1=32768;
  35.  
  36. csize=choruslen/numvoices * slider4;
  37.  
  38. wetmix = 2 ^ (slider5/6);
  39. drymix = 2 ^ (slider6/6);
  40.  
  41.  
  42. @block
  43.  
  44.  
  45. slider3==0 ? (
  46.   rateadj=tempo/(240*slider8)*2*$pi/srate;
  47.   rateadj0=tempo/(240*slider8)*2*$pi/srate;
  48.   rateadj1=(tempo/(240*slider8)+slider7)*2*$pi/srate;
  49. ):(
  50.   rateadj=slider3*2*$pi/srate;
  51.   rateadj0=slider3*2*$pi/srate;
  52.   rateadj1=(slider3+slider7)*2*$pi/srate;
  53. );
  54.  
  55. @sample
  56.  
  57. bpos0 >= choruslen ? (
  58.   bpos0=0;
  59. );
  60. os0=spl0;
  61. bpos1 >= choruslen ? (
  62.   bpos1=0;
  63. );
  64. os1=spl1;
  65.  
  66. // calculate new sample based on numvoices
  67.  
  68. spl0=spl0*drymix;
  69. spl1=spl1*drymix;
  70. vol=wetmix/numvoices;
  71. i0=0;
  72. i1=0;
  73.  
  74. loop(numvoices,
  75.    tpos0 = bpos0 - (0.5+0.49*(sin( $pi*(i0[0] += rateadj0))/($pi*i0[0]))) * (i0+1) * csize;
  76.    tpos1 = bpos1 - (0.5+0.49*(sin( $pi*(i1[0] += rateadj1))/($pi*i1[0]))) * (i1+1) * csize;
  77.  
  78.    tpos0 < 0 ? tpos0 += choruslen;
  79.    tpos1 < 0 ? tpos1 += choruslen;
  80.    tpos0 > choruslen ? tpos0 -= choruslen;
  81.    tpos1 > choruslen ? tpos1 -= choruslen;
  82.  
  83.    frac0=tpos0-(0|tpos0);
  84.    tpos02=tpos0>=choruslen-1?0:tpos0+1;
  85.    frac1=tpos1-(0|tpos1);
  86.    tpos12=tpos1>=choruslen-1?0:tpos1+1;
  87.  
  88.    spl0 += (bufofs0[tpos0]*(1-frac0)+bufofs0[tpos02]*frac0) * vol;
  89.    spl1 += (bufofs1[tpos1]*(1-frac1)+bufofs1[tpos12]*frac1) * vol;
  90.  
  91.    i0+=1;
  92.    i1+=1;
  93. );
  94.  
  95.  
  96. bufofs0[bpos0]=os0;
  97. bufofs1[bpos1]=os1;
  98.  
  99. bpos0+=1;
  100. bpos1+=1;
  101.