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

  1. // This effect Copyright (C) 2004 and later Cockos Incorporated
  2. // License: GPL - http://www.gnu.org/licenses/gpl.html
  3.  
  4. desc: pitch2 (subdivided)
  5. slider1:1<0,6,1>octaves down (0..6)
  6. slider2:0<0,11,1>semitones down (0..11)
  7. slider3:0<0,99,1>cents down (0..99)
  8. slider4:250<4,500,10>chunk size (ms)
  9. slider5:0.5<0.001,1>overlap size (0..1)
  10. slider6:-120<-120,6,1>dry mix (dB)
  11. slider7:0.9<0.1,1,0.1>subdivide ratio
  12. slider8:4<1,8,1>subdivide
  13.  
  14. @slider
  15.   lbufsize=bufsize; bufsize=(srate*0.001*slider4)&65534; 
  16.   lbufsize!=bufsize ? ( memset(0,0,1024); freembuf(0); );
  17.   scl=2 ^ (-(slider1 + slider2/12 + slider3/1200)); 
  18.   rilen=(max(scl,0.5)*bufsize)|0; 
  19.   rrilen=((scl*bufsize)|0); 
  20.   slider5=min(1,max(slider5,0)); 
  21.   rspos=slider5*(bufsize-rilen); 
  22.   invbs=1/rspos;
  23.   drymix=2 ^ (slider6/6); 
  24.   subdivide=max(slider8|0,1);
  25.   wetmix=1 / subdivide;
  26.   sdfact=slider7;
  27.   isdfact=1/sdfact;
  28.  
  29. @sample
  30. ss0=spl0; ss1=spl1;
  31. s0=0;
  32. s1=0;
  33.  
  34.  
  35. splbuf=1024;
  36. tbufsize=bufsize;
  37. posbuf=0;
  38. rrilen_l=rrilen;
  39. rspos_l = rspos;
  40. invbs_l = invbs;
  41.  
  42. loop(subdivide,
  43.  
  44.   bufpos = posbuf[0];
  45.  
  46.   hbp=((bufpos * scl)|0)*2;
  47.  
  48.   // pre read these before writing
  49.   s0r=splbuf[2*rrilen_l+hbp];
  50.   s1r=splbuf[2*rrilen_l+hbp+1];
  51.  
  52.   splbuf[bufpos*2]=spl0;
  53.   splbuf[bufpos*2+1]=spl1;
  54.  
  55.   bufpos < rspos_l ? 
  56.   (
  57.      // mix
  58.      sc=bufpos*invbs_l;
  59.      s0+=splbuf[hbp]*sc + s0r*(1-sc);
  60.      s1+=splbuf[hbp+1]*sc + s1r*(1-sc);
  61.   ) : (
  62.     // straight resample
  63.      s0+=splbuf[hbp]; 
  64.      s1+=splbuf[hbp+1];
  65.   );
  66.   (bufpos+=1) >= tbufsize ? bufpos=0;
  67.  
  68.   posbuf[0] = bufpos;
  69.   posbuf += 1;
  70.  
  71.   splbuf += tbufsize*2+1024;
  72.  
  73.  
  74.   invbs_l *= isdfact;
  75.   tbufsize *= sdfact;
  76.   rspos_l *= sdfact;
  77.   rrilen_l = (rrilen_l*sdfact)|0;
  78.  
  79. );
  80.  
  81.  
  82. spl0 = s0*wetmix + ss0*drymix;
  83. spl1 = s1*wetmix + ss1*drymix;
  84.