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

  1. // This effect Copyright (C) 2004 and later Cockos Incorporated
  2. // License: GPL - http://www.gnu.org/licenses/gpl.html
  3.  
  4. desc: octave up
  5. slider1:120<4,500,10>Chunk (ms)
  6. slider2:0.4<0,1>overlap
  7. slider3:0<-120,6,1>wet mix (dB)
  8. slider4:-120<-120,6,1>dry mix (dB)
  9.  
  10. @init
  11. bufsize=-1;
  12.  
  13. @slider
  14. nbufsize=srate*0.001*slider1; 
  15. nbufsize=nbufsize&(65536-1-7); 
  16. bufsize != nbufsize ? 
  17. (
  18.   bufsize=nbufsize; 
  19.   hbsz=bufsize*0.5; 
  20.   qbsz=bufsize*0.25;
  21.   playbuf=0;    
  22.   recpos=0; 
  23.   playpos=hbsz; 
  24.   recbuf=bufsize;
  25. );
  26.  
  27. slider2=min(1,max(slider2,0));
  28. o_start=qbsz * (2 - slider2);
  29. o_end=qbsz * (2 + slider2);
  30. fadesc=1/(hbsz-o_start);
  31. drymix=2 ^ (slider4/6); wetmix=2 ^ (slider3/6);
  32.  
  33. @sample
  34.  
  35. s0=spl0;
  36. s1=spl1;
  37.  
  38. recbuf[recpos*2]=spl0;
  39. recbuf[recpos*2+1]=spl1;
  40.  
  41. playpos < o_start ? ( 
  42.     // first quarter (first half of first block)
  43.     spl0=playbuf[playpos*4];
  44.     spl1=playbuf[playpos*4+1];
  45. ) : (
  46.     playpos < hbsz ? ( 
  47.       // second quarter
  48.         sc=(playpos-o_start)*fadesc;
  49.                       
  50.         spl0=
  51.            // second half of first block mix
  52.             playbuf[playpos*4]*(1-sc) + 
  53.            // first half of second block mix
  54.             playbuf[(playpos-qbsz)*4]*sc;
  55.         spl1=
  56.            // second half of first block mix
  57.             playbuf[playpos*4+1]*(1-sc) + 
  58.            // first half of second block mix
  59.             playbuf[(playpos-qbsz)*4+1]*sc;
  60.     ) : (
  61.       playpos < o_end ? (
  62.          // third quarter
  63.         sc=(playpos-hbsz)*fadesc;
  64.         spl0=
  65.            // second half of second block
  66.             playbuf[(playpos-qbsz)*4]*(1-sc) + 
  67.            // first half of third block
  68.             playbuf[(playpos-hbsz)*4]*sc;
  69.         spl1=
  70.            // second half of second block
  71.             playbuf[(playpos-qbsz)*4+1]*(1-sc) + 
  72.            // first half of third block
  73.             playbuf[(playpos-hbsz)*4+1]*sc;
  74.       ) : (
  75.           // last quarter (second half of third block)
  76.         spl0=playbuf[(playpos-hbsz)*4];
  77.         spl1=playbuf[(playpos-hbsz)*4+1];
  78.       )
  79.   )
  80.  
  81. );
  82.  
  83. (recpos+=1) >= bufsize ? (
  84.    recpos=0;
  85.    recbuf=(!recbuf)*bufsize*2;
  86. );
  87.  
  88. (playpos+=1) >= bufsize ? (
  89.   playpos=0;
  90.   playbuf=(!playbuf)*bufsize*2;
  91. );
  92.  
  93. spl0=spl0*wetmix + s0*drymix;
  94. spl1=spl1*wetmix + s1*drymix;
  95.