home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February / PCWorld_2008-02_cd.bin / audio-video / reaper / reaper2028-install.exe / Effects / SStillwell / chorus_stereo < prev    next >
Text File  |  2007-12-03  |  2KB  |  99 lines

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