home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World 2008 February
/
PCWorld_2008-02_cd.bin
/
audio-video
/
reaper
/
reaper2028-install.exe
/
Effects
/
IX
/
MIDI_Wobulator
< prev
next >
Wrap
Text File
|
2007-12-03
|
4KB
|
137 lines
/*
Copyright 2007, Philip S. Considine
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted
provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list of conditions
and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this list of conditions
and the following disclaimer in the documentation and/or other materials provided with the distribution.
The name of Philip S. Considine may not be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
////////////////////////////////////////////////////////////////////////////////////////////
desc:LFO Controlled MIDI Pitch Wheel Generator
////////////////////////////////////////////////////////////////////////////////////////////
slider1:0<0,15,1{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}>MIDI Channel
slider2:0<0,100,1>Max Bend (%)
slider3:1<0,24,0.1>LFO Frequency
slider4:0<0,1,1{Hertz,Beats}>LFO Units
slider5:6<0,9,1{1,2,4,8,16,32,64,128,256,512}>Updates Per Beat
slider6:1<0,1,1{Off,On}>On/Off
////////////////////////////////////////////////////////////////////////////////////////////
@init
statPitch = 14 * 16;
pitchCentre = 16384;
updateCounter = 0;
t = 0;
divs[0] = 1;
divs[1] = 2;
divs[2] = 4;
divs[3] = 8;
divs[4] = 16;
divs[5] = 32;
divs[6] = 64;
divs[7] = 128;
divs[8] = 256;
divs[9] = 512;
////////////////////////////////////////////////////////////////////////////////////////////
@slider
slider2 < 0 ? slider2 = 0; slider2 > 100 ? slider2 = 100;
slider3 < 0 ? slider3 = 0; slider3 > 50 ? slider3 = 50;
channel = slider1;
valMax = pitchCentre * (slider2/100);
freq = slider3;
units = slider4;
updateFreq = divs[slider5];
slider6 != on ?
(
on = slider6;
t = 0;
updateCounter = 0;
);
////////////////////////////////////////////////////////////////////////////////////////////
@block
updateSamples = ((srate * 60) / tempo) / updateFreq;
units == 0 ? sinTemp = 2*$pi*freq; //Hz
units == 1 ? sinTemp = 2*$pi*((tempo/60)/freq); //Beats
on == 1 ?
(
active = 1;
updateCounter + samplesblock >= updateSamples ?
(
updateSamples <= samplesblock ?
(
//Possibly more than one update in the block
samplesLeft = samplesblock;
offset = 0;
while
(
offset += updateSamples - updateCounter;
t += (updateSamples - updateCounter)/srate;
value = pitchCentre + floor(valMax * sin(sinTemp*t));
midisend(offset,statPitch+channel,value);
samplesLeft -= updateSamples - updateCounter;
updateCounter = 0;
samplesLeft >= updateSamples;
);
updateCounter = samplesLeft;
t += updateCounter/srate;
)
:
(
//Block is smaller than updateSamples, just one update
offset = updateCounter + samplesblock - updateSamples;
t += offset/srate;
value = pitchCentre + floor(valMax * sin(sinTemp*t));
midisend(offset,statPitch+channel,value);
updateCounter = samplesblock - offset;
t += updateCounter/srate;
);
)
:
(
//Just update counters
updateCounter += samplesblock;
t += samplesblock /srate;
);
)
:
(
//send off value only if not already sent
active == 1 ?
(
midisend(offset,statController+channel,target|(offValue*256));
active = 0;
);
);