Hello everyone. I am not a programmer, i have never used javascript or anything and i have a basic knowledge of how coding works. That said, I am trying to create a script to control the following:
-note range
-note octave
it's basically the Key Range script, with an added option of choosing the octave to play (choosing between +1 which transposes +12 steps, +2 which transposes 24 steps, -1 which transposes -12 steps, and -2 which transposes -24 steps).
So far i have gotten to this:
-----------------------------------------------------------
var activeNotes = [];
function HandleMIDI(event)
{
if (event instanceof NoteOn) {
if (event.pitch > GetParameter('Maximum Pitch'))
return undefined; // don't send if too high
if (event.pitch < GetParameter('Minimum Pitch'))
return undefined; // don't send if too low
if (GetParameter('Octave') = 1)
event.pitch=+12
if (GetParameter('Octave')=-1)
event.pitch=-12
if (GetParameter('Octave')=2)
event.pitch=+24
if (GetParameter('Octave')=-2)
event.pitch=-24
if (GetParameter('Octave')=0)
event.pitch=0
else {
activeNotes.push(event);
event.send()
}
}
else if (event instanceof NoteOff) {
for (i=0; i < activeNotes.length; i++) {
if (event.pitch == activeNotes.pitch) {
event.send();
activeNotes.splice(i,1);
break;
}
}
}
else { // pass non-note events through
event.send();
}
}
var PluginParameters = [
{ name:"Octave", defaultValue:0, minValue:-2, maxValue:2,
numberOfSteps:4,type:'lin'},
{ name:'Maximum Pitch', type:'lin',
minValue:0, maxValue:127, numberOfSteps:127, defaultValue:115},
{ name:'Minimum Pitch', type:'lin',
minValue:0, maxValue:127, numberOfSteps:127, defaultValue:30}
];
-----------------------------------------------
this gives me the octave slider in the UI, but when i run the script and play a note, it returns an error and i don't understand what happens. Any input? THAAAAANKS