ArrayArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2010-02-22T14:46:48+02:00 https://brainmodular.org/forums/app.php/feed/topic/1926 2010-02-22T14:46:48+02:00 2010-02-22T14:46:48+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11810#p11810 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
Take the code below, copy it into an empty script overwriting the existing text and run compile (ctrl-F9].

CODE:

&#40;*****************************************************************************************************Transpose.scriptScript for inserting into a MIDI stream to transpose all or just a part of the notes received.NoteOffs are mapped to the same channel and note number as the previous NoteOns, avoidinghanging notes even when changing parameters before the note is released.The input channel/note can be sent together with the transposed notes.Key/poly aftertouch can optionally also be transposed together with the notes.*****************************************************************************************************&#41;CONST BUFFER_SIZE = 128;// MIDI channel messagesCONST NOTEOFF = Byte&#40;128&#41;;CONST NOTEON  = Byte&#40;144&#41;;CONST KA      = Byte&#40;160&#41;; // Key &#40;poly&#41; AftertouchTYPE tMidiArr = ARRAY OF tMidi;TYPE tNoteOns = RECORD        origChannel &#58; Byte;        origNoteNo  &#58; Byte;        outChannel  &#58; Byte;        outNoteNo   &#58; Byte;        hasKA       &#58; Boolean;     END;////////////////////////////////////////////////////////////////////////////////////////// In-/out parametersVAR pMidiIn, pMidiOut1 &#58; tParameter;VAR pBypass, pChIn, pTrspLoLim, pTrspHiLim, pInclKA &#58; tParameter;VAR pChOut, pTranspose, pOctFoldBack, pKeep &#58; tParameter;// Global variablesVAR bypass, inclKA &#58; Boolean;VAR sentNoteOns &#58; ARRAY OF tNoteOns;VAR numIn, numSentNoteOns, numOut1 &#58; Integer;VAR chIn, trspLoLim, trspHiLim, chOut &#58; Byte;VAR transpose &#58; Integer;VAR octFoldback, keepOrig &#58; Boolean;////////////////////////////////////////////////////////////////////////////////////////PROCEDURE Init;   VAR i &#58; Integer;BEGIN   trspLoLim &#58;= 0;   trspHiLim &#58;= 127;   chIn &#58;= 0;   chOut &#58;= 0;   pMidiIn &#58;= CreateParam&#40;'midi in', ptMidi&#41;; SetIsOutput&#40;pMidiIn, FALSE&#41;;   pMidiOut1 &#58;= CreateParam&#40;'midi out', ptMidi&#41;; SetIsInput&#40;pMidiOut1, FALSE&#41;;   pBypass &#58;= CreateParam&#40;'bypass', ptSwitch&#41;; SetIsOutput&#40;pBypass, FALSE&#41;;   pChIn &#58;= CreateParam&#40;'channel in', ptListbox&#41;; SetIsOutput&#40;pChIn, FALSE&#41;;   SetListboxString&#40;pChIn, '"all","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"'&#41;;   SetValue&#40;pChIn, Single&#40;chIn&#41;&#41;;   pTrspLoLim &#58;= CreateParam&#40;'note lo limit', ptMidiNoteFader&#41;; SetIsOutput&#40;pTrspLoLim, FALSE&#41;;   SetDefaultValue&#40;pTrspLoLim, trspLoLim&#41;; SetValue&#40;pTrspLoLim, trspLoLim&#41;;   pTrspHiLim &#58;= CreateParam&#40;'note hi limit', ptMidiNoteFader&#41;; SetIsOutput&#40;pTrspHiLim, FALSE&#41;;   SetDefaultValue&#40;pTrspHiLim, trspHiLim&#41;; SetValue&#40;pTrspHiLim, trspHiLim&#41;;   pInclKA &#58;= CreateParam&#40;'incl KA', ptSwitch&#41;; SetIsOutput&#40;pInclKA, FALSE&#41;;      pChOut &#58;= CreateParam&#40;'channel out', ptListbox&#41;; SetIsOutput&#40;pChOut, FALSE&#41;;   SetListboxString&#40;pChOut, '"orig","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"'&#41;;   SetValue&#40;pChOut, Single&#40;chOut&#41;&#41;;   pTranspose &#58;= CreateParam&#40;'transpose', ptDataFader&#41;; SetIsOutput&#40;pTranspose, FALSE&#41;;   SetMin&#40;pTranspose, -48&#41;; SetMax&#40;pTranspose, 48&#41;;   SetFormat&#40;pTranspose, '%.0f'&#41;; SetSymbol&#40;pTranspose, 'sm'&#41;;   pOctFoldback &#58;= CreateParam&#40;'oct foldback', ptSwitch&#41;; SetIsOutput&#40;pOctFoldback, FALSE&#41;;   pKeep &#58;= CreateParam&#40;'keep input', ptSwitch&#41;; SetIsOutput&#40;pKeep, FALSE&#41;;   SetArrayLength&#40;sentNoteOns, BUFFER_SIZE&#41;;   numSentNoteOns &#58;= 0;   numOut1 &#58;= 0;END; // Init/////////////////////////////////  Checking channel message types  /////////////////////////////////FUNCTION IsNote &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsNote &#58;= &#40;&#40;currMsg.msg = NOTEON&#41; OR &#40;currMsg.msg = NOTEOFF&#41;&#41;;END;FUNCTION IsNoteOn &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsNoteOn &#58;= &#40;&#40;currMsg.msg = NOTEON&#41; AND &#40;currMsg.data2 > 0&#41;&#41;;END;FUNCTION IsNoteOff &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsNoteOff &#58;= &#40;currMsg.msg = NOTEOFF&#41; OR &#40;&#40;currMsg.msg = NOTEON&#41; AND &#40;currMsg.data2 = 0&#41;&#41;;END;FUNCTION IsKA &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsKA &#58;= &#40;currMsg.msg = KA&#41;;END;////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE mTrace&#40;s &#58; String; m &#58; tMidi&#41;;BEGIN   WITH m DO       WriteLn&#40;s + '&#58; msg&#58;' + IntToStr&#40;msg&#41;                 + ' ch&#58;' + IntToStr&#40;channel&#41;                 + ' d1&#58;' + IntToStr&#40;data1&#41;                 + ' d2&#58;' + IntToStr&#40;data2&#41;&#41;;END; // mTrace////////////////////////////////////////////////////////////////////////////////////////////////////FUNCTION WithinRange&#40;value &#58; Byte&#41; &#58; Boolean;   VAR retVal &#58; Boolean;BEGIN   retVal &#58;= FALSE;   IF &#40;&#40;value >= trspLoLim&#41; AND &#40;value <= trspHiLim&#41;&#41; THEN BEGIN      retVal &#58;= TRUE;   END   ELSE IF &#40;value = trspLoLim&#41; OR &#40;value = trspHiLim&#41; THEN BEGIN      retVal &#58;= TRUE;   END   ELSE IF &#40;trspLoLim > trspHiLim&#41; THEN BEGIN      retVal &#58;= &#40;&#40;value < trspHiLim&#41; OR &#40;value > trspLoLim&#41;&#41;;   END;   WithinRange &#58;= retVal;END; // WithinRange////////////////////////////////////////////////////////////////////////////////////////////////////FUNCTION CalcTranspose&#40;NoteNo &#58; Byte&#41; &#58; Byte;   VAR note &#58; Integer; BEGIN   note &#58;= Integer&#40;NoteNo&#41; + transpose;   IF &#40;note < 0&#41; THEN BEGIN      IF &#40;NOT octFoldback&#41; THEN BEGIN         note &#58;= 0;      END      ELSE BEGIN         note &#58;= abs&#40;12 + note&#41; MOD 12;      END;   END   ELSE IF &#40;note > 127&#41; THEN BEGIN      IF &#40;NOT octFoldback&#41; THEN BEGIN         note &#58;= 127;      END      ELSE BEGIN        note &#58;= &#40;&#40;note - 128&#41; MOD 12&#41; + 116;      END;   END;   CalcTranspose &#58;= Byte&#40;note&#41;;END; // CalcTranspose////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CreateOut&#40;currMsg &#58; tMidi&#41;;BEGIN   SetMidiArrayValue&#40;pMidiOut1, numOut1, currMsg&#41;;   numOut1 &#58;= numOut1 + 1;END; // CreateOut////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CreateNoteOnOut&#40;origMsg, outMsg &#58; tMidi&#41;;   VAR curr &#58; tNoteOns;BEGIN   WITH curr DO BEGIN      origChannel &#58;= origMsg.channel;      origNoteNo  &#58;= origMsg.data1;      outChannel  &#58;= outMsg.channel;      outNoteNo   &#58;= outMsg.data1;      hasKA       &#58;= FALSE;   END;   sentNoteOns&#91;numSentNoteOns&#93; &#58;= curr;   numSentNoteOns &#58;= numSentNoteOns + 1;   CreateOut&#40;outMsg&#41;;END; // CreateNoteOnOut///////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CheckSendNoteOff&#40;currMsg &#58; tMidi&#41;;   VAR i, j &#58; Integer;   VAR outMsg &#58; tMidi;   VAR curr &#58; tNoteOns;   VAR found &#58; Boolean;BEGIN   j &#58;= 0;   found &#58;= FALSE;   FOR i &#58;= 0 TO &#40;numSentNoteOns - 1&#41; DO BEGIN      curr &#58;= sentNoteOns&#91;i&#93;;      IF &#40;&#40;currMsg.channel = curr.origChannel&#41; AND &#40;currMsg.data1 = curr.origNoteNo&#41;&#41; THEN BEGIN         outMsg.msg     &#58;= currMsg.msg;         outMsg.channel &#58;= curr.outChannel;         outMsg.data1   &#58;= curr.outNoteNo;         outMsg.data2   &#58;= currMsg.data2;         CreateOut&#40;outMsg&#41;;         IF &#40;curr.hasKA&#41; THEN BEGIN            outMsg.msg  &#58;= KA;            outMsg.data2 &#58;= 0;            CreateOut&#40;outMsg&#41;; // Resets any key aftertouch <> 0         END;         j &#58;= j + 1;         found &#58;= TRUE;      END      ELSE BEGIN         sentNoteOns&#91;i - j&#93; &#58;= curr;      END;   END;   numSentNoteOns &#58;= numSentNoteOns - j;   IF &#40;NOT found&#41; THEN CreateOut&#40;currMsg&#41;;END; // CheckSendNoteOff////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CheckSendKA&#40;currMsg &#58; tMidi&#41;;   VAR i &#58; Integer;   VAR outMsg &#58; tMidi;   VAR curr &#58; tNoteOns;BEGIN   FOR i &#58;= 0 TO &#40;numSentNoteOns - 1&#41; DO BEGIN      curr &#58;= sentNoteOns&#91;i&#93;;      IF &#40;&#40;currMsg.channel = curr.origChannel&#41; AND &#40;currMsg.data1 = curr.origNoteNo&#41;&#41; THEN BEGIN         outMsg.msg     &#58;= currMsg.msg;         outMsg.channel &#58;= curr.outChannel;         outMsg.data1   &#58;= curr.outNoteNo;         outMsg.data2   &#58;= currMsg.data2;         sentNoteOns&#91;i&#93;.hasKA &#58;= TRUE;         CreateOut&#40;outMsg&#41;;      END;   END;END; // CheckSendKA////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CheckInput&#40;currMsg &#58; tMidi&#41;;   VAR newMsg &#58; tMidi;BEGIN   IF &#40;bypass AND IsNoteOn&#40;currMsg&#41;&#41; THEN BEGIN      CreateNoteOnOut&#40;currMsg, currMsg&#41;;   END   ELSE IF &#40;    &#40;NOT bypass&#41;             AND IsNoteOn&#40;currMsg&#41;            AND &#40;&#40;chIn = 0&#41; OR &#40;chIn = currMsg.channel&#41;&#41;            AND WithinRange&#40;currMsg.data1&#41;&#41; THEN BEGIN      newMsg &#58;= currMsg;      IF &#40;transpose <> 0&#41; THEN          newMsg.data1 &#58;= CalcTranspose&#40;newMsg.data1&#41;;      IF &#40;chOut <> 0&#41; THEN          newMsg.channel &#58;= chOut;      IF &#40;keepOrig AND &#40;&#40;currMsg.channel <> newMsg.channel&#41; OR &#40;currMsg.data1 <> newMsg.data1&#41;&#41;&#41; THEN         CreateNoteOnOut&#40;currMsg, currMsg&#41;;      CreateNoteOnOut&#40;currMsg, newMsg&#41;;   END   ELSE IF &#40;IsNoteOff&#40;currMsg&#41;&#41; THEN BEGIN      CheckSendNoteOff&#40;currMsg&#41;;   END   ELSE IF &#40;inclKA AND IsKA&#40;currMsg&#41;&#41; THEN BEGIN      CheckSendKA&#40;currMsg&#41;;   END   ELSE BEGIN      CreateOut&#40;currMsg&#41;;   END;END; // CheckInput////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE Callback&#40;n &#58; Integer&#41;;BEGIN   //strace&#40;'callback&#58; ' + IntToStr&#40;n&#41;&#41;;   CASE n OF      pMidiIn       &#58; numIn       &#58;= GetLength&#40;n&#41;;      pBypass       &#58; bypass      &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;      pChIn         &#58; chIn        &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pTrspLoLim    &#58; trspLoLim   &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pTrspHiLim    &#58; trspHiLim   &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pInclKA       &#58; inclKA      &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;      pChOut        &#58; chOut       &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pTranspose    &#58; transpose   &#58;= round&#40;GetValue&#40;n&#41;&#41;;      pOctFoldback  &#58; octFoldback &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;      pKeep         &#58; keepOrig    &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;   END;END; // Callback////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE Process;   VAR i &#58; Integer;   VAR currMsg &#58; tMidi;BEGIN   FOR i &#58;= 0 TO &#40;numIn - 1&#41; DO BEGIN      GetMidiArrayValue&#40;pMidiIn, i, currMsg&#41;;      CheckInput&#40;currMsg&#41;;   END;   SetLength&#40;pMidiOut1, numOut1&#41;;   numOut1 &#58;= 0;END; // Process
(Hope it's the right version - I'm away from home and haven't got time to check)

Statistics: Posted by bsork — 22 Feb 2010, 13:46


]]>
2010-02-22T12:42:18+02:00 2010-02-22T12:42:18+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11798#p11798 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
This is not too smart, in that you must stop playing all notes before you switch channels, or you will get hanging notes. The script will be smarter.....
if you put a 'has changed' triggering an 'all notes off' from the knob/fader you use to change channels you can get around this pretty easily. hope it helps... :)

Statistics: Posted by Clearscreen — 22 Feb 2010, 11:42


]]>
2010-02-22T05:18:17+02:00 2010-02-22T05:18:17+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11793#p11793 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]> Statistics: Posted by Ben J — 22 Feb 2010, 04:18


]]>
2010-02-21T16:26:01+02:00 2010-02-21T16:26:01+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11782#p11782 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]> http://www.niallmoody.com/ndcplugs/ndcmidi.htm
If you connect a slider or similar to the Midi channel inlet you can store it in the conductor.

Not saying that it isn't possible with Usine's own modules, it was just the quickest way I've found when being new to Usine and I keep it out of laziness. :)

Statistics: Posted by nofish — 21 Feb 2010, 15:26


]]>
2010-02-21T11:27:26+02:00 2010-02-21T11:27:26+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11776#p11776 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]> you can also use several midi transformer module...;-)

Statistics: Posted by nay-seven — 21 Feb 2010, 10:27


]]>
2010-02-21T11:22:39+02:00 2010-02-21T11:22:39+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11775#p11775 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
Take a midi input object, turn on 'unpack'. Plug message,code1,code2,and receive into the related inputs on a 'create midi message' module (receive goes to create)

Now drag a cable from the 'chan' input and create a combobox (or what have you) to change channel....

This is not too smart, in that you must stop playing all notes before you switch channels, or you will get hanging notes. The script will be smarter.....

For me, I use multi mode in kontakt, and then I can run 80+ instruments instead of just 16, and I can use regular patch change commands ;)

Statistics: Posted by woodslanding — 21 Feb 2010, 10:22


]]>
2010-02-21T10:59:43+02:00 2010-02-21T10:59:43+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11774#p11774 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
However, I did figure out how to transpose MIDI without affecting CC, complete with a fancy UI button, so I'm a little proud of myself for that. :)

But I've spent hours reading posts, checking out various MIDI addons, and basically trying to figure it out for myself, but I've had no such luck with MIDI remapping.

Here's what I'm trying to accomplish:
One of the VSTi I'm using is Kontakt, and rather than setting up multiple instances of the plugin, I want to load several samples into Kontakt that are set to various MIDI channels. To change sounds I want to be able to switch MIDI channels in Usine to play the respective samples.

I'd use my controller to change MIDI channels, but it wouldn't be as fast as pressing a button on the UI.

Statistics: Posted by Ben J — 21 Feb 2010, 09:59


]]>
BrainModular BrainModular Users Forum 2010-02-22T14:46:48+02:00 https://brainmodular.org/forums/app.php/feed/topic/1926 2010-02-22T14:46:48+02:00 2010-02-22T14:46:48+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11810#p11810 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
Take the code below, copy it into an empty script overwriting the existing text and run compile (ctrl-F9].

CODE:

&#40;*****************************************************************************************************Transpose.scriptScript for inserting into a MIDI stream to transpose all or just a part of the notes received.NoteOffs are mapped to the same channel and note number as the previous NoteOns, avoidinghanging notes even when changing parameters before the note is released.The input channel/note can be sent together with the transposed notes.Key/poly aftertouch can optionally also be transposed together with the notes.*****************************************************************************************************&#41;CONST BUFFER_SIZE = 128;// MIDI channel messagesCONST NOTEOFF = Byte&#40;128&#41;;CONST NOTEON  = Byte&#40;144&#41;;CONST KA      = Byte&#40;160&#41;; // Key &#40;poly&#41; AftertouchTYPE tMidiArr = ARRAY OF tMidi;TYPE tNoteOns = RECORD        origChannel &#58; Byte;        origNoteNo  &#58; Byte;        outChannel  &#58; Byte;        outNoteNo   &#58; Byte;        hasKA       &#58; Boolean;     END;////////////////////////////////////////////////////////////////////////////////////////// In-/out parametersVAR pMidiIn, pMidiOut1 &#58; tParameter;VAR pBypass, pChIn, pTrspLoLim, pTrspHiLim, pInclKA &#58; tParameter;VAR pChOut, pTranspose, pOctFoldBack, pKeep &#58; tParameter;// Global variablesVAR bypass, inclKA &#58; Boolean;VAR sentNoteOns &#58; ARRAY OF tNoteOns;VAR numIn, numSentNoteOns, numOut1 &#58; Integer;VAR chIn, trspLoLim, trspHiLim, chOut &#58; Byte;VAR transpose &#58; Integer;VAR octFoldback, keepOrig &#58; Boolean;////////////////////////////////////////////////////////////////////////////////////////PROCEDURE Init;   VAR i &#58; Integer;BEGIN   trspLoLim &#58;= 0;   trspHiLim &#58;= 127;   chIn &#58;= 0;   chOut &#58;= 0;   pMidiIn &#58;= CreateParam&#40;'midi in', ptMidi&#41;; SetIsOutput&#40;pMidiIn, FALSE&#41;;   pMidiOut1 &#58;= CreateParam&#40;'midi out', ptMidi&#41;; SetIsInput&#40;pMidiOut1, FALSE&#41;;   pBypass &#58;= CreateParam&#40;'bypass', ptSwitch&#41;; SetIsOutput&#40;pBypass, FALSE&#41;;   pChIn &#58;= CreateParam&#40;'channel in', ptListbox&#41;; SetIsOutput&#40;pChIn, FALSE&#41;;   SetListboxString&#40;pChIn, '"all","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"'&#41;;   SetValue&#40;pChIn, Single&#40;chIn&#41;&#41;;   pTrspLoLim &#58;= CreateParam&#40;'note lo limit', ptMidiNoteFader&#41;; SetIsOutput&#40;pTrspLoLim, FALSE&#41;;   SetDefaultValue&#40;pTrspLoLim, trspLoLim&#41;; SetValue&#40;pTrspLoLim, trspLoLim&#41;;   pTrspHiLim &#58;= CreateParam&#40;'note hi limit', ptMidiNoteFader&#41;; SetIsOutput&#40;pTrspHiLim, FALSE&#41;;   SetDefaultValue&#40;pTrspHiLim, trspHiLim&#41;; SetValue&#40;pTrspHiLim, trspHiLim&#41;;   pInclKA &#58;= CreateParam&#40;'incl KA', ptSwitch&#41;; SetIsOutput&#40;pInclKA, FALSE&#41;;      pChOut &#58;= CreateParam&#40;'channel out', ptListbox&#41;; SetIsOutput&#40;pChOut, FALSE&#41;;   SetListboxString&#40;pChOut, '"orig","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16"'&#41;;   SetValue&#40;pChOut, Single&#40;chOut&#41;&#41;;   pTranspose &#58;= CreateParam&#40;'transpose', ptDataFader&#41;; SetIsOutput&#40;pTranspose, FALSE&#41;;   SetMin&#40;pTranspose, -48&#41;; SetMax&#40;pTranspose, 48&#41;;   SetFormat&#40;pTranspose, '%.0f'&#41;; SetSymbol&#40;pTranspose, 'sm'&#41;;   pOctFoldback &#58;= CreateParam&#40;'oct foldback', ptSwitch&#41;; SetIsOutput&#40;pOctFoldback, FALSE&#41;;   pKeep &#58;= CreateParam&#40;'keep input', ptSwitch&#41;; SetIsOutput&#40;pKeep, FALSE&#41;;   SetArrayLength&#40;sentNoteOns, BUFFER_SIZE&#41;;   numSentNoteOns &#58;= 0;   numOut1 &#58;= 0;END; // Init/////////////////////////////////  Checking channel message types  /////////////////////////////////FUNCTION IsNote &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsNote &#58;= &#40;&#40;currMsg.msg = NOTEON&#41; OR &#40;currMsg.msg = NOTEOFF&#41;&#41;;END;FUNCTION IsNoteOn &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsNoteOn &#58;= &#40;&#40;currMsg.msg = NOTEON&#41; AND &#40;currMsg.data2 > 0&#41;&#41;;END;FUNCTION IsNoteOff &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsNoteOff &#58;= &#40;currMsg.msg = NOTEOFF&#41; OR &#40;&#40;currMsg.msg = NOTEON&#41; AND &#40;currMsg.data2 = 0&#41;&#41;;END;FUNCTION IsKA &#40;currMsg &#58; tMidi&#41; &#58; Boolean;BEGIN   IsKA &#58;= &#40;currMsg.msg = KA&#41;;END;////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE mTrace&#40;s &#58; String; m &#58; tMidi&#41;;BEGIN   WITH m DO       WriteLn&#40;s + '&#58; msg&#58;' + IntToStr&#40;msg&#41;                 + ' ch&#58;' + IntToStr&#40;channel&#41;                 + ' d1&#58;' + IntToStr&#40;data1&#41;                 + ' d2&#58;' + IntToStr&#40;data2&#41;&#41;;END; // mTrace////////////////////////////////////////////////////////////////////////////////////////////////////FUNCTION WithinRange&#40;value &#58; Byte&#41; &#58; Boolean;   VAR retVal &#58; Boolean;BEGIN   retVal &#58;= FALSE;   IF &#40;&#40;value >= trspLoLim&#41; AND &#40;value <= trspHiLim&#41;&#41; THEN BEGIN      retVal &#58;= TRUE;   END   ELSE IF &#40;value = trspLoLim&#41; OR &#40;value = trspHiLim&#41; THEN BEGIN      retVal &#58;= TRUE;   END   ELSE IF &#40;trspLoLim > trspHiLim&#41; THEN BEGIN      retVal &#58;= &#40;&#40;value < trspHiLim&#41; OR &#40;value > trspLoLim&#41;&#41;;   END;   WithinRange &#58;= retVal;END; // WithinRange////////////////////////////////////////////////////////////////////////////////////////////////////FUNCTION CalcTranspose&#40;NoteNo &#58; Byte&#41; &#58; Byte;   VAR note &#58; Integer; BEGIN   note &#58;= Integer&#40;NoteNo&#41; + transpose;   IF &#40;note < 0&#41; THEN BEGIN      IF &#40;NOT octFoldback&#41; THEN BEGIN         note &#58;= 0;      END      ELSE BEGIN         note &#58;= abs&#40;12 + note&#41; MOD 12;      END;   END   ELSE IF &#40;note > 127&#41; THEN BEGIN      IF &#40;NOT octFoldback&#41; THEN BEGIN         note &#58;= 127;      END      ELSE BEGIN        note &#58;= &#40;&#40;note - 128&#41; MOD 12&#41; + 116;      END;   END;   CalcTranspose &#58;= Byte&#40;note&#41;;END; // CalcTranspose////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CreateOut&#40;currMsg &#58; tMidi&#41;;BEGIN   SetMidiArrayValue&#40;pMidiOut1, numOut1, currMsg&#41;;   numOut1 &#58;= numOut1 + 1;END; // CreateOut////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CreateNoteOnOut&#40;origMsg, outMsg &#58; tMidi&#41;;   VAR curr &#58; tNoteOns;BEGIN   WITH curr DO BEGIN      origChannel &#58;= origMsg.channel;      origNoteNo  &#58;= origMsg.data1;      outChannel  &#58;= outMsg.channel;      outNoteNo   &#58;= outMsg.data1;      hasKA       &#58;= FALSE;   END;   sentNoteOns&#91;numSentNoteOns&#93; &#58;= curr;   numSentNoteOns &#58;= numSentNoteOns + 1;   CreateOut&#40;outMsg&#41;;END; // CreateNoteOnOut///////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CheckSendNoteOff&#40;currMsg &#58; tMidi&#41;;   VAR i, j &#58; Integer;   VAR outMsg &#58; tMidi;   VAR curr &#58; tNoteOns;   VAR found &#58; Boolean;BEGIN   j &#58;= 0;   found &#58;= FALSE;   FOR i &#58;= 0 TO &#40;numSentNoteOns - 1&#41; DO BEGIN      curr &#58;= sentNoteOns&#91;i&#93;;      IF &#40;&#40;currMsg.channel = curr.origChannel&#41; AND &#40;currMsg.data1 = curr.origNoteNo&#41;&#41; THEN BEGIN         outMsg.msg     &#58;= currMsg.msg;         outMsg.channel &#58;= curr.outChannel;         outMsg.data1   &#58;= curr.outNoteNo;         outMsg.data2   &#58;= currMsg.data2;         CreateOut&#40;outMsg&#41;;         IF &#40;curr.hasKA&#41; THEN BEGIN            outMsg.msg  &#58;= KA;            outMsg.data2 &#58;= 0;            CreateOut&#40;outMsg&#41;; // Resets any key aftertouch <> 0         END;         j &#58;= j + 1;         found &#58;= TRUE;      END      ELSE BEGIN         sentNoteOns&#91;i - j&#93; &#58;= curr;      END;   END;   numSentNoteOns &#58;= numSentNoteOns - j;   IF &#40;NOT found&#41; THEN CreateOut&#40;currMsg&#41;;END; // CheckSendNoteOff////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CheckSendKA&#40;currMsg &#58; tMidi&#41;;   VAR i &#58; Integer;   VAR outMsg &#58; tMidi;   VAR curr &#58; tNoteOns;BEGIN   FOR i &#58;= 0 TO &#40;numSentNoteOns - 1&#41; DO BEGIN      curr &#58;= sentNoteOns&#91;i&#93;;      IF &#40;&#40;currMsg.channel = curr.origChannel&#41; AND &#40;currMsg.data1 = curr.origNoteNo&#41;&#41; THEN BEGIN         outMsg.msg     &#58;= currMsg.msg;         outMsg.channel &#58;= curr.outChannel;         outMsg.data1   &#58;= curr.outNoteNo;         outMsg.data2   &#58;= currMsg.data2;         sentNoteOns&#91;i&#93;.hasKA &#58;= TRUE;         CreateOut&#40;outMsg&#41;;      END;   END;END; // CheckSendKA////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE CheckInput&#40;currMsg &#58; tMidi&#41;;   VAR newMsg &#58; tMidi;BEGIN   IF &#40;bypass AND IsNoteOn&#40;currMsg&#41;&#41; THEN BEGIN      CreateNoteOnOut&#40;currMsg, currMsg&#41;;   END   ELSE IF &#40;    &#40;NOT bypass&#41;             AND IsNoteOn&#40;currMsg&#41;            AND &#40;&#40;chIn = 0&#41; OR &#40;chIn = currMsg.channel&#41;&#41;            AND WithinRange&#40;currMsg.data1&#41;&#41; THEN BEGIN      newMsg &#58;= currMsg;      IF &#40;transpose <> 0&#41; THEN          newMsg.data1 &#58;= CalcTranspose&#40;newMsg.data1&#41;;      IF &#40;chOut <> 0&#41; THEN          newMsg.channel &#58;= chOut;      IF &#40;keepOrig AND &#40;&#40;currMsg.channel <> newMsg.channel&#41; OR &#40;currMsg.data1 <> newMsg.data1&#41;&#41;&#41; THEN         CreateNoteOnOut&#40;currMsg, currMsg&#41;;      CreateNoteOnOut&#40;currMsg, newMsg&#41;;   END   ELSE IF &#40;IsNoteOff&#40;currMsg&#41;&#41; THEN BEGIN      CheckSendNoteOff&#40;currMsg&#41;;   END   ELSE IF &#40;inclKA AND IsKA&#40;currMsg&#41;&#41; THEN BEGIN      CheckSendKA&#40;currMsg&#41;;   END   ELSE BEGIN      CreateOut&#40;currMsg&#41;;   END;END; // CheckInput////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE Callback&#40;n &#58; Integer&#41;;BEGIN   //strace&#40;'callback&#58; ' + IntToStr&#40;n&#41;&#41;;   CASE n OF      pMidiIn       &#58; numIn       &#58;= GetLength&#40;n&#41;;      pBypass       &#58; bypass      &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;      pChIn         &#58; chIn        &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pTrspLoLim    &#58; trspLoLim   &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pTrspHiLim    &#58; trspHiLim   &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pInclKA       &#58; inclKA      &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;      pChOut        &#58; chOut       &#58;= Byte&#40;trunc&#40;GetValue&#40;n&#41;&#41;&#41;;      pTranspose    &#58; transpose   &#58;= round&#40;GetValue&#40;n&#41;&#41;;      pOctFoldback  &#58; octFoldback &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;      pKeep         &#58; keepOrig    &#58;= &#40;GetValue&#40;n&#41; > 0&#41;;   END;END; // Callback////////////////////////////////////////////////////////////////////////////////////////////////////PROCEDURE Process;   VAR i &#58; Integer;   VAR currMsg &#58; tMidi;BEGIN   FOR i &#58;= 0 TO &#40;numIn - 1&#41; DO BEGIN      GetMidiArrayValue&#40;pMidiIn, i, currMsg&#41;;      CheckInput&#40;currMsg&#41;;   END;   SetLength&#40;pMidiOut1, numOut1&#41;;   numOut1 &#58;= 0;END; // Process
(Hope it's the right version - I'm away from home and haven't got time to check)

Statistics: Posted by bsork — 22 Feb 2010, 13:46


]]>
2010-02-22T12:42:18+02:00 2010-02-22T12:42:18+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11798#p11798 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
This is not too smart, in that you must stop playing all notes before you switch channels, or you will get hanging notes. The script will be smarter.....
if you put a 'has changed' triggering an 'all notes off' from the knob/fader you use to change channels you can get around this pretty easily. hope it helps... :)

Statistics: Posted by Clearscreen — 22 Feb 2010, 11:42


]]>
2010-02-22T05:18:17+02:00 2010-02-22T05:18:17+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11793#p11793 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]> Statistics: Posted by Ben J — 22 Feb 2010, 04:18


]]>
2010-02-21T16:26:01+02:00 2010-02-21T16:26:01+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11782#p11782 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]> http://www.niallmoody.com/ndcplugs/ndcmidi.htm
If you connect a slider or similar to the Midi channel inlet you can store it in the conductor.

Not saying that it isn't possible with Usine's own modules, it was just the quickest way I've found when being new to Usine and I keep it out of laziness. :)

Statistics: Posted by nofish — 21 Feb 2010, 15:26


]]>
2010-02-21T11:27:26+02:00 2010-02-21T11:27:26+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11776#p11776 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]> you can also use several midi transformer module...;-)

Statistics: Posted by nay-seven — 21 Feb 2010, 10:27


]]>
2010-02-21T11:22:39+02:00 2010-02-21T11:22:39+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11775#p11775 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
Take a midi input object, turn on 'unpack'. Plug message,code1,code2,and receive into the related inputs on a 'create midi message' module (receive goes to create)

Now drag a cable from the 'chan' input and create a combobox (or what have you) to change channel....

This is not too smart, in that you must stop playing all notes before you switch channels, or you will get hanging notes. The script will be smarter.....

For me, I use multi mode in kontakt, and then I can run 80+ instruments instead of just 16, and I can use regular patch change commands ;)

Statistics: Posted by woodslanding — 21 Feb 2010, 10:22


]]>
2010-02-21T10:59:43+02:00 2010-02-21T10:59:43+02:00 https://brainmodular.org/forums/viewtopic.php?t=1926&p=11774#p11774 <![CDATA[Remapping MIDI channels ( [1 to 2] [1 to 3],etc )]]>
However, I did figure out how to transpose MIDI without affecting CC, complete with a fancy UI button, so I'm a little proud of myself for that. :)

But I've spent hours reading posts, checking out various MIDI addons, and basically trying to figure it out for myself, but I've had no such luck with MIDI remapping.

Here's what I'm trying to accomplish:
One of the VSTi I'm using is Kontakt, and rather than setting up multiple instances of the plugin, I want to load several samples into Kontakt that are set to various MIDI channels. To change sounds I want to be able to switch MIDI channels in Usine to play the respective samples.

I'd use my controller to change MIDI channels, but it wouldn't be as fast as pressing a button on the UI.

Statistics: Posted by Ben J — 21 Feb 2010, 09:59


]]>