Jump to content

Help for a simple (i think) scripter script


grazuck

Recommended Posts

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 :)

Link to comment
Share on other sites

I'm not a programmer either but i could run your script without the error message.

 

change

if (GetParameter('Octave') = 1)

for

if (GetParameter("Octave") == 1)

 

On every line.

 

Now there is other problems.

At octave 0 no note is passing thru.

at other octave you need a note off signal.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...