ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2009-03-31T11:38:45+02:00 https://brainmodular.org/forums/app.php/feed/topic/1449 2009-03-31T11:38:45+02:00 2009-03-31T11:38:45+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8096#p8096 <![CDATA[how to split midi channels?]]>
I don't think the script belongs in the add-ons section as long as the effiency and the ease of use is bad compared to a relatively simple module-based patch, but thanks for the nice words anyway. I think there are plenty of other scripts in the distro and the add-ons that are better examples of eg using MIDI data as indexex to arrays, or a boolean or three to avoid unneccessary executions.

Statistics: Posted by bsork — 31 Mar 2009, 11:38


]]>
2009-03-31T10:47:09+02:00 2009-03-31T10:47:09+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8095#p8095 <![CDATA[how to split midi channels?]]> would not have thought u could create and access ports (Tparameter) dynamically.
maybe i'll do a test like gurulogic to compare CPU and RAM usage of the brute-force and the clever way when i get home.

though the script isnt more efficient, i might use it, cause its more elegant, flexible and well arranged than the module version for my taste.
post as addon?

Statistics: Posted by amiga909 — 31 Mar 2009, 10:47


]]>
2009-03-31T10:03:43+02:00 2009-03-31T10:03:43+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8094#p8094 <![CDATA[how to split midi channels?]]>

CODE:

VAR pIn &#58; Tparameter;TYPE outArr = ARRAY of Tparameter;VAR pOut &#58; outArr;VAR tmp &#58; tMidi;VAR inLen, min, max, i, x &#58; INTEGER;VAR outLen &#58; ARRAY OF INTEGER;VAR updLen &#58; BOOLEAN;PROCEDURE init;BEGIN   pIn &#58;= CreateParam&#40;'midi in', ptMidi&#41;; SetIsOutput&#40;pIn, FALSE&#41;;   SetArrayLength&#40;pOut, 16&#41;;   SetArrayLength&#40;outlen, 16&#41;;      FOR i &#58;= 0 TO 15 DO BEGIN      pOut&#91;i&#93; &#58;= CreateParam&#40;'midi ch ' + IntToStr&#40;i + 1&#41;, ptMidi&#41;;      SetIsInput&#40;pOut&#91;i&#93;, FALSE&#41;;   END;   min &#58;= 16;   max &#58;= 0;   updLen &#58;= FALSE;END;PROCEDURE SetMinMax&#40;y &#58; integer&#41;;BEGIN   IF &#40;y < min&#41; THEN      min &#58;= y;   IF &#40;y > max&#41; THEN      max &#58;= y;END;// mainBEGIN   IF &#40;updLen&#41; THEN BEGIN      FOR i &#58;= min TO max DO BEGIN         IF &#40;OutLen&#91;i&#93; > 0&#41; THEN BEGIN            SetLength&#40;pOut&#91;i&#93;, 0&#41;;            OutLen&#91;i&#93; &#58;= 0;         END;      END;      min &#58;= 16;      max &#58;= 0;      updLen &#58;= FALSE;   END;   inLen &#58;= GetLength&#40;pIn&#41;;   IF &#40;inlen > 0&#41; THEN BEGIN      FOR i &#58;= 0 TO &#40;inLen - 1&#41; DO BEGIN         GetMidiArrayValue&#40;pIn, i, tmp&#41;;         IF &#40;tmp.msg <= 239&#41; THEN BEGIN            x &#58;= tmp.channel - 1;            SetMidiArrayValue&#40;pOut&#91;x&#93;, OutLen&#91;x&#93;, tmp&#41;;            OutLen&#91;x&#93; &#58;= OutLen&#91;x&#93; + 1;            SetMinMax&#40;x&#41;;            updLen &#58;= TRUE;         END;      END;      IF &#40;updLen&#41; THEN BEGIN         FOR i &#58;= min TO max DO BEGIN            IF &#40;OutLen&#91;i&#93; > 0&#41; THEN BEGIN               SetLength&#40;pOut&#91;i&#93;, OutLen&#91;i&#93;&#41;;            END;         END;      END;   END;END.
By using arrays, at least the code is smaller even if the results CPU-wise aren't much better than coding it the "hard way". Anyway, when doing MIDI scripts of various types, using the MIDI values themselves (channel, CC no, note no, etc) as indexes to arrays is often a good idea IMO. Depends on what the script is doing, of course.

Statistics: Posted by bsork — 31 Mar 2009, 10:03


]]>
2009-03-30T23:21:38+02:00 2009-03-30T23:21:38+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8085#p8085 <![CDATA[how to split midi channels?]]> Statistics: Posted by 23fx23 — 30 Mar 2009, 23:21


]]>
2009-03-30T23:06:17+02:00 2009-03-30T23:06:17+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8083#p8083 <![CDATA[how to split midi channels?]]>
in the end there is no way to beat mr. senso as it seems.. dont tell me he also walks on water, i might believe it ;)

EDIT: @23fx: for this case I would guess CPU load would not vary significantly if one puts a 'Patch Active' module: the modules to check if a patch should be set active would prolly consume more than an unused midi filter patch itself. as gurulogic pointed out, the only advantage might be less RAM usage.

Statistics: Posted by amiga909 — 30 Mar 2009, 23:06


]]>
2009-03-30T22:36:37+02:00 2009-03-30T22:36:37+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8080#p8080 <![CDATA[how to split midi channels?]]>

...and once the 16 ch filter patch is made... or should we maybe do 16 subpatchs that would be activated only on incoming stream to save CPu if chanels are not used, mm gonna try if it worth..?

just made me think CPu contests for things we all want could be ccol to find the best tech..

Statistics: Posted by 23fx23 — 30 Mar 2009, 22:36


]]>
2009-03-30T22:25:45+02:00 2009-03-30T22:25:45+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8079#p8079 <![CDATA[how to split midi channels?]]>

Statistics: Posted by bsork — 30 Mar 2009, 22:25


]]>
2009-03-30T13:09:16+02:00 2009-03-30T13:09:16+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8073#p8073 <![CDATA[how to split midi channels?]]>
I know a script version could be made more effective using a couple of tricks, but no matter how it's constructed, what is most effective will to some extent be dependent on the MIDI data.
I'd love to learn more about these tricks.
the only thing I could think of is rejecting message types like clock (or activesense or sysex) - which would save some wires in comparison to a module version. apart from that I really dont know?
waiting for ur answer, excited to learn :)

Statistics: Posted by amiga909 — 30 Mar 2009, 13:09


]]>
2009-03-30T09:19:47+02:00 2009-03-30T09:19:47+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8071#p8071 <![CDATA[how to split midi channels?]]>
I know a script version could be made more effective using a couple of tricks, but no matter how it's constructed, what is most effective will to some extent be dependent on the MIDI data. I'll see if I can find the time tonight to create and post an example that I think would work ok for a relatively dense MIDI stream.

Anyway, no matter how a script is written, I'm sure the module way of doing things would be better when the amount of MIDI data is moderate - especially if only a handful of MIDI channels are in use.

Statistics: Posted by bsork — 30 Mar 2009, 09:19


]]>
2009-03-30T00:35:52+02:00 2009-03-30T00:35:52+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8069#p8069 <![CDATA[how to split midi channels?]]> first your question:
scripts dont recreate modules. afaik its a completely different mechanism: modules are compiled, while scripts are interpreted, which means that the actual code for modules is bytecode that is only readable by a machine. script languages (like javascript) do not come up with such an optimized source code but a human readable source code can be executed directly which also means less efficiency.
please correct me if i am wrong.

btw, thanks for your kind words above 23fx23. but the script master here is bsork (except olivier of course). I didnt do much more than recreating his ideas by now (got some queer midi script stuff in the pipeline, maybe I'll be able to add something new sometimes, but i want to finish the easy stuff first...)

about script efficiency. maybe its valid to say that it is a bad idea to recreate stuff with scripts that can be done quite easily with modules. in our example we also need the same amount of wires: a script maybe would be more efficient if you would split channels but merging 2 channels to 1 (means: 1+2 > out1, 15+16 > out8, etc.). scripts can be more powerful if you would want to change the midi filter 'split by channel' param in realtime: if u change the channel while a note is still held u get a nasty hanging note. bsorks method would take care of that.

Statistics: Posted by amiga909 — 30 Mar 2009, 00:35


]]>
2009-03-30T00:09:32+02:00 2009-03-30T00:09:32+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8067#p8067 <![CDATA[how to split midi channels?]]> quite a good news for me if modules are as efficient as if they were called by the script..

Statistics: Posted by 23fx23 — 30 Mar 2009, 00:09


]]>
2009-03-30T00:01:57+02:00 2009-03-30T00:01:57+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8066#p8066 <![CDATA[how to split midi channels?]]> @guru: u were faster :)
yeah, its what I got too (didnt look at the MB usage)


here a test. usine modules vs. script.
first the mentioned no script version, then the script version with 2x2 chn, and 16x16 chn:
Image
Image

Image
Image

and here the patches if u want to try urself:
http://www.sensomusic.com/forums/upload ... script.pat
http://www.sensomusic.com/forums/upload ... script.pat


result:
dont know if this measurement method is reliable?
hmmm.. usine modules are NOT slower from what i got.
not-script version is clearly better if u have only a few channels. they are about the same if it comes to extensive splitting, non-script being rather faster.

kinda disappointing for me.. I wonder if my script could be made faster?
kinda trust enforcing for usine! usine is even better than we expect :)

Statistics: Posted by amiga909 — 30 Mar 2009, 00:01


]]>
2009-03-29T23:54:39+02:00 2009-03-29T23:54:39+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8065#p8065 <![CDATA[how to split midi channels?]]> In the interest of wasting time I made two patches. One with 20 instances of this script and the other with 20x 16 midi filters.
Both were fed 15 channels of 16 beats per bar midi. The midi filter example used about 30Mb and barely any cpu, the script example used about 8Mb and considerable more cpu. (including the vsti generating the midi , the filter patch cpu usage showed about 1.8%, the script patch about 8%)

I think I am best off sticking with multiple filters to split channels :-)

Statistics: Posted by gurulogic — 29 Mar 2009, 23:54


]]>
2009-03-29T23:25:39+02:00 2009-03-29T23:25:39+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8064#p8064 <![CDATA[how to split midi channels?]]> I so wish I could know usine script as you and bsork, but when you give us some we can try to understand a bit...

Statistics: Posted by 23fx23 — 29 Mar 2009, 23:25


]]>
2009-03-29T23:14:54+02:00 2009-03-29T23:14:54+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8063#p8063 <![CDATA[how to split midi channels?]]>
What do you mean exactly? Even though the MIDI channels are named 1 to 16, technically they're 0-15 AFAIK, if that's what you're referring to.
actually I have to apologize.
your excellent clearmidinotes and miditransposewithoctavefoldback run perfect. probably it was rather in one of my buggy attempts, sorry.


to explain what i meant:
from clearmidinotes.script:
GetMidiArrayValue(pIn, i, tmp);
writeln('tmpchan'+inttostr(tmp.channel));

=> if channel = 1: tmpchan: 1
=> if channel = 16: tmpchan: 16

and thats why u put this line before u throw the message in a 0..15 array:
x := tmp.channel - 1;

Statistics: Posted by amiga909 — 29 Mar 2009, 23:14


]]>
2009-03-29T22:47:40+02:00 2009-03-29T22:47:40+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8062#p8062 <![CDATA[how to split midi channels?]]> Statistics: Posted by bsork — 29 Mar 2009, 22:47


]]>
2009-03-29T09:39:02+02:00 2009-03-29T09:39:02+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8057#p8057 <![CDATA[how to split midi channels?]]>
corrected the script above and tested it with copy+paste the same piano roll and changing channels.
seems to work now.

have to check my other scripts for that issue too. thanks again :)

btw, in some of your scripts I found a bug with channel 16 messages (channel counts from 1-16, data from 0-127)

Statistics: Posted by amiga909 — 29 Mar 2009, 09:39


]]>
2009-03-28T11:43:54+02:00 2009-03-28T11:43:54+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8043#p8043 <![CDATA[how to split midi channels?]]> Statistics: Posted by bsork — 28 Mar 2009, 10:43


]]>
2009-03-28T10:28:19+02:00 2009-03-28T10:28:19+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8042#p8042 <![CDATA[how to split midi channels?]]> now we have to test...
its a very easy thingie, done in 10min.
easy, easy.....;-))

Statistics: Posted by nay-seven — 28 Mar 2009, 09:28


]]>
2009-03-28T09:52:27+02:00 2009-03-28T09:52:27+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8041#p8041 <![CDATA[how to split midi channels?]]>
CORRECTED:

CODE:

&#40;*/////////////////////////////////////////////////////// MEP_splitChn -  midi script module for sensomusic usine // version&#58; 2009-03-23 1.0; author&#58; amiga909//// <Description> // splits midi messages by channel // <Parameters> //  none// <Ports> // &#91;channel 1-16&#93;&#58;  //////////////////////////////////////////////////////*&#41;//////////////////////////////////////////////////////// globals//////////////////////////////////////////////////////VAR  pIn, pOut1, pOut2, pOut3, pOut4, pOut5, pOut6, pOut7, pOut8, pOut9, pOut10, pOut11, pOut12, pOut13, pOut14, pOut15, pOut16  &#58; TParameter; VAR  tmp      &#58; TMidi;   VAR  len, i, len1, len2, len3, len4, len5, len6, len7, len8, len9, len10, len11, len12, len13, len14, len15, len16     &#58; INTEGER;   //////////////////////////////////////////////////////// initialize//////////////////////////////////////////////////////PROCEDURE init;    BEGIN  pIn &#58;= createParam&#40;'in', ptMidi&#41;;  pOut1 &#58;= createParam&#40;'chn 1', ptMidi&#41;;  pOut2 &#58;= createParam&#40;'chn 2', ptMidi&#41;; pOut3 &#58;= createParam&#40;'chn 3', ptMidi&#41;; pOut4 &#58;= createParam&#40;'chn 4', ptMidi&#41;; pOut5 &#58;= createParam&#40;'chn 5', ptMidi&#41;; pOut6 &#58;= createParam&#40;'chn 6', ptMidi&#41;; pOut7 &#58;= createParam&#40;'chn 7', ptMidi&#41;; pOut8 &#58;= createParam&#40;'chn 8', ptMidi&#41;; pOut9 &#58;= createParam&#40;'chn 9', ptMidi&#41;; pOut10 &#58;= createParam&#40;'chn 10', ptMidi&#41;; pOut11 &#58;= createParam&#40;'chn 11', ptMidi&#41;; pOut12 &#58;= createParam&#40;'chn 12', ptMidi&#41;; pOut13 &#58;= createParam&#40;'chn 13', ptMidi&#41;; pOut14 &#58;= createParam&#40;'chn 14', ptMidi&#41;; pOut15 &#58;= createParam&#40;'chn 15', ptMidi&#41;; pOut16 &#58;= createParam&#40;'chn 16', ptMidi&#41;;  setIsInput&#40;pOut1,FALSE&#41;;setIsInput&#40;pOut2,FALSE&#41;;setIsInput&#40;pOut3,FALSE&#41;;setIsInput&#40;pOut4,FALSE&#41;;setIsInput&#40;pOut5,FALSE&#41;;setIsInput&#40;pOut6,FALSE&#41;;setIsInput&#40;pOut7,FALSE&#41;;setIsInput&#40;pOut8,FALSE&#41;;setIsInput&#40;pOut9,FALSE&#41;;setIsInput&#40;pOut10,FALSE&#41;;setIsInput&#40;pOut11,FALSE&#41;;setIsInput&#40;pOut12,FALSE&#41;;setIsInput&#40;pOut13,FALSE&#41;;setIsInput&#40;pOut14,FALSE&#41;;setIsInput&#40;pOut15,FALSE&#41;;setIsInput&#40;pOut16,FALSE&#41;;setIsOutput&#40;pIn,FALSE&#41;;END; ////////////////////////////////////////// main//////////////////////////////////////////////////////BEGIN    len &#58;= getLength&#40;pIn&#41;;   //writeln&#40;'len&#58; '+inttostr&#40;len&#41;&#41;;   IF len > 0 THEN BEGIN len1 &#58;= 0;len2 &#58;= 0;len3 &#58;= 0;len4 &#58;= 0;len5 &#58;= 0;len6 &#58;= 0;len7 &#58;= 0;len8 &#58;= 0;len9 &#58;= 0;len10 &#58;= 0;len11 &#58;= 0;len12 &#58;= 0;len13 &#58;= 0;len14 &#58;= 0;len15 &#58;= 0;len16 &#58;= 0;FOR i &#58;= 0 TO &#40;len - 1&#41; DO BEGIN  getMidiArrayValue&#40;pIn, i, tmp&#41;; IF &#40;tmp.channel = 1&#41; THEN BEGIN setMidiArrayValue&#40;pOut1, len1, tmp&#41;;   len1 &#58;= len1 +1; ENDELSE IF &#40;tmp.channel = 2&#41; THEN BEGIN  setMidiArrayValue&#40;pOut2, len2, tmp&#41;; len2 &#58;= len2 +1; END  ELSE IF &#40;tmp.channel = 3&#41; THEN BEGIN setMidiArrayValue&#40;pOut3, len3, tmp&#41;;  len3 &#58;= len3 +1; ENDELSE IF &#40;tmp.channel = 4&#41; THEN BEGIN setMidiArrayValue&#40;pOut4, len4, tmp&#41;; len4 &#58;= len4 +1; ENDELSE IF &#40;tmp.channel = 5&#41; THEN BEGIN setMidiArrayValue&#40;pOut5, len5, tmp&#41;; setLength&#40;pOut5,len5&#41;; len5 &#58;= len5 +1; ENDELSE IF &#40;tmp.channel = 6&#41; THEN BEGIN setMidiArrayValue&#40;pOut6, len6, tmp&#41;;  len6 &#58;= len6 +1; ENDELSE IF &#40;tmp.channel = 7&#41; THEN BEGIN setMidiArrayValue&#40;pOut7, len7, tmp&#41;;  len7 &#58;= len7 +1; ENDELSE IF &#40;tmp.channel = 8&#41; THEN BEGIN setMidiArrayValue&#40;pOut8, len8, tmp&#41;;  len8 &#58;= len8 +1; ENDELSE IF &#40;tmp.channel = 9&#41; THEN BEGIN setMidiArrayValue&#40;pOut9, len9, tmp&#41;;  len9 &#58;= len9 +1; ENDELSE IF &#40;tmp.channel = 10&#41; THEN BEGIN setMidiArrayValue&#40;pOut10, len10, tmp&#41;;  len10 &#58;= len10 +1; ENDELSE IF &#40;tmp.channel = 11&#41; THEN BEGIN setMidiArrayValue&#40;pOut11, len11, tmp&#41;;  len11 &#58;= len11 +1; ENDELSE IF &#40;tmp.channel = 12&#41; THEN BEGIN setMidiArrayValue&#40;pOut12, len12, tmp&#41;;  len12 &#58;= len12 +1; ENDELSE IF &#40;tmp.channel = 13&#41; THEN BEGIN setMidiArrayValue&#40;pOut13, len13, tmp&#41;;  len13 &#58;= len13 +1; ENDELSE IF &#40;tmp.channel = 14&#41; THEN BEGIN setMidiArrayValue&#40;pOut14, len14, tmp&#41;;  len14 &#58;= len14 +1; ENDELSE IF &#40;tmp.channel = 15&#41; THEN BEGIN setMidiArrayValue&#40;pOut15, len15, tmp&#41;;  len15 &#58;= len15 +1; ENDELSE IF &#40;tmp.channel = 16&#41; THEN BEGIN setMidiArrayValue&#40;pOut16, len16, tmp&#41;;  len16 &#58;= len16 +1; END; setLength&#40;pOut1,len1&#41;;  setLength&#40;pOut2,len2&#41;;setLength&#40;pOut3,len3&#41;;  setLength&#40;pOut4,len4&#41;;setLength&#40;pOut5,len5&#41;;  setLength&#40;pOut6,len6&#41;;setLength&#40;pOut7,len7&#41;;  setLength&#40;pOut8,len8&#41;;setLength&#40;pOut9,len9&#41;;  setLength&#40;pOut10,len10&#41;;setLength&#40;pOut11,len11&#41;;  setLength&#40;pOut12,len12&#41;;setLength&#40;pOut13,len13&#41;;  setLength&#40;pOut14,len14&#41;;setLength&#40;pOut15,len15&#41;;  setLength&#40;pOut16,len16&#41;;   END;      END   ELSE BEGIN  setLength&#40;pOut1, 0&#41;;setLength&#40;pOut2, 0&#41;;setLength&#40;pOut3, 0&#41;;setLength&#40;pOut4, 0&#41;;setLength&#40;pOut5, 0&#41;;setLength&#40;pOut6, 0&#41;;setLength&#40;pOut7, 0&#41;;setLength&#40;pOut8, 0&#41;;setLength&#40;pOut9, 0&#41;;setLength&#40;pOut10, 0&#41;;setLength&#40;pOut11, 0&#41;;setLength&#40;pOut12, 0&#41;;setLength&#40;pOut13, 0&#41;;setLength&#40;pOut14, 0&#41;;setLength&#40;pOut15, 0&#41;;setLength&#40;pOut16, 0&#41;;   END;   END.
and a picture:
Image

Statistics: Posted by amiga909 — 28 Mar 2009, 08:52


]]>
2009-03-28T09:34:10+02:00 2009-03-28T09:34:10+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8040#p8040 <![CDATA[how to split midi channels?]]> but don't count with me for a script...;-)

Statistics: Posted by nay-seven — 28 Mar 2009, 08:34


]]>
2009-03-28T01:15:00+02:00 2009-03-28T01:15:00+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8035#p8035 <![CDATA[how to split midi channels?]]> Statistics: Posted by gurulogic — 28 Mar 2009, 00:15


]]>
2009-03-27T21:27:30+02:00 2009-03-27T21:27:30+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8032#p8032 <![CDATA[how to split midi channels?]]>
i mean : you take 16 midi filter with data in and out and you save it as subpatch so you can re-use it when you need...?
don't think it more cpu eater than a script...?

Image

Statistics: Posted by nay-seven — 27 Mar 2009, 20:27


]]>
2009-03-27T19:17:38+02:00 2009-03-27T19:17:38+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8029#p8029 <![CDATA[how to split midi channels?]]> individual channels.
I assume scripting is the answer but scriptingt is currently way over my head so I am hoping there is an easier solution?

Statistics: Posted by gurulogic — 27 Mar 2009, 18:17


]]>
BrainModular BrainModular Users Forum 2009-03-31T11:38:45+02:00 https://brainmodular.org/forums/app.php/feed/topic/1449 2009-03-31T11:38:45+02:00 2009-03-31T11:38:45+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8096#p8096 <![CDATA[how to split midi channels?]]>
I don't think the script belongs in the add-ons section as long as the effiency and the ease of use is bad compared to a relatively simple module-based patch, but thanks for the nice words anyway. I think there are plenty of other scripts in the distro and the add-ons that are better examples of eg using MIDI data as indexex to arrays, or a boolean or three to avoid unneccessary executions.

Statistics: Posted by bsork — 31 Mar 2009, 11:38


]]>
2009-03-31T10:47:09+02:00 2009-03-31T10:47:09+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8095#p8095 <![CDATA[how to split midi channels?]]> would not have thought u could create and access ports (Tparameter) dynamically.
maybe i'll do a test like gurulogic to compare CPU and RAM usage of the brute-force and the clever way when i get home.

though the script isnt more efficient, i might use it, cause its more elegant, flexible and well arranged than the module version for my taste.
post as addon?

Statistics: Posted by amiga909 — 31 Mar 2009, 10:47


]]>
2009-03-31T10:03:43+02:00 2009-03-31T10:03:43+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8094#p8094 <![CDATA[how to split midi channels?]]>

CODE:

VAR pIn &#58; Tparameter;TYPE outArr = ARRAY of Tparameter;VAR pOut &#58; outArr;VAR tmp &#58; tMidi;VAR inLen, min, max, i, x &#58; INTEGER;VAR outLen &#58; ARRAY OF INTEGER;VAR updLen &#58; BOOLEAN;PROCEDURE init;BEGIN   pIn &#58;= CreateParam&#40;'midi in', ptMidi&#41;; SetIsOutput&#40;pIn, FALSE&#41;;   SetArrayLength&#40;pOut, 16&#41;;   SetArrayLength&#40;outlen, 16&#41;;      FOR i &#58;= 0 TO 15 DO BEGIN      pOut&#91;i&#93; &#58;= CreateParam&#40;'midi ch ' + IntToStr&#40;i + 1&#41;, ptMidi&#41;;      SetIsInput&#40;pOut&#91;i&#93;, FALSE&#41;;   END;   min &#58;= 16;   max &#58;= 0;   updLen &#58;= FALSE;END;PROCEDURE SetMinMax&#40;y &#58; integer&#41;;BEGIN   IF &#40;y < min&#41; THEN      min &#58;= y;   IF &#40;y > max&#41; THEN      max &#58;= y;END;// mainBEGIN   IF &#40;updLen&#41; THEN BEGIN      FOR i &#58;= min TO max DO BEGIN         IF &#40;OutLen&#91;i&#93; > 0&#41; THEN BEGIN            SetLength&#40;pOut&#91;i&#93;, 0&#41;;            OutLen&#91;i&#93; &#58;= 0;         END;      END;      min &#58;= 16;      max &#58;= 0;      updLen &#58;= FALSE;   END;   inLen &#58;= GetLength&#40;pIn&#41;;   IF &#40;inlen > 0&#41; THEN BEGIN      FOR i &#58;= 0 TO &#40;inLen - 1&#41; DO BEGIN         GetMidiArrayValue&#40;pIn, i, tmp&#41;;         IF &#40;tmp.msg <= 239&#41; THEN BEGIN            x &#58;= tmp.channel - 1;            SetMidiArrayValue&#40;pOut&#91;x&#93;, OutLen&#91;x&#93;, tmp&#41;;            OutLen&#91;x&#93; &#58;= OutLen&#91;x&#93; + 1;            SetMinMax&#40;x&#41;;            updLen &#58;= TRUE;         END;      END;      IF &#40;updLen&#41; THEN BEGIN         FOR i &#58;= min TO max DO BEGIN            IF &#40;OutLen&#91;i&#93; > 0&#41; THEN BEGIN               SetLength&#40;pOut&#91;i&#93;, OutLen&#91;i&#93;&#41;;            END;         END;      END;   END;END.
By using arrays, at least the code is smaller even if the results CPU-wise aren't much better than coding it the "hard way". Anyway, when doing MIDI scripts of various types, using the MIDI values themselves (channel, CC no, note no, etc) as indexes to arrays is often a good idea IMO. Depends on what the script is doing, of course.

Statistics: Posted by bsork — 31 Mar 2009, 10:03


]]>
2009-03-30T23:21:38+02:00 2009-03-30T23:21:38+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8085#p8085 <![CDATA[how to split midi channels?]]> Statistics: Posted by 23fx23 — 30 Mar 2009, 23:21


]]>
2009-03-30T23:06:17+02:00 2009-03-30T23:06:17+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8083#p8083 <![CDATA[how to split midi channels?]]>
in the end there is no way to beat mr. senso as it seems.. dont tell me he also walks on water, i might believe it ;)

EDIT: @23fx: for this case I would guess CPU load would not vary significantly if one puts a 'Patch Active' module: the modules to check if a patch should be set active would prolly consume more than an unused midi filter patch itself. as gurulogic pointed out, the only advantage might be less RAM usage.

Statistics: Posted by amiga909 — 30 Mar 2009, 23:06


]]>
2009-03-30T22:36:37+02:00 2009-03-30T22:36:37+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8080#p8080 <![CDATA[how to split midi channels?]]>

...and once the 16 ch filter patch is made... or should we maybe do 16 subpatchs that would be activated only on incoming stream to save CPu if chanels are not used, mm gonna try if it worth..?

just made me think CPu contests for things we all want could be ccol to find the best tech..

Statistics: Posted by 23fx23 — 30 Mar 2009, 22:36


]]>
2009-03-30T22:25:45+02:00 2009-03-30T22:25:45+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8079#p8079 <![CDATA[how to split midi channels?]]>

Statistics: Posted by bsork — 30 Mar 2009, 22:25


]]>
2009-03-30T13:09:16+02:00 2009-03-30T13:09:16+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8073#p8073 <![CDATA[how to split midi channels?]]>
I know a script version could be made more effective using a couple of tricks, but no matter how it's constructed, what is most effective will to some extent be dependent on the MIDI data.
I'd love to learn more about these tricks.
the only thing I could think of is rejecting message types like clock (or activesense or sysex) - which would save some wires in comparison to a module version. apart from that I really dont know?
waiting for ur answer, excited to learn :)

Statistics: Posted by amiga909 — 30 Mar 2009, 13:09


]]>
2009-03-30T09:19:47+02:00 2009-03-30T09:19:47+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8071#p8071 <![CDATA[how to split midi channels?]]>
I know a script version could be made more effective using a couple of tricks, but no matter how it's constructed, what is most effective will to some extent be dependent on the MIDI data. I'll see if I can find the time tonight to create and post an example that I think would work ok for a relatively dense MIDI stream.

Anyway, no matter how a script is written, I'm sure the module way of doing things would be better when the amount of MIDI data is moderate - especially if only a handful of MIDI channels are in use.

Statistics: Posted by bsork — 30 Mar 2009, 09:19


]]>
2009-03-30T00:35:52+02:00 2009-03-30T00:35:52+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8069#p8069 <![CDATA[how to split midi channels?]]> first your question:
scripts dont recreate modules. afaik its a completely different mechanism: modules are compiled, while scripts are interpreted, which means that the actual code for modules is bytecode that is only readable by a machine. script languages (like javascript) do not come up with such an optimized source code but a human readable source code can be executed directly which also means less efficiency.
please correct me if i am wrong.

btw, thanks for your kind words above 23fx23. but the script master here is bsork (except olivier of course). I didnt do much more than recreating his ideas by now (got some queer midi script stuff in the pipeline, maybe I'll be able to add something new sometimes, but i want to finish the easy stuff first...)

about script efficiency. maybe its valid to say that it is a bad idea to recreate stuff with scripts that can be done quite easily with modules. in our example we also need the same amount of wires: a script maybe would be more efficient if you would split channels but merging 2 channels to 1 (means: 1+2 > out1, 15+16 > out8, etc.). scripts can be more powerful if you would want to change the midi filter 'split by channel' param in realtime: if u change the channel while a note is still held u get a nasty hanging note. bsorks method would take care of that.

Statistics: Posted by amiga909 — 30 Mar 2009, 00:35


]]>
2009-03-30T00:09:32+02:00 2009-03-30T00:09:32+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8067#p8067 <![CDATA[how to split midi channels?]]> quite a good news for me if modules are as efficient as if they were called by the script..

Statistics: Posted by 23fx23 — 30 Mar 2009, 00:09


]]>
2009-03-30T00:01:57+02:00 2009-03-30T00:01:57+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8066#p8066 <![CDATA[how to split midi channels?]]> @guru: u were faster :)
yeah, its what I got too (didnt look at the MB usage)


here a test. usine modules vs. script.
first the mentioned no script version, then the script version with 2x2 chn, and 16x16 chn:
Image
Image

Image
Image

and here the patches if u want to try urself:
http://www.sensomusic.com/forums/upload ... script.pat
http://www.sensomusic.com/forums/upload ... script.pat


result:
dont know if this measurement method is reliable?
hmmm.. usine modules are NOT slower from what i got.
not-script version is clearly better if u have only a few channels. they are about the same if it comes to extensive splitting, non-script being rather faster.

kinda disappointing for me.. I wonder if my script could be made faster?
kinda trust enforcing for usine! usine is even better than we expect :)

Statistics: Posted by amiga909 — 30 Mar 2009, 00:01


]]>
2009-03-29T23:54:39+02:00 2009-03-29T23:54:39+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8065#p8065 <![CDATA[how to split midi channels?]]> In the interest of wasting time I made two patches. One with 20 instances of this script and the other with 20x 16 midi filters.
Both were fed 15 channels of 16 beats per bar midi. The midi filter example used about 30Mb and barely any cpu, the script example used about 8Mb and considerable more cpu. (including the vsti generating the midi , the filter patch cpu usage showed about 1.8%, the script patch about 8%)

I think I am best off sticking with multiple filters to split channels :-)

Statistics: Posted by gurulogic — 29 Mar 2009, 23:54


]]>
2009-03-29T23:25:39+02:00 2009-03-29T23:25:39+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8064#p8064 <![CDATA[how to split midi channels?]]> I so wish I could know usine script as you and bsork, but when you give us some we can try to understand a bit...

Statistics: Posted by 23fx23 — 29 Mar 2009, 23:25


]]>
2009-03-29T23:14:54+02:00 2009-03-29T23:14:54+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8063#p8063 <![CDATA[how to split midi channels?]]>
What do you mean exactly? Even though the MIDI channels are named 1 to 16, technically they're 0-15 AFAIK, if that's what you're referring to.
actually I have to apologize.
your excellent clearmidinotes and miditransposewithoctavefoldback run perfect. probably it was rather in one of my buggy attempts, sorry.


to explain what i meant:
from clearmidinotes.script:
GetMidiArrayValue(pIn, i, tmp);
writeln('tmpchan'+inttostr(tmp.channel));

=> if channel = 1: tmpchan: 1
=> if channel = 16: tmpchan: 16

and thats why u put this line before u throw the message in a 0..15 array:
x := tmp.channel - 1;

Statistics: Posted by amiga909 — 29 Mar 2009, 23:14


]]>
2009-03-29T22:47:40+02:00 2009-03-29T22:47:40+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8062#p8062 <![CDATA[how to split midi channels?]]> Statistics: Posted by bsork — 29 Mar 2009, 22:47


]]>
2009-03-29T09:39:02+02:00 2009-03-29T09:39:02+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8057#p8057 <![CDATA[how to split midi channels?]]>
corrected the script above and tested it with copy+paste the same piano roll and changing channels.
seems to work now.

have to check my other scripts for that issue too. thanks again :)

btw, in some of your scripts I found a bug with channel 16 messages (channel counts from 1-16, data from 0-127)

Statistics: Posted by amiga909 — 29 Mar 2009, 09:39


]]>
2009-03-28T11:43:54+02:00 2009-03-28T11:43:54+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8043#p8043 <![CDATA[how to split midi channels?]]> Statistics: Posted by bsork — 28 Mar 2009, 10:43


]]>
2009-03-28T10:28:19+02:00 2009-03-28T10:28:19+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8042#p8042 <![CDATA[how to split midi channels?]]> now we have to test...
its a very easy thingie, done in 10min.
easy, easy.....;-))

Statistics: Posted by nay-seven — 28 Mar 2009, 09:28


]]>
2009-03-28T09:52:27+02:00 2009-03-28T09:52:27+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8041#p8041 <![CDATA[how to split midi channels?]]>
CORRECTED:

CODE:

&#40;*/////////////////////////////////////////////////////// MEP_splitChn -  midi script module for sensomusic usine // version&#58; 2009-03-23 1.0; author&#58; amiga909//// <Description> // splits midi messages by channel // <Parameters> //  none// <Ports> // &#91;channel 1-16&#93;&#58;  //////////////////////////////////////////////////////*&#41;//////////////////////////////////////////////////////// globals//////////////////////////////////////////////////////VAR  pIn, pOut1, pOut2, pOut3, pOut4, pOut5, pOut6, pOut7, pOut8, pOut9, pOut10, pOut11, pOut12, pOut13, pOut14, pOut15, pOut16  &#58; TParameter; VAR  tmp      &#58; TMidi;   VAR  len, i, len1, len2, len3, len4, len5, len6, len7, len8, len9, len10, len11, len12, len13, len14, len15, len16     &#58; INTEGER;   //////////////////////////////////////////////////////// initialize//////////////////////////////////////////////////////PROCEDURE init;    BEGIN  pIn &#58;= createParam&#40;'in', ptMidi&#41;;  pOut1 &#58;= createParam&#40;'chn 1', ptMidi&#41;;  pOut2 &#58;= createParam&#40;'chn 2', ptMidi&#41;; pOut3 &#58;= createParam&#40;'chn 3', ptMidi&#41;; pOut4 &#58;= createParam&#40;'chn 4', ptMidi&#41;; pOut5 &#58;= createParam&#40;'chn 5', ptMidi&#41;; pOut6 &#58;= createParam&#40;'chn 6', ptMidi&#41;; pOut7 &#58;= createParam&#40;'chn 7', ptMidi&#41;; pOut8 &#58;= createParam&#40;'chn 8', ptMidi&#41;; pOut9 &#58;= createParam&#40;'chn 9', ptMidi&#41;; pOut10 &#58;= createParam&#40;'chn 10', ptMidi&#41;; pOut11 &#58;= createParam&#40;'chn 11', ptMidi&#41;; pOut12 &#58;= createParam&#40;'chn 12', ptMidi&#41;; pOut13 &#58;= createParam&#40;'chn 13', ptMidi&#41;; pOut14 &#58;= createParam&#40;'chn 14', ptMidi&#41;; pOut15 &#58;= createParam&#40;'chn 15', ptMidi&#41;; pOut16 &#58;= createParam&#40;'chn 16', ptMidi&#41;;  setIsInput&#40;pOut1,FALSE&#41;;setIsInput&#40;pOut2,FALSE&#41;;setIsInput&#40;pOut3,FALSE&#41;;setIsInput&#40;pOut4,FALSE&#41;;setIsInput&#40;pOut5,FALSE&#41;;setIsInput&#40;pOut6,FALSE&#41;;setIsInput&#40;pOut7,FALSE&#41;;setIsInput&#40;pOut8,FALSE&#41;;setIsInput&#40;pOut9,FALSE&#41;;setIsInput&#40;pOut10,FALSE&#41;;setIsInput&#40;pOut11,FALSE&#41;;setIsInput&#40;pOut12,FALSE&#41;;setIsInput&#40;pOut13,FALSE&#41;;setIsInput&#40;pOut14,FALSE&#41;;setIsInput&#40;pOut15,FALSE&#41;;setIsInput&#40;pOut16,FALSE&#41;;setIsOutput&#40;pIn,FALSE&#41;;END; ////////////////////////////////////////// main//////////////////////////////////////////////////////BEGIN    len &#58;= getLength&#40;pIn&#41;;   //writeln&#40;'len&#58; '+inttostr&#40;len&#41;&#41;;   IF len > 0 THEN BEGIN len1 &#58;= 0;len2 &#58;= 0;len3 &#58;= 0;len4 &#58;= 0;len5 &#58;= 0;len6 &#58;= 0;len7 &#58;= 0;len8 &#58;= 0;len9 &#58;= 0;len10 &#58;= 0;len11 &#58;= 0;len12 &#58;= 0;len13 &#58;= 0;len14 &#58;= 0;len15 &#58;= 0;len16 &#58;= 0;FOR i &#58;= 0 TO &#40;len - 1&#41; DO BEGIN  getMidiArrayValue&#40;pIn, i, tmp&#41;; IF &#40;tmp.channel = 1&#41; THEN BEGIN setMidiArrayValue&#40;pOut1, len1, tmp&#41;;   len1 &#58;= len1 +1; ENDELSE IF &#40;tmp.channel = 2&#41; THEN BEGIN  setMidiArrayValue&#40;pOut2, len2, tmp&#41;; len2 &#58;= len2 +1; END  ELSE IF &#40;tmp.channel = 3&#41; THEN BEGIN setMidiArrayValue&#40;pOut3, len3, tmp&#41;;  len3 &#58;= len3 +1; ENDELSE IF &#40;tmp.channel = 4&#41; THEN BEGIN setMidiArrayValue&#40;pOut4, len4, tmp&#41;; len4 &#58;= len4 +1; ENDELSE IF &#40;tmp.channel = 5&#41; THEN BEGIN setMidiArrayValue&#40;pOut5, len5, tmp&#41;; setLength&#40;pOut5,len5&#41;; len5 &#58;= len5 +1; ENDELSE IF &#40;tmp.channel = 6&#41; THEN BEGIN setMidiArrayValue&#40;pOut6, len6, tmp&#41;;  len6 &#58;= len6 +1; ENDELSE IF &#40;tmp.channel = 7&#41; THEN BEGIN setMidiArrayValue&#40;pOut7, len7, tmp&#41;;  len7 &#58;= len7 +1; ENDELSE IF &#40;tmp.channel = 8&#41; THEN BEGIN setMidiArrayValue&#40;pOut8, len8, tmp&#41;;  len8 &#58;= len8 +1; ENDELSE IF &#40;tmp.channel = 9&#41; THEN BEGIN setMidiArrayValue&#40;pOut9, len9, tmp&#41;;  len9 &#58;= len9 +1; ENDELSE IF &#40;tmp.channel = 10&#41; THEN BEGIN setMidiArrayValue&#40;pOut10, len10, tmp&#41;;  len10 &#58;= len10 +1; ENDELSE IF &#40;tmp.channel = 11&#41; THEN BEGIN setMidiArrayValue&#40;pOut11, len11, tmp&#41;;  len11 &#58;= len11 +1; ENDELSE IF &#40;tmp.channel = 12&#41; THEN BEGIN setMidiArrayValue&#40;pOut12, len12, tmp&#41;;  len12 &#58;= len12 +1; ENDELSE IF &#40;tmp.channel = 13&#41; THEN BEGIN setMidiArrayValue&#40;pOut13, len13, tmp&#41;;  len13 &#58;= len13 +1; ENDELSE IF &#40;tmp.channel = 14&#41; THEN BEGIN setMidiArrayValue&#40;pOut14, len14, tmp&#41;;  len14 &#58;= len14 +1; ENDELSE IF &#40;tmp.channel = 15&#41; THEN BEGIN setMidiArrayValue&#40;pOut15, len15, tmp&#41;;  len15 &#58;= len15 +1; ENDELSE IF &#40;tmp.channel = 16&#41; THEN BEGIN setMidiArrayValue&#40;pOut16, len16, tmp&#41;;  len16 &#58;= len16 +1; END; setLength&#40;pOut1,len1&#41;;  setLength&#40;pOut2,len2&#41;;setLength&#40;pOut3,len3&#41;;  setLength&#40;pOut4,len4&#41;;setLength&#40;pOut5,len5&#41;;  setLength&#40;pOut6,len6&#41;;setLength&#40;pOut7,len7&#41;;  setLength&#40;pOut8,len8&#41;;setLength&#40;pOut9,len9&#41;;  setLength&#40;pOut10,len10&#41;;setLength&#40;pOut11,len11&#41;;  setLength&#40;pOut12,len12&#41;;setLength&#40;pOut13,len13&#41;;  setLength&#40;pOut14,len14&#41;;setLength&#40;pOut15,len15&#41;;  setLength&#40;pOut16,len16&#41;;   END;      END   ELSE BEGIN  setLength&#40;pOut1, 0&#41;;setLength&#40;pOut2, 0&#41;;setLength&#40;pOut3, 0&#41;;setLength&#40;pOut4, 0&#41;;setLength&#40;pOut5, 0&#41;;setLength&#40;pOut6, 0&#41;;setLength&#40;pOut7, 0&#41;;setLength&#40;pOut8, 0&#41;;setLength&#40;pOut9, 0&#41;;setLength&#40;pOut10, 0&#41;;setLength&#40;pOut11, 0&#41;;setLength&#40;pOut12, 0&#41;;setLength&#40;pOut13, 0&#41;;setLength&#40;pOut14, 0&#41;;setLength&#40;pOut15, 0&#41;;setLength&#40;pOut16, 0&#41;;   END;   END.
and a picture:
Image

Statistics: Posted by amiga909 — 28 Mar 2009, 08:52


]]>
2009-03-28T09:34:10+02:00 2009-03-28T09:34:10+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8040#p8040 <![CDATA[how to split midi channels?]]> but don't count with me for a script...;-)

Statistics: Posted by nay-seven — 28 Mar 2009, 08:34


]]>
2009-03-28T01:15:00+02:00 2009-03-28T01:15:00+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8035#p8035 <![CDATA[how to split midi channels?]]> Statistics: Posted by gurulogic — 28 Mar 2009, 00:15


]]>
2009-03-27T21:27:30+02:00 2009-03-27T21:27:30+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8032#p8032 <![CDATA[how to split midi channels?]]>
i mean : you take 16 midi filter with data in and out and you save it as subpatch so you can re-use it when you need...?
don't think it more cpu eater than a script...?

Image

Statistics: Posted by nay-seven — 27 Mar 2009, 20:27


]]>
2009-03-27T19:17:38+02:00 2009-03-27T19:17:38+02:00 https://brainmodular.org/forums/viewtopic.php?t=1449&p=8029#p8029 <![CDATA[how to split midi channels?]]> individual channels.
I assume scripting is the answer but scriptingt is currently way over my head so I am hoping there is an easier solution?

Statistics: Posted by gurulogic — 27 Mar 2009, 18:17


]]>