Posted: 20 Nov 2010, 18:41
I'm always a noob script but i would like to use this script found in the matrix pack.
I want to use it with my launchpad patch, but i'm really enable to modify it...
Is there any script guru who could help me to add velocity and note lenght to this script?
I want to use it with my launchpad patch, but i'm really enable to modify it...
Is there any script guru who could help me to add velocity and note lenght to this script?
Code: Select all
//////////////////////////
//
/////////////////////////
// parameters declaration
var RowIn : Tparameter;
var OnModeIn : Tparameter;
var OffModeIn : Tparameter;
var BaseOctaveIn : Tparameter;
var TickIn : Tparameter;
var MidiOut : Tparameter;
var BaseOctave : integer;
var NbOfMidiNotes : integer;
var OnMode : integer;
var OffMode : integer;
var PlayNotes : boolean;
var CurrentNotes : array of single;
var CurrentNotesLen : integer;
var LastNotes : array of single;
CONST MID_NOTE_ON = 144;
CONST MID_VOL_RANGE = 127;
CONST OCTAVE_RANGE = 12;
CONST ON_MODE = '"each","group"';
CONST OFF_MODE = '"hold","cut"';
// initialisation : create parameters
procedure init;
begin
RowIn := CreateParam('row in',ptArray);
SetIsOutput(RowIn,false);
OnModeIn := CreateParam('on mode',ptListBox);
SetIsOutput(OnModeIn,false);
SetListBoxString(OnModeIn,ON_MODE);
OffModeIn := CreateParam('off mode',ptListBox);
SetIsOutput(OffModeIn,false);
SetListBoxString(OffModeIn,OFF_MODE);
BaseOctaveIn := CreateParam('octave',ptDataFader);
SetIsOutput (BaseOctaveIn,false);
SetMin (BaseOctaveIn , 1);
SetMax (BaseOctaveIn , 10);
SetDefaultValue(BaseOctaveIn , 5);
SetFormat (BaseOctaveIn , '%.0f');
TickIn := CreateParam('tick',ptButton);
SetIsOutput(RowIn,false);
MidiOut := CreateParam('midi out',ptMidi);
SetIsInput(MidiOut,false);
BaseOctave := 5;
NbOfMidiNotes := 0;
OnMode := 0;
OffMode := 0;
PlayNotes := FALSE;
SetArrayLength(CurrentNotes , 0);
CurrentNotesLen := 0;
end;
// Global variables
var Miditmp : TMidi;
//////////////////////////////
// callback proc
//////////////////////////////
procedure Callback(n:integer);
var i : integer;
var vol : single;
begin
if (n = RowIn) then begin
CurrentNotesLen := GetLength(RowIn);
SetArrayLength(CurrentNotes , CurrentNotesLen);
SetArrayLength(LastNotes , CurrentNotesLen);
i := 0;
while i < CurrentNotesLen do begin
vol := GetDataArrayValue(RowIn, i);
CurrentNotes[i] := vol;
i := i+1;
end;
end
else if (n = OnModeIn) then begin
OnMode := round( GetValue(OnModeIn) );
end
else if (n = OffModeIn) then begin
OffMode := round( GetValue(OffModeIn) );
end
else if (n = BaseOctaveIn) then begin
BaseOctave := round( GetValue(BaseOctaveIn) );
end
else if (n = TickIn) then begin
NbOfMidiNotes := 0;
i := 0;
while i < CurrentNotesLen do begin
if ((OnMode = 1) and (CurrentNotes[i] <> LastNotes[i]) and (CurrentNotes[i] > 0))
or ((OnMode = 0) and (CurrentNotes[i] > 0))
or ((OffMode = 1) and (CurrentNotes[i] = 0))
then begin
Miditmp.Channel := byte(1);
Miditmp.Msg := MID_NOTE_ON;
Miditmp.Data1 := byte( (BaseOctave * OCTAVE_RANGE) + i);
Miditmp.Data2 := round(MID_VOL_RANGE * CurrentNotes[i]);
SetMidiArrayValue(MidiOut, NbOfMidiNotes ,Miditmp); // set output value
NbOfMidiNotes := NbOfMidiNotes + 1;
end;
LastNotes[i] := CurrentNotes[i];
i := i+1;
end;
SetLength(MidiOut,NbOfMidiNotes);
PlayNotes := TRUE;
end;
end;
//////////////////////////////
// main proc
//////////////////////////////
Procedure Process;
var i : integer;
var len : integer;
var vol : single;
begin
if PlayNotes then begin
PlayNotes := FALSE;
end
else begin
SetLength(MidiOut,0);
end;
end;