home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 March / PCWorld_2007-03_cd.bin / audio-video / reaper / reaper174-install.exe / Effects / SStillwell / volscale < prev   
Encoding:
Text File  |  2006-08-15  |  2.3 KB  |  67 lines

  1. // Copyright 2006, 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.  
  14. //
  15. //The name of Thomas Scott Stillwell may not be used to endorse or 
  16. //promote products derived from this software without specific prior written permission. 
  17.  
  18.  
  19. //
  20.  
  21.  
  22. //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 
  23. //IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 
  24. //FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS 
  25. //BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  26. //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
  27. //PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  28. //STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
  29. //THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30.  
  31. desc:scale velocities...vol+compressor for MIDI!
  32.  
  33. slider1:0<0,16,1>Listen channel (0=omni)
  34. slider2:1<0,3,0.01>Scale factor
  35. slider3:0<-127,127,1>Volume offset
  36. slider4:0<0,100,0.1>Mix %
  37.  
  38. @init
  39.   bpos=0;
  40.   note_on = 9*16;
  41.   note_off = 8*16;
  42.  
  43. @slider
  44.   chan=slider1-1;
  45.   scale=slider2;
  46.   offset=slider3;
  47.   mix=slider4/100;
  48.  
  49. @block
  50.   bpos=0;
  51.   while(
  52.     midirecv(mpos, msg1, msg2) ? (
  53.       (msg1 & 240) == note_on ? (
  54.         ((msg1 & 15) == chan) || chan==-1 ? (
  55.           velocity = (msg2 & 65280)/256;
  56.           note = msg2 & 255;
  57.           newvel = min(127,max(0,floor(velocity * scale) + offset));
  58.           midisend(mpos, msg1, (newvel*256) | note);
  59.         );
  60.       ) : (
  61.             midisend(mpos, msg1, msg2);
  62.       );
  63.     );
  64.   );
  65.  
  66. @sample
  67.   bpos += 1;
  68.   spl0 = spl0 * mix;
  69.   spl1 = spl1 * mix;
  70.