ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray
Statistics: Posted by nay-seven — 22 Jun 2012, 17:45 Statistics: Posted by Fléau — 22 Jun 2012, 16:46
]]>
Corrected a scale mistake in the chord database.
Added a 'key feedback' switch on the note scaler.
Added a chord player and a arppegio player with modulated speed.
I'm near to upload it in the addons, so all suggestions are welcome!
]]>
Statistics: Posted by damstraversaz — 18 Jun 2012, 14:49

Statistics: Posted by Fléau — 17 Jun 2012, 17:57
CODE:
CONST BUFFER_SIZE = 128;// MIDI channel messagesCONST NOTEOFF = Byte(128);CONST NOTEON = Byte(144);TYPE tMidiArr = ARRAY OF tMidi;TYPE tNoteOns = RECORD origChannel : Byte; origNoteNo : Byte; outChannel : Byte; outNoteNo : Byte; END;VAR pMidiIn, pMidiOut1 : tParameter;VAR pTranspose, pNumNotes : tParameter;VAR sentNoteOns : ARRAY OF tNoteOns;VAR numIn, numSentNoteOns, numOut1 : Integer;VAR transpose : Integer;PROCEDURE Init; VAR i : Integer;BEGIN pMidiIn := CreateParam('midi in', ptMidi); SetIsOutput(pMidiIn, FALSE); pMidiOut1 := CreateParam('midi out', ptMidi); SetIsInput(pMidiOut1, FALSE); pTranspose := CreateParam('transpose', ptDataFader); SetIsOutput(pTranspose, FALSE); SetMin(pTranspose, -48); SetMax(pTranspose, 48); SetFormat(pTranspose, '%.0f'); SetSymbol(pTranspose, 'sm'); pNumNotes := CreateParam('num notes', ptDataField); SetIsInput(pNumNotes, FALSE); SetArrayLength(sentNoteOns, BUFFER_SIZE); numSentNoteOns := 0; numOut1 := 0;END; // InitFUNCTION IsNoteOn (currMsg : tMidi) : Boolean;BEGIN IsNoteOn := ((currMsg.msg = NOTEON) AND (currMsg.data2 > 0));END;FUNCTION IsNoteOff (currMsg : tMidi) : Boolean;BEGIN IsNoteOff := (currMsg.msg = NOTEOFF) OR ((currMsg.msg = NOTEON) AND (currMsg.data2 = 0));END;PROCEDURE CreateOut(currMsg : tMidi);BEGIN SetMidiArrayValue(pMidiOut1, numOut1, currMsg); numOut1 := numOut1 + 1;END; // CreateOutPROCEDURE CreateNoteOnOut(origMsg, outMsg : tMidi); VAR curr : tNoteOns;BEGIN WITH curr DO BEGIN origChannel := origMsg.channel; origNoteNo := origMsg.data1; outChannel := outMsg.channel; outNoteNo := outMsg.data1; END; sentNoteOns[numSentNoteOns] := curr; numSentNoteOns := numSentNoteOns + 1; CreateOut(outMsg);END; // CreateNoteOnOutPROCEDURE CheckSendNoteOff(currMsg : tMidi); VAR i, j : Integer; VAR outMsg : tMidi; VAR curr : tNoteOns;BEGIN j := 0; FOR i := 0 TO (numSentNoteOns - 1) DO BEGIN curr := sentNoteOns[i]; IF ((currMsg.channel = curr.origChannel) AND (currMsg.data1 = curr.origNoteNo)) THEN BEGIN outMsg.msg := currMsg.msg; outMsg.channel := curr.outChannel; outMsg.data1 := curr.outNoteNo; outMsg.data2 := currMsg.data2; CreateOut(outMsg); j := j + 1; END ELSE BEGIN sentNoteOns[i - j] := curr; END; END; numSentNoteOns := numSentNoteOns - j;END; // CheckSendNoteOffPROCEDURE CheckInput(currMsg : tMidi); VAR newMsg : tMidi;BEGIN newMsg := currMsg; IF (IsNoteOn(currMsg)) THEN BEGIN newMsg.data1 := newMsg.data1 + transpose; CreateNoteOnOut(currMsg, newMsg); END ELSE IF (IsNoteOff(currMsg)) THEN CheckSendNoteOff(currMsg); SetValue(pNumNotes, numSentNoteOns);END; // CheckInputPROCEDURE Callback(n : Integer);BEGIN CASE n OF pMidiIn : numIn := GetLength(n); pTranspose : transpose := round(GetValue(n)); END;END; // CallbackPROCEDURE Process; VAR i : Integer; VAR currMsg : tMidi;BEGIN FOR i := 0 TO (numIn - 1) DO BEGIN GetMidiArrayValue(pMidiIn, i, currMsg); CheckInput(currMsg); END; SetLength(pMidiOut1, numOut1); numOut1 := 0;END; // ProcessStatistics: Posted by bsork — 15 Jun 2012, 23:57
CODE:
SetValue(voices, nbOfMidi );This will assign the value of nbOfMidi to the parameter called voicesStatistics: Posted by caco — 15 Jun 2012, 15:12
CODE:
var input : Tparameter;var output : Tparameter;var transpo : TParameter;var voices : TParameter;procedure init;begin Input := CreateParam('In',ptMidi); Output := CreateParam('Out',ptMidi); transpo := CreateParam('transpo',ptDataFader); voices := CreateParam('voices',ptDatafield); SetIsInput(Output,false); SetIsOutPut(Input,false); SetIsOutPut(transpo,false); SetFormat(transpo,'%.0f'); SetIsInput(voices,false); SetMin(transpo,-24); SetMax(transpo,24);end;var i : integer;var nbOfMidi : integer;var ReceivedMidi : TMidi;var TranspoVal : single;//////////////////////////////// main proc//////////////////////////////procedure Process;begin nbOfMidi := GetLength(input); // get the number of incoming midi codes if nbOfMidi > 0 then begin SetLength(outPut,nbOfMidi); // set the number of output codes transpoVal := getValue(transpo); // get the transpo value for i := 0 to nbOfMidi-1 // loop for all input codes, for polyphonic data (chords) do begin GetMidiArrayValue(input,i,ReceivedMidi); // get each code ReceivedMidi.data1 := ReceivedMidi.data1+trunc(transpoVal); // calculate transpo SetMidiArrayValue(output,i,ReceivedMidi); // set output value end; end else SetLength(outPut,0); // nothing received, set out length to 0end;I added:Statistics: Posted by Fléau — 15 Jun 2012, 14:50
Statistics: Posted by caco — 15 Jun 2012, 12:06
CODE:
////////////////////////////////////////////////////////////////////////////////// ArrayFind.script// Returns the array index where array B is first found in array A, with an// optional start index for array A. If no matches, the result is -1.//// The returned index in A is the "real" index; the start offset is not // subtracted from the result.//// bSork, V2 June 2012////////////////////////////////////////////////////////////////////////////////VAR pArrA, pStartA, pArrB, pResult : tParameter;PROCEDURE Init;BEGIN pArrA := CreateParam('array A', ptArray); SetIsOutput(pArrA, FALSE); SetMin(pArrA, -1000000000); SetMax(pArrA, +1000000000); pStartA := CreateParam('start index A', ptDataFader); SetIsOutput(pStartA, FALSE); SetMin(pStartA, 0); SetMax(pStartA, 8191); SetFormat(pStartA, '%.0f'); SetDefaultValue(pStartA, 0); pArrB := CreateParam('array B', ptArray); SetIsOutput(pArrB, FALSE); SetMin(pArrB, -1000000000); SetMax(pArrB, +1000000000); pResult := CreateParam('result', ptDataField); SetIsInput(pResult, FALSE); SetMin(pResult, -1); SetMax(pResult, 8191); SetFormat(pResult, '%.0f'); SetValue(pResult, 0);END; // InitPROCEDURE Find; VAR lenA, lenB : Integer; VAR r, a, a2, b : Integer; VAR bx : Single; VAR found : Boolean;BEGIN r := -1; lenB := GetLength(pArrB); IF (lenB > 0) THEN BEGIN b := 0; bx := GetDataArrayValue(pArrB, b); a := round(GetValue(pStartA)); lenA := GetLength(pArrA); WHILE ((r = -1) AND ((lenA - a) >= lenB)) DO BEGIN found := (bx = GetDataArrayValue(pArrA, a)); IF (found) THEN BEGIN a2 := a + 1; b := 1; END; WHILE (found AND (b < lenB)) DO BEGIN found := (GetDataArrayValue(pArrA, a2) = GetDataArrayValue(pArrB, b)); a2 := a2 + 1; b := b + 1; END; IF (found AND (b = lenB)) THEN r := a ELSE b := 0; a := a + 1; END; END; SetValue(pResult, r);END; // FindPROCEDURE Callback(n : Integer);BEGIN IF (n <= pArrB) THEN Find;END; // CallbackStatistics: Posted by bsork — 14 Jun 2012, 23:23
Statistics: Posted by bsork — 14 Jun 2012, 11:40
Statistics: Posted by caco — 14 Jun 2012, 11:21
Statistics: Posted by Fléau — 14 Jun 2012, 10:19
Statistics: Posted by bsork — 14 Jun 2012, 00:19
Statistics: Posted by Fléau — 13 Jun 2012, 15:56
Statistics: Posted by tanabarbier — 12 Jun 2012, 19:53
Statistics: Posted by Fléau — 12 Jun 2012, 18:45
Statistics: Posted by bsork — 12 Jun 2012, 14:20
Statistics: Posted by caco — 12 Jun 2012, 12:58
CODE:
Var ArrayIn, ArrayOut : tparameter;// initialisation : create parametersprocedure init;begin ArrayIn:= createParam('Array in', PtArray); SetIsOutput(ArrayIn,false); ArrayOut:= createParam('Array out', PtArray); SetIsInput(ArrayOut,false);end;// Callback procedureProcedure Callback(N:integer); Var i, j : Integer;begin if (N=ArrayIn) then begin j := 0; for i:= 0 to GetLength(ArrayIn)-1 do begin If (GetDataArrayValue(ArrayIn, i) <> 0) then begin SetDataArrayValue(ArrayOut, j, GetDataArrayValue(ArrayIn, i)); j := j + 1; end; end; SetLength(ArrayOut, j); end;end;Statistics: Posted by bsork — 12 Jun 2012, 12:17
CODE:
///////////////////////////////////////////////////////////////////////////////// Function: Removes any zero values from an array // Version : 1.0// Date : 12 June 2012//////////////////////////////////////////////////////////////////////////////// variables declarationVar ArrayIn, ArrayOut : tparameter;Var non_zero, i, j : integer;// initialisation : create parametersprocedure init;begin ArrayIn:= createParam('Array in', PtArray); SetIsOutput(ArrayIn,false);ArrayOut:= createParam('Array out', PtArray); SetIsInput(ArrayOut,false);end;// Callback procedureProcedure Callback(N:integer); beginif (N=ArrayIn) then beginnon_zero := 0;i := 0;j := 0;//count non-zero elementsfor i:= 0 to GetLength(ArrayIn)-1 do beginIf GetDataArrayValue(ArrayIn, i) <> 0 then beginnon_zero := non_zero + 1; end;end;//set output array to size of non zero elementsSetLength(ArrayOut, non_zero);//copy only non_zero elements to outputfor i:= 0 to GetLength(ArrayIn)-1 do beginIf GetDataArrayValue(ArrayIn, i) <> 0 then beginSetDataArrayValue(ArrayOut, j, GetDataArrayValue(ArrayIn, i)); j := j + 1;end;end;end;end;//////////////////////////////// main proc//////////////////////////////Procedure Process;beginend;Statistics: Posted by caco — 12 Jun 2012, 11:07
That's why i didn't removed duplicates.Confusing, but in this case educational, as you learn that scales with different names are in fact alike..
Statistics: Posted by Fléau — 12 Jun 2012, 10:26
If you don't find the time Caco, I think I can do it tonight. It shouldn't take many lines of code.If nobody else has time for your script I will have a go for you tomorrow, I am learning Usine's script language at the moment so it will be good practice for me
Statistics: Posted by bsork — 12 Jun 2012, 09:20
Statistics: Posted by nay-seven — 22 Jun 2012, 17:45
Statistics: Posted by Fléau — 22 Jun 2012, 16:46
Statistics: Posted by damstraversaz — 18 Jun 2012, 14:49

Statistics: Posted by Fléau — 17 Jun 2012, 17:57
CODE:
CONST BUFFER_SIZE = 128;// MIDI channel messagesCONST NOTEOFF = Byte(128);CONST NOTEON = Byte(144);TYPE tMidiArr = ARRAY OF tMidi;TYPE tNoteOns = RECORD origChannel : Byte; origNoteNo : Byte; outChannel : Byte; outNoteNo : Byte; END;VAR pMidiIn, pMidiOut1 : tParameter;VAR pTranspose, pNumNotes : tParameter;VAR sentNoteOns : ARRAY OF tNoteOns;VAR numIn, numSentNoteOns, numOut1 : Integer;VAR transpose : Integer;PROCEDURE Init; VAR i : Integer;BEGIN pMidiIn := CreateParam('midi in', ptMidi); SetIsOutput(pMidiIn, FALSE); pMidiOut1 := CreateParam('midi out', ptMidi); SetIsInput(pMidiOut1, FALSE); pTranspose := CreateParam('transpose', ptDataFader); SetIsOutput(pTranspose, FALSE); SetMin(pTranspose, -48); SetMax(pTranspose, 48); SetFormat(pTranspose, '%.0f'); SetSymbol(pTranspose, 'sm'); pNumNotes := CreateParam('num notes', ptDataField); SetIsInput(pNumNotes, FALSE); SetArrayLength(sentNoteOns, BUFFER_SIZE); numSentNoteOns := 0; numOut1 := 0;END; // InitFUNCTION IsNoteOn (currMsg : tMidi) : Boolean;BEGIN IsNoteOn := ((currMsg.msg = NOTEON) AND (currMsg.data2 > 0));END;FUNCTION IsNoteOff (currMsg : tMidi) : Boolean;BEGIN IsNoteOff := (currMsg.msg = NOTEOFF) OR ((currMsg.msg = NOTEON) AND (currMsg.data2 = 0));END;PROCEDURE CreateOut(currMsg : tMidi);BEGIN SetMidiArrayValue(pMidiOut1, numOut1, currMsg); numOut1 := numOut1 + 1;END; // CreateOutPROCEDURE CreateNoteOnOut(origMsg, outMsg : tMidi); VAR curr : tNoteOns;BEGIN WITH curr DO BEGIN origChannel := origMsg.channel; origNoteNo := origMsg.data1; outChannel := outMsg.channel; outNoteNo := outMsg.data1; END; sentNoteOns[numSentNoteOns] := curr; numSentNoteOns := numSentNoteOns + 1; CreateOut(outMsg);END; // CreateNoteOnOutPROCEDURE CheckSendNoteOff(currMsg : tMidi); VAR i, j : Integer; VAR outMsg : tMidi; VAR curr : tNoteOns;BEGIN j := 0; FOR i := 0 TO (numSentNoteOns - 1) DO BEGIN curr := sentNoteOns[i]; IF ((currMsg.channel = curr.origChannel) AND (currMsg.data1 = curr.origNoteNo)) THEN BEGIN outMsg.msg := currMsg.msg; outMsg.channel := curr.outChannel; outMsg.data1 := curr.outNoteNo; outMsg.data2 := currMsg.data2; CreateOut(outMsg); j := j + 1; END ELSE BEGIN sentNoteOns[i - j] := curr; END; END; numSentNoteOns := numSentNoteOns - j;END; // CheckSendNoteOffPROCEDURE CheckInput(currMsg : tMidi); VAR newMsg : tMidi;BEGIN newMsg := currMsg; IF (IsNoteOn(currMsg)) THEN BEGIN newMsg.data1 := newMsg.data1 + transpose; CreateNoteOnOut(currMsg, newMsg); END ELSE IF (IsNoteOff(currMsg)) THEN CheckSendNoteOff(currMsg); SetValue(pNumNotes, numSentNoteOns);END; // CheckInputPROCEDURE Callback(n : Integer);BEGIN CASE n OF pMidiIn : numIn := GetLength(n); pTranspose : transpose := round(GetValue(n)); END;END; // CallbackPROCEDURE Process; VAR i : Integer; VAR currMsg : tMidi;BEGIN FOR i := 0 TO (numIn - 1) DO BEGIN GetMidiArrayValue(pMidiIn, i, currMsg); CheckInput(currMsg); END; SetLength(pMidiOut1, numOut1); numOut1 := 0;END; // ProcessStatistics: Posted by bsork — 15 Jun 2012, 23:57
CODE:
SetValue(voices, nbOfMidi );This will assign the value of nbOfMidi to the parameter called voicesStatistics: Posted by caco — 15 Jun 2012, 15:12
CODE:
var input : Tparameter;var output : Tparameter;var transpo : TParameter;var voices : TParameter;procedure init;begin Input := CreateParam('In',ptMidi); Output := CreateParam('Out',ptMidi); transpo := CreateParam('transpo',ptDataFader); voices := CreateParam('voices',ptDatafield); SetIsInput(Output,false); SetIsOutPut(Input,false); SetIsOutPut(transpo,false); SetFormat(transpo,'%.0f'); SetIsInput(voices,false); SetMin(transpo,-24); SetMax(transpo,24);end;var i : integer;var nbOfMidi : integer;var ReceivedMidi : TMidi;var TranspoVal : single;//////////////////////////////// main proc//////////////////////////////procedure Process;begin nbOfMidi := GetLength(input); // get the number of incoming midi codes if nbOfMidi > 0 then begin SetLength(outPut,nbOfMidi); // set the number of output codes transpoVal := getValue(transpo); // get the transpo value for i := 0 to nbOfMidi-1 // loop for all input codes, for polyphonic data (chords) do begin GetMidiArrayValue(input,i,ReceivedMidi); // get each code ReceivedMidi.data1 := ReceivedMidi.data1+trunc(transpoVal); // calculate transpo SetMidiArrayValue(output,i,ReceivedMidi); // set output value end; end else SetLength(outPut,0); // nothing received, set out length to 0end;I added:Statistics: Posted by Fléau — 15 Jun 2012, 14:50
Statistics: Posted by caco — 15 Jun 2012, 12:06
CODE:
////////////////////////////////////////////////////////////////////////////////// ArrayFind.script// Returns the array index where array B is first found in array A, with an// optional start index for array A. If no matches, the result is -1.//// The returned index in A is the "real" index; the start offset is not // subtracted from the result.//// bSork, V2 June 2012////////////////////////////////////////////////////////////////////////////////VAR pArrA, pStartA, pArrB, pResult : tParameter;PROCEDURE Init;BEGIN pArrA := CreateParam('array A', ptArray); SetIsOutput(pArrA, FALSE); SetMin(pArrA, -1000000000); SetMax(pArrA, +1000000000); pStartA := CreateParam('start index A', ptDataFader); SetIsOutput(pStartA, FALSE); SetMin(pStartA, 0); SetMax(pStartA, 8191); SetFormat(pStartA, '%.0f'); SetDefaultValue(pStartA, 0); pArrB := CreateParam('array B', ptArray); SetIsOutput(pArrB, FALSE); SetMin(pArrB, -1000000000); SetMax(pArrB, +1000000000); pResult := CreateParam('result', ptDataField); SetIsInput(pResult, FALSE); SetMin(pResult, -1); SetMax(pResult, 8191); SetFormat(pResult, '%.0f'); SetValue(pResult, 0);END; // InitPROCEDURE Find; VAR lenA, lenB : Integer; VAR r, a, a2, b : Integer; VAR bx : Single; VAR found : Boolean;BEGIN r := -1; lenB := GetLength(pArrB); IF (lenB > 0) THEN BEGIN b := 0; bx := GetDataArrayValue(pArrB, b); a := round(GetValue(pStartA)); lenA := GetLength(pArrA); WHILE ((r = -1) AND ((lenA - a) >= lenB)) DO BEGIN found := (bx = GetDataArrayValue(pArrA, a)); IF (found) THEN BEGIN a2 := a + 1; b := 1; END; WHILE (found AND (b < lenB)) DO BEGIN found := (GetDataArrayValue(pArrA, a2) = GetDataArrayValue(pArrB, b)); a2 := a2 + 1; b := b + 1; END; IF (found AND (b = lenB)) THEN r := a ELSE b := 0; a := a + 1; END; END; SetValue(pResult, r);END; // FindPROCEDURE Callback(n : Integer);BEGIN IF (n <= pArrB) THEN Find;END; // CallbackStatistics: Posted by bsork — 14 Jun 2012, 23:23
Statistics: Posted by bsork — 14 Jun 2012, 11:40
Statistics: Posted by caco — 14 Jun 2012, 11:21
Statistics: Posted by Fléau — 14 Jun 2012, 10:19
Statistics: Posted by bsork — 14 Jun 2012, 00:19
Statistics: Posted by Fléau — 13 Jun 2012, 15:56
Statistics: Posted by tanabarbier — 12 Jun 2012, 19:53
Statistics: Posted by Fléau — 12 Jun 2012, 18:45
Statistics: Posted by bsork — 12 Jun 2012, 14:20
Statistics: Posted by caco — 12 Jun 2012, 12:58
CODE:
Var ArrayIn, ArrayOut : tparameter;// initialisation : create parametersprocedure init;begin ArrayIn:= createParam('Array in', PtArray); SetIsOutput(ArrayIn,false); ArrayOut:= createParam('Array out', PtArray); SetIsInput(ArrayOut,false);end;// Callback procedureProcedure Callback(N:integer); Var i, j : Integer;begin if (N=ArrayIn) then begin j := 0; for i:= 0 to GetLength(ArrayIn)-1 do begin If (GetDataArrayValue(ArrayIn, i) <> 0) then begin SetDataArrayValue(ArrayOut, j, GetDataArrayValue(ArrayIn, i)); j := j + 1; end; end; SetLength(ArrayOut, j); end;end;Statistics: Posted by bsork — 12 Jun 2012, 12:17
CODE:
///////////////////////////////////////////////////////////////////////////////// Function: Removes any zero values from an array // Version : 1.0// Date : 12 June 2012//////////////////////////////////////////////////////////////////////////////// variables declarationVar ArrayIn, ArrayOut : tparameter;Var non_zero, i, j : integer;// initialisation : create parametersprocedure init;begin ArrayIn:= createParam('Array in', PtArray); SetIsOutput(ArrayIn,false);ArrayOut:= createParam('Array out', PtArray); SetIsInput(ArrayOut,false);end;// Callback procedureProcedure Callback(N:integer); beginif (N=ArrayIn) then beginnon_zero := 0;i := 0;j := 0;//count non-zero elementsfor i:= 0 to GetLength(ArrayIn)-1 do beginIf GetDataArrayValue(ArrayIn, i) <> 0 then beginnon_zero := non_zero + 1; end;end;//set output array to size of non zero elementsSetLength(ArrayOut, non_zero);//copy only non_zero elements to outputfor i:= 0 to GetLength(ArrayIn)-1 do beginIf GetDataArrayValue(ArrayIn, i) <> 0 then beginSetDataArrayValue(ArrayOut, j, GetDataArrayValue(ArrayIn, i)); j := j + 1;end;end;end;end;//////////////////////////////// main proc//////////////////////////////Procedure Process;beginend;Statistics: Posted by caco — 12 Jun 2012, 11:07
That's why i didn't removed duplicates.Confusing, but in this case educational, as you learn that scales with different names are in fact alike..
Statistics: Posted by Fléau — 12 Jun 2012, 10:26
If you don't find the time Caco, I think I can do it tonight. It shouldn't take many lines of code.If nobody else has time for your script I will have a go for you tomorrow, I am learning Usine's script language at the moment so it will be good practice for me
Statistics: Posted by bsork — 12 Jun 2012, 09:20