a patch that counts notes to filter a midi phrase
Bonjour/hi,
i need a patch that counts notes to filter a midi phrase
I don't know where to begin. It seems to be possible with a script?
That i would like to do:
1-
for example
a phrase loop with 9 notes: 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 : midi in
a way to pickup a note on 2: 1 3 5 7 9 2 4 6 8 : midi out
a note on 3: 1 4 7 1 4 7 : midi out
a note on n...
2-
a way to scroll n step forward (pass n notes before count begins)
a note on 3 0 step forward: 1 4 7 1 4 7 : midi out
1 step forward: 2 5 8 2 5 8 : id
2 step forward: 3 6 9 3 6 9 : id
If someone can give me information.
Syntax info source for script (not sure that i'll be able to deal with it)?
Salutations, cyrille.
i need a patch that counts notes to filter a midi phrase
I don't know where to begin. It seems to be possible with a script?
That i would like to do:
1-
for example
a phrase loop with 9 notes: 1 2 3 4 5 6 7 8 9 1 2 3 4 5 6 7 8 9 : midi in
a way to pickup a note on 2: 1 3 5 7 9 2 4 6 8 : midi out
a note on 3: 1 4 7 1 4 7 : midi out
a note on n...
2-
a way to scroll n step forward (pass n notes before count begins)
a note on 3 0 step forward: 1 4 7 1 4 7 : midi out
1 step forward: 2 5 8 2 5 8 : id
2 step forward: 3 6 9 3 6 9 : id
If someone can give me information.
Syntax info source for script (not sure that i'll be able to deal with it)?
Salutations, cyrille.
hi
if u want to try for yourself:
I'd use the MOD operator (modulo). and you need to filter and count note on's of course. like:
IF ((count >= trunc(getValue(offset))) AND (NOT(count MOD trunc(getValue(step))) = 0)) THEN BEGIN // process message
END
ELSE BEGIN // filter message, go to next message
I can put it together for you (maybe tomorrow). its not hard.
if u want to try for yourself:
I'd use the MOD operator (modulo). and you need to filter and count note on's of course. like:
IF ((count >= trunc(getValue(offset))) AND (NOT(count MOD trunc(getValue(step))) = 0)) THEN BEGIN // process message
END
ELSE BEGIN // filter message, go to next message
I can put it together for you (maybe tomorrow). its not hard.
Thanks Amiga909,
I afraid i have not the background to understand yet.
But yes i prefer try myself !
Is this script syntax specific to usine?
If not where can i find things to begin.
I have no programmer's abilities but script seem to be powerful to midi manipulation, then it worth than i take a look.
Your help is welcome.
I afraid i have not the background to understand yet.
But yes i prefer try myself !
Is this script syntax specific to usine?
If not where can i find things to begin.
I have no programmer's abilities but script seem to be powerful to midi manipulation, then it worth than i take a look.
Your help is welcome.
hi cyrille
ok, here is a running version.
its a bit more complicated now - but u should be able to change params in realtime without getting hanging notes (I can explain..). also i stole your idea and i'll do it a bit more generic (eg. want to try to limitCount midiclock messages, etc.).
this version is a mere draft, have to leave now... hope it should get u started with experimenting
btw: @bsork and others: chords should be processed correctly (isnt the case in my scripts that use more than one output, will correct and upload them)
..to use the script, you need to copy&paste into a .script file and insert it in usine (browser or drag&drop).
ok, here is a running version.
its a bit more complicated now - but u should be able to change params in realtime without getting hanging notes (I can explain..). also i stole your idea and i'll do it a bit more generic (eg. want to try to limitCount midiclock messages, etc.).
this version is a mere draft, have to leave now... hope it should get u started with experimenting
Code: Select all
(*/////////////////////////////////////////////////////
// MEP_limitCount - midi script module for sensomusic usine
// version: 2009-04-08 0.1; author: amiga909
//
// TO DO: select message type for counting
// <Description>
// filters Note message based on a counter
// <Parameters>
// offset
// step
//////////////////////////////////////////////////////
*)
//////////////////////////////////////////////////////
// globals
//////////////////////////////////////////////////////
VAR pIn, pOut, pOut2, pStep, pOffset,pResetCount : TParameter;
TYPE MidiNotes = ARRAY OF BOOLEAN;
VAR midiMem : ARRAY OF MidiNotes;
VAR midiMem2 : ARRAY OF MidiNotes;
VAR tmp : TMidi;
VAR len,len1,len2, i,j, step,tmpChan, offset, count : INTEGER;
VAR isLimit,isNoteOffMsg_out1,isNoteOffMsg_out2 : BOOLEAN;
CONST NOTE_ON = 144;
CONST NOTE_OFF = 128;
CONST PROGRAM_CHG = 192;
CONST AFTER_MONO = 208;
CONST PITCHBEND = 224;
//////////////////////////////////////////////////////
// initialize
//////////////////////////////////////////////////////
PROCEDURE init;
BEGIN
pIn := createParam('in', ptMidi);
pOut := createParam('out', ptMidi);
pOut2 := createParam('filtered', ptMidi);
pOffset := createParam('offset', ptDataFader); setMin(pOffset, 0);setMax(pOffset, 16);
pStep := createParam('step', ptDataFader); setMin(pStep, 1);setMax(pStep, 16);
setFormat(step, '%.0f'); setFormat(offset, '%.0f');
pResetCount := createParam('reset count', ptSwitch);
setFormat(pStep, '%.0f'); setFormat(pOffset, '%.0f');
setValue(pStep,1);
setValue(pResetCount,0);
setValue(pOffset,0);
setValue(pStep,1);
setIsInput(pOut,FALSE);
setIsInput(pOut2,FALSE);
setIsOutput(pIn,FALSE);
setIsOutput(pStep,FALSE);
setIsOutput(pResetCount,FALSE);
setIsOutput(pOffset,FALSE);
len:=0; len1 := 0; len2 := 0;
isNoteOffMsg_out1 := FALSE;
isNoteOffMsg_out2 := FALSE;
setArrayLength(midiMem, 16);
setArrayLength(midiMem2, 16);
FOR i := 0 TO 15 DO BEGIN
setArrayLength(midiMem[i], 128);
setArrayLength(midiMem2[i], 128);
FOR j:=0 TO 127 DO BEGIN
midiMem[i][j]:=FALSE;
midiMem2[i][j]:=FALSE;
END;
END;
END;
// <F> filterMidi: filter MIDI_CLOCK, START, CONT, STOP, ACTIVE_SENS
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
FUNCTION filterMidi(msg: INTEGER): BOOLEAN;
BEGIN
IF (msg <= PITCHBEND) THEN BEGIN
RESULT := TRUE;
END
ELSE BEGIN
RESULT:=FALSE;
END;
END;
// <F> isNoteOn:
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
FUNCTION isNoteOn(message: BYTE; velocity: BYTE): BOOLEAN;
BEGIN
IF (message=NOTE_ON)AND(velocity>0) THEN BEGIN
RESULT:=TRUE;
END
ELSE BEGIN
RESULT:=FALSE;
END;
END;
// <F> isNoteOff:
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
FUNCTION isNoteOff(message: BYTE; velocity: BYTE): BOOLEAN;
BEGIN
IF (message=NOTE_OFF)OR((message=NOTE_ON)AND(velocity=0)) THEN BEGIN
RESULT:=TRUE;
END
ELSE BEGIN
RESULT:=FALSE;
END;
END;
// <F> checkStep: TRUE = is modulo dividend
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
FUNCTION checkStep(offs: INTEGER; stp: INTEGER): BOOLEAN;
BEGIN
IF ((count >= offs) AND (NOT(count MOD (stp)) = 0)) THEN BEGIN
RESULT:=FALSE; // send to filter output
END
ELSE BEGIN
RESULT:=TRUE; // pass to normal output
END;
END;
// <P> setHangingNoteOff1:
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
PROCEDURE setHangingNoteOff1();
BEGIN
IF isNoteOn(tmp.msg,tmp.data2) THEN BEGIN
midiMem[tmpChan][tmp.data1] := TRUE;
END
ELSE IF (isNoteOff(tmp.msg,tmp.data2)) THEN BEGIN
midiMem[tmpChan][tmp.data1] := FALSE;
END;
END;
// <P> setHangingNoteOff2:
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
PROCEDURE setHangingNoteOff2();
BEGIN
IF isNoteOn(tmp.msg,tmp.data2) THEN BEGIN
midiMem2[tmpChan][tmp.data1] := TRUE;
END
ELSE IF (isNoteOff(tmp.msg,tmp.data2)) THEN BEGIN
midiMem2[tmpChan][tmp.data1] := FALSE;
END;
END;
////////////////////////////////////////
// main
//////////////////////////////////////////////////////
BEGIN
len := getLength(pIn);
step := trunc(getValue(pStep));
offset := trunc(getValue(pOffset));
IF len > 0 THEN BEGIN
len1 := 0;
len2 := 0;
FOR i := 0 TO (len - 1) DO BEGIN
getMidiArrayValue(pIn, i, tmp);
IF (filterMidi(tmp.msg)) THEN BEGIN
tmpChan := tmp.channel - 1;
IF (tmp.msg = NOTE_ON) THEN BEGIN
count := count + 1;
END;
IF (checkStep(offset, step)) THEN BEGIN
isLimit := TRUE;
END
ELSE BEGIN
isLimit := FALSE;
END;
IF (isLimit) THEN BEGIN // => out1
IF ((isNoteOff(tmp.msg,tmp.data2)) AND (midiMem2[tmpChan][tmp.data1])) THEN BEGIN
setMidiArrayValue(pOut2, len2, tmp);
len2 := len2 + 1;
setHangingNoteOff2();
END
ELSE BEGIN
setMidiArrayValue(pOut, len1, tmp);
len1 := len1 + 1;
setHangingNoteOff1();
END;
END
ELSE BEGIN // // => out2; isLimit = FALSE OR isNoteOffMsg_out2=TRUE
IF ((isNoteOff(tmp.msg,tmp.data2)) AND (midiMem[tmpChan][tmp.data1])) THEN BEGIN
setMidiArrayValue(pOut, len1, tmp);
len1 := len1 + 1;
setHangingNoteOff1();
END
ELSE BEGIN
setMidiArrayValue(pOut2, len2, tmp);
len2 := len2 + 1;
setHangingNoteOff2();
END;
END;
setLength(pOut,len1);
setLength(pOut2,len2);
END
ELSE BEGIN
END;
END;
END
ELSE BEGIN
setLength(pOut, 0);
setLength(pOut2,0);
END;
// writeln('count:'+ inttostr(count));
IF (trunc(getValue(pResetCount)) = 1 ) OR (count = 16384) THEN BEGIN
//count := offset + (count MOD step);
setValue(pResetCount,0);
count := 0;
//setValue(pOffset,0); NOT CORRECT!!
END;
END...to use the script, you need to copy&paste into a .script file and insert it in usine (browser or drag&drop).
Bonjour/hi,
"i stole your idea and i'll do it a bit more generic (eg. want to try to limitCount midiclock messages, etc.). "
Your welcome!
"a bit more complicated now "
Ok, in fact it's very simple, i read the script language like the newspaper (just kidding, of course not !).
Salutations, Cyrille.
"..to use the script, you need to copy&paste into a .script file and insert it in usine (browser or drag&drop)."
I'll try it today, and try to understand it.
"i stole your idea and i'll do it a bit more generic (eg. want to try to limitCount midiclock messages, etc.). "
Your welcome!
"a bit more complicated now "
Ok, in fact it's very simple, i read the script language like the newspaper (just kidding, of course not !).
Salutations, Cyrille.
"..to use the script, you need to copy&paste into a .script file and insert it in usine (browser or drag&drop)."
I'll try it today, and try to understand it.
no midi in/out....?
np, mate 
learning scripting: well.. it took me a long time to get into a bit. now it seems much easier but at the beginning i understood nothing. for me the best way was to start with the 1in/1out script and trying different Tparameters (midi, data, notes, switch, button, etc.), and then trying to do something with these parameters.
the getMidiArrayValue(), setMidiArrayValue(), setLength(), getLength() methods are vital. also the Midi data type.
this script: it should do what you want (at least it compiles). its a ripoff of another script and there a few redundant things it does.
i'l let you know when a final (tested) version is done.
in terms of elegance and CPU/RAM efficiency i won't be able to do a perfect script. if bsork wants to do a better version, look for his stuff!
learning scripting: well.. it took me a long time to get into a bit. now it seems much easier but at the beginning i understood nothing. for me the best way was to start with the 1in/1out script and trying different Tparameters (midi, data, notes, switch, button, etc.), and then trying to do something with these parameters.
the getMidiArrayValue(), setMidiArrayValue(), setLength(), getLength() methods are vital. also the Midi data type.
this script: it should do what you want (at least it compiles). its a ripoff of another script and there a few redundant things it does.
i'l let you know when a final (tested) version is done.
in terms of elegance and CPU/RAM efficiency i won't be able to do a perfect script. if bsork wants to do a better version, look for his stuff!
?nay-seven wrote:no midi in/out....?
pIn := createParam('in', ptMidi);
pOut := createParam('out', ptMidi);
Bonjour/hi,
Just give up to understand, but it works fine and do that i want.
Well done Amiga 909 !
The idea is to make rythmical accents or arrange (in a very simple and automatic way) a patern or realtime while keyboard playing. Accent by playing the same instrument with diffrents eq, volume or send to a reverb parameter. Arrange by choosing differents sounds.
I'll post a patch that use 3 of it.
Salutations, cyrille.
Just give up to understand, but it works fine and do that i want.
Well done Amiga 909 !
The idea is to make rythmical accents or arrange (in a very simple and automatic way) a patern or realtime while keyboard playing. Accent by playing the same instrument with diffrents eq, volume or send to a reverb parameter. Arrange by choosing differents sounds.
I'll post a patch that use 3 of it.
Salutations, cyrille.
Who is online
Users browsing this forum: No registered users and 34 guests
