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

  1. // Copyright 2007, Thomas Scott Stillwell
  2. // All rights reserved.
  3. //
  4. //Redistribution and use in source and binary forms, with or without modification, are permitted 
  5. //provided that the following conditions are met:
  6. //
  7. //Redistributions of source code must retain the above copyright notice, this list of conditions 
  8. //and the following disclaimer. 
  9. //
  10. //Redistributions in binary form must reproduce the above copyright notice, this list of conditions 
  11. //and the following disclaimer in the documentation and/or other materials provided with the distribution. 
  12. //
  13. //The name of Thomas Scott Stillwell may not be used to endorse or 
  14. //promote products derived from this software without specific prior written permission. 
  15. //
  16. //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
  17. //IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
  18. //FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
  19. //BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  20. //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  21. //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  22. //STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
  23. //THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. //
  25. //Contains code from stereoField (c) 2007 by Michael Gruhn, used by permission
  26. //
  27. desc:Stereo Width
  28.  
  29. slider1:0<-20,20>Width boost
  30. slider2:0<-20,20>Center boost
  31. slider3:0<-20,20>Gain
  32. slider4:0<-100,100>Width Balance
  33. slider5:0<-90,90>Width Rotation
  34.  
  35. @init
  36.   log2db = 8.6858896380650365530225783783321; // 20 / ln(10)
  37.   db2log = 0.11512925464970228420089957273422; // ln(10) / 20 
  38.   pi = 3.1415926535;
  39.   halfpi = pi / 2;
  40.  
  41. @slider
  42.   wideboost=exp(slider1 * db2log);
  43.   centerboost=exp(slider2 * db2log);
  44.   gain=exp(slider3 * db2log);
  45.   leftrot = cos(((slider4+100)*0.005)*halfpi) * 2;
  46.   rightrot = sin(((slider4+100)*0.005)*halfpi) * 2;
  47.   rot=slider5*0.017453292;
  48.  
  49. @sample
  50.   center = (spl0 + spl1) * 0.5;
  51.   left = spl0 - center;
  52.   right = spl1 - center;
  53.   spl0 += left * wideboost * leftrot;
  54.   spl1 += right * wideboost * rightrot;
  55.   spl0 += center * centerboost;
  56.   spl1 += center * centerboost;
  57.   spl0 *= gain;
  58.   spl1 *= gain;
  59.   s0 = sign(spl0);
  60.   s1 = sign(spl1);
  61.   angle = atan( spl0 / spl1 );
  62.   (s0 == 1 && s1 == -1) || (s0 == -1 && s1 == -1) ? angle += pi;
  63.   (s0 == -1 && s1 == 1) ? angle += 2 * pi;
  64.   (spl1 == 0) ? (spl0 > 0) ? angle = halfpi : angle = pi + halfpi;
  65.   (spl0 == 0) ? (spl1 > 0) ? angle = 0 : angle = pi;
  66.   angle -= rot;
  67.   radius = sqrt( sqr(spl0)+sqr(spl1) ) ;
  68.   spl0 = sin(angle)*radius;
  69.   spl1 = cos(angle)*radius;
  70.  
  71.