ArrayArrayArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2008-12-06T12:21:53+02:00 https://brainmodular.org/forums/app.php/feed/topic/1195 2008-12-06T12:21:53+02:00 2008-12-06T12:21:53+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6511#p6511 <![CDATA[scripts--midi output array size question]]>
fascinating idea, keep on :)

Statistics: Posted by amiga909 — 06 Dec 2008, 11:21


]]>
2008-12-06T06:37:04+02:00 2008-12-06T06:37:04+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6508#p6508 <![CDATA[scripts--midi output array size question]]>
That said, I'm now wondering if I should be using midi at all.... what about vsts with more than 127 parameters? Maybe I should be doing most of this with OSC instead. I mean, data comes in through USB via midi, so my thought is to keep it there. But... I only have 16 ot 32 midi control sources, and I may have hundreds of destinations.... but I'm not at all sure how OSC maps to VST parameters.

And anyway, maybe Oliver is figuring out a much better way to address this issue, right now!

This may all just be a learning experience for all I know. Getting me up to speed on Pascal, FI! (I'd rather be getting up to
speed on C++ though!) And this may all be supplanted by features in 4.1 anyway....

Just so you know where I stand, here is the script as it exists:

CODE:

&#40;*Requires an input file in the form&#58;1$modwh7$volume11$expression112$osc2PWetc.... haven't figured out how to read tabs yet.  I alphabetize them in excel first.... the scriptdoesn't care what order they're in.inputs--2 text inputs for directory and file &#40;directory should come from buss if a bunch of theseare being used in the workspace, for portability.&#41;Each set of ins and outs should be hooked up to one fader and one switch&#58;The fader's value controls the line of the input file--cable it to 'vstParam'The fader should not display its 'fader' element, as the line of the file isn't important data to the user. The fader's 'caption' is controlled by the 'name' output, and shows the name of the selected parameter.So it's basically being used like a one-element list, or a text fader.The 'switch' output should be cabled to the 'enable' input.  hey that's easy!The 'value' output should be cabled to the switch's 'caption'.  Now the switch shows the midiinput value, in the range 0 to 99, or '--' if the control is not enabled.The 'valHUE' output goes to the switch's 'color'.Finally, connect a midi knob to the midi input, and make sure the 'ccNum' input matches what theknob sends.... viola--pretty colors, and instant reassignment by name to any parameter of your VST.*&#41;type midiCC = Record    name   &#58; string;    number &#58; integer;end;var st          &#58; TStringList;var line        &#58; string;var delimiter   &#58; string;var position    &#58; integer;var i           &#58; integer;var chCount     &#58; integer;var ccCount     &#58; integer;var count       &#58; string;var controls    &#58; array of  midiCC;var name          &#58; string;var number        &#58; integer;var filename    &#58; string;var dirPath     &#58; string;var fileIn      &#58; Tparameter;   // file namevar dirIn       &#58; Tparameter;   // directory addressvar midiIn      &#58; Tparameter;   // midi INvar parCountOUT &#58; Tparameter;   // length of parameterListvar midiOut     &#58; Tparameter;   // midi outputvar enableIN        &#58; Array of Tparameter;   // enable controlvar ccnumberIN      &#58; Array of Tparameter;var vstParamIN      &#58; Array of Tparameter;var captionOUT      &#58; Array of Tparameter;var valHueOUT      &#58; Array of Tparameter;var valueOUT        &#58; Array of Tparameter;var enabled         &#58; Array of boolean;var inputCCs        &#58; Array of integer;  //these are the input CC#s to look for a matchvar parameterOuts   &#58; Array of integer;  //this is the key to get the output param#var interval        &#58; integer;var cycle           &#58; integer;var parameterIndex  &#58; integer;//var key             &#58; integer;var first           &#58; boolean;var midi           &#58; TMidi;var msgCount       &#58; integer;var msgNumber      &#58; integer;var current        &#58; integer;//var control        &#58; integer;var red            &#58; integer;var green          &#58; integer;var blue           &#58; integer;// initialisation &#58; create parametersprocedure init;begin      chCount &#58;= 4;    cycle &#58;= 0;    interval &#58;= 64;    first &#58;= TRUE;    fileIn      &#58;= CreateParam&#40;'fileName',ptTextField&#41;;     SetIsOutput&#40;fileIn,false&#41;;    setStringValue&#40;fileIn, 'pro5CCs.txt'&#41;;     dirIn       &#58;= CreateParam&#40;'dirPath',ptTextField&#41;;      SetIsOutput&#40;dirIn,false&#41;;    setStringValue&#40;dirIn, 'c&#58;usinedata'&#41;;    midiIn &#58;= CreateParam&#40;'MIDIin',ptMidi&#41;;                 SetIsOutput&#40;midiIn,false&#41;;     midiOut &#58;= CreateParam&#40;'MIDIout',ptMidi&#41;;               SetIsInput&#40;midiOut,false&#41;;        parCountOUT  &#58;= CreateParam&#40;'ccCount', ptdataField&#41;;    SetIsInput&#40;parCountOUT,false&#41;;    setDefaultValue&#40;parCountOUT, 127&#41;;           // set array lengths    SetArrayLength&#40;ccNumberIN, chCount&#41;;    SetArrayLength&#40;enableIN, chCount&#41;;    SetArrayLength&#40;vstParamIN, chCount&#41;;    //SetArrayLength&#40;ctrlTypeIN, chCount&#41;;    SetArrayLength&#40;enableIN, chCount&#41;;    SetArrayLength&#40;captionOUT, chCount&#41;;    SetArrayLength&#40;valueOUT, chCount&#41;;    SetArrayLength&#40;valHueOUT, chCount&#41;;           SetArrayLength&#40;enabled, chCount&#41;;     SetArrayLength&#40;inputCCs, chCount&#41;;    SetArrayLength&#40;parameterOuts, chCount&#41;;            // create channels     for i &#58;= 0 to &#40;chCount - 1&#41; do begin                count &#58;= IntToStr&#40;i+1&#41;;                // chCount        ccNumberIN&#91;i&#93;&#58;= CreateParam&#40;'ccNum' + count, ptdataField&#41;;        setMax&#40;ccNumberIN&#91;i&#93;, 127&#41;;        setMin&#40;ccNumberIN&#91;i&#93;, 0&#41;;        SetFormat&#40;ccNumberIN&#91;i&#93;,'%.0f'&#41;;        SetIsOutput&#40;ccNumberIN&#91;i&#93;, false&#41;;                enableIN&#91;i&#93; &#58;= CreateParam&#40;'enable' + count, ptSwitch&#41;;                     SetIsOutput&#40;enableIN&#91;i&#93;,false&#41;;            vstParamIN&#91;i&#93; &#58;= CreateParam&#40;'vstParam'+ count, ptdataFader&#41;;        SetIsOutput&#40;vstParamIN&#91;i&#93;, false&#41;;        setMax&#40;vstParamIN&#91;i&#93;, 127&#41;;        setMin&#40;vstParamIN&#91;i&#93;, 0&#41;;        SetFormat&#40;vstParamIN&#91;i&#93;,'%.0f'&#41;;        // outs        captionOUT&#91;i&#93; &#58;= CreateParam&#40;'name' + count, ptTextField&#41;;        SetIsInput&#40;captionOut&#91;i&#93;, false&#41;;                // use for text of enable switch        valueOUT&#91;i&#93; &#58;= CreateParam&#40;'value' + count, ptTextField&#41;;        // use for background of parameter fader        valHueOUT&#91;i&#93; &#58;= CreateParam&#40;'valHUE' + count, ptDataField&#41;;                SetIsInput&#40;valueOUT&#91;i&#93;, false&#41;;        SetIsInput&#40;valHueOUT&#91;i&#93;, false&#41;;    end;    end;function midiDecStr&#40;val &#58; integer&#41; &#58; string;begin    result &#58;= intToStr&#40;trunc&#40;&#40;val * 100/128&#41;&#41;&#41;;end;function boolToStr&#40;isOn &#58; boolean&#41; &#58; string;begin    if isOn then    begin        result &#58;= 'ON';    end    else    begin        result &#58;= '--';    end;end;function singleToBool&#40;val &#58; single&#41; &#58; boolean ;begin    if val = 0 then    begin        result &#58;= FALSE;    end    else    begin        result &#58;= TRUE;    end;end;function midiToColor&#40;midiVal &#58; integer&#41;&#58; integer;begin    midiVal &#58;= &#40;midiVal * 2&#41;;    red &#58;= midiVal;    if &#40;midiVal > 128&#41; then    begin        green &#58;= &#40;256 - midival&#41; * 2;    end else    begin        green &#58;= midival * 2;    end;    blue &#58;= 256 - midiVal;    midiVal&#58;= red + &#40;green * 256&#41; + &#40;blue * 256 * 256&#41;;    writeln&#40;'rgb = ' + intToStr&#40;red&#41; + ', ' + intToStr&#40;green&#41; + ', ' + intToStr&#40;blue&#41;&#41;;    result &#58;= midiVal;end;    procedure processCCs; // here we figure out if it's a cc# that we want to process....begin    current &#58;= midi.data1;    writeln&#40;'control ' + intToStr&#40;i&#41; + '  ' + intToStr&#40;inputCCs&#91;i&#93;&#41;&#41;;    if &#40;current = inputCCs&#91;i&#93;&#41; then        begin        midi.data1 &#58;= parameterOuts&#91;i&#93;;           SetMidiArrayValue&#40;midiOUT, msgNumber, midi&#41;;        SetStringValue&#40;valueOUT&#91;i&#93;, midiDecStr&#40;midi.data2&#41;&#41;;        SetValue&#40;valHueOUT&#91;i&#93;, midiToColor&#40;midi.data2&#41;&#41;;            end;end;procedure loadCCs;  // a post-init method to load the filebegin    filename  &#58;= getStringValue&#40;fileIn&#41;;    dirPath  &#58;= getStringValue&#40;dirIn&#41;;    delimiter &#58;= '$';    st &#58;= TStringList.create;    st.clear;    st.loadfromFile&#40;dirPath + '' + filename&#41;;        ccCount &#58;= st.count;    setArrayLength&#40;controls, ccCount&#41;;    setValue&#40;parCountOUT, ccCount - 1&#41;;    for i &#58;= 0 to &#40;st.count-1&#41; do    begin            line &#58;= st.strings&#91;i&#93;;        position &#58;= pos&#40;delimiter, line&#41;;                        name &#58;= copy&#40;line, position + 1, length&#40;line&#41;&#41;;        number &#58;= strtoInt&#40;copy&#40;line, 0, position - 1&#41;&#41;;        controls&#91;i&#93;.name &#58;= name;        controls&#91;i&#93;.number &#58;= number;        writeln&#40;controls&#91;0&#93;.name + ' ' + intToStr&#40;controls&#91;0&#93;.number&#41;&#41;;    end;     st.free;end;//////////////////////////////// main procbegin        if first then    begin        loadCCs;        first &#58;= false;    end;        cycle &#58;= &#40;cycle + 1&#41; MOD 2000;        IF &#40;&#40;cycle MOD interval&#41; = 0&#41; THEN    begin        for i &#58;= 0 to &#40;chCount - 1&#41; do        begin                          parameterIndex &#58;= trunc&#40;getValue&#40;vstParamIN&#91;i&#93;&#41;&#41;; // this is the key for the param map            parameterOUts&#91;i&#93; &#58;= controls&#91;parameterIndex&#93;.number;  // these are the output parameter #s            setStringValue&#40;captionOUT&#91;i&#93;, controls&#91;parameterIndex&#93;.name&#41;; // set the string outs            enabled&#91;i&#93; &#58;= singleToBool&#40;getValue&#40;enableIn&#91;i&#93;&#41;&#41;;            inputCCs&#91;i&#93; &#58;= trunc&#40;getValue&#40;ccNumberIN&#91;i&#93;&#41;&#41;;                if &#40;enabled&#91;i&#93; = FALSE&#41; then            begin                setStringValue&#40;valueOUT&#91;i&#93;,'--'&#41;;            end;                   end;           end;            msgCount &#58;= GetLength&#40;midiIN&#41;;  // get the number of incoming midi codes     SetLength&#40;midiOut, msgCount&#41;;    if msgCount > 0 then     begin        for msgNumber &#58;= 0 to msgCount-1 do        begin             GetMidiArrayValue&#40;midiIN, msgNumber, midi&#41;;            for i &#58;= 0 to &#40;chCount - 1&#41; do            begin                if &#40;midi.msg = 176&#41; and &#40;enabled&#91;i&#93;&#41;                then                begin                    processCCs;                end                else            end;        end;    end        // no midi in this block....    ELSE BEGIN        SetLength&#40;midiOut, 0&#41;;    END;end.
cheers!
-eric

Statistics: Posted by woodslanding — 06 Dec 2008, 05:37


]]>
2008-12-05T00:04:35+02:00 2008-12-05T00:04:35+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6485#p6485 <![CDATA[scripts--midi output array size question]]>
I assume I don't need to worry if I don't fill up the output array--if I filter some messages, I don't need to create 'dummy' messages for the output array do I?
No - just add the MIDI messages you want and set the size when you're through. I'm pretty sure that the maximum length is 512 messages per execution block/array though, but you would have to create a really OTT patch to have problems with that limit. That said, I do have a feeling that your MIDI patches are bigger and more complex than most of us would ever dream of creating.... :)

Looking forward to to have a look at the ideas and solutions you've come up with!

Statistics: Posted by bsork — 04 Dec 2008, 23:04


]]>
2008-12-04T19:49:03+02:00 2008-12-04T19:49:03+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6477#p6477 <![CDATA[scripts--midi output array size question]]>
I assume I don't need to worry if I don't fill up the output array--if I filter some messages, I don't need to create 'dummy' messages for the output array do I?

I have my module working now. After some testing, I'll upload to the user section. Then you can tell me how to make it twice as efficient ;)

-e

Statistics: Posted by woodslanding — 04 Dec 2008, 18:49


]]>
2008-12-04T09:53:09+02:00 2008-12-04T09:53:09+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6466#p6466 <![CDATA[scripts--midi output array size question]]> Statistics: Posted by bsork — 04 Dec 2008, 08:53


]]>
2008-12-04T00:55:35+02:00 2008-12-04T00:55:35+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6459#p6459 <![CDATA[scripts--midi output array size question]]>
Thanks!
-e

Statistics: Posted by woodslanding — 03 Dec 2008, 23:55


]]>
2008-12-04T00:14:10+02:00 2008-12-04T00:14:10+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6456#p6456 <![CDATA[scripts--midi output array size question]]>
Just use a counter when populating the output array, and set the size after filling it. Remember that the size is the last index number + 1. It may seem a bit weird that you can enter values in the array even beyond the existing size, but you can. You can see examples of that in a lot of the MIDI scripts in Usine.

And if you think it's confusing, I can tell you that I more than once have had to check that this really is the way it's being done...

Statistics: Posted by bsork — 03 Dec 2008, 23:14


]]>
2008-12-03T21:10:14+02:00 2008-12-03T21:10:14+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6451#p6451 <![CDATA[scripts--midi output array size question]]>
Or is this not really possible?

Thanks as ever!
-eric

Statistics: Posted by woodslanding — 03 Dec 2008, 20:10


]]>
BrainModular BrainModular Users Forum 2008-12-06T12:21:53+02:00 https://brainmodular.org/forums/app.php/feed/topic/1195 2008-12-06T12:21:53+02:00 2008-12-06T12:21:53+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6511#p6511 <![CDATA[scripts--midi output array size question]]>
fascinating idea, keep on :)

Statistics: Posted by amiga909 — 06 Dec 2008, 11:21


]]>
2008-12-06T06:37:04+02:00 2008-12-06T06:37:04+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6508#p6508 <![CDATA[scripts--midi output array size question]]>
That said, I'm now wondering if I should be using midi at all.... what about vsts with more than 127 parameters? Maybe I should be doing most of this with OSC instead. I mean, data comes in through USB via midi, so my thought is to keep it there. But... I only have 16 ot 32 midi control sources, and I may have hundreds of destinations.... but I'm not at all sure how OSC maps to VST parameters.

And anyway, maybe Oliver is figuring out a much better way to address this issue, right now!

This may all just be a learning experience for all I know. Getting me up to speed on Pascal, FI! (I'd rather be getting up to
speed on C++ though!) And this may all be supplanted by features in 4.1 anyway....

Just so you know where I stand, here is the script as it exists:

CODE:

&#40;*Requires an input file in the form&#58;1$modwh7$volume11$expression112$osc2PWetc.... haven't figured out how to read tabs yet.  I alphabetize them in excel first.... the scriptdoesn't care what order they're in.inputs--2 text inputs for directory and file &#40;directory should come from buss if a bunch of theseare being used in the workspace, for portability.&#41;Each set of ins and outs should be hooked up to one fader and one switch&#58;The fader's value controls the line of the input file--cable it to 'vstParam'The fader should not display its 'fader' element, as the line of the file isn't important data to the user. The fader's 'caption' is controlled by the 'name' output, and shows the name of the selected parameter.So it's basically being used like a one-element list, or a text fader.The 'switch' output should be cabled to the 'enable' input.  hey that's easy!The 'value' output should be cabled to the switch's 'caption'.  Now the switch shows the midiinput value, in the range 0 to 99, or '--' if the control is not enabled.The 'valHUE' output goes to the switch's 'color'.Finally, connect a midi knob to the midi input, and make sure the 'ccNum' input matches what theknob sends.... viola--pretty colors, and instant reassignment by name to any parameter of your VST.*&#41;type midiCC = Record    name   &#58; string;    number &#58; integer;end;var st          &#58; TStringList;var line        &#58; string;var delimiter   &#58; string;var position    &#58; integer;var i           &#58; integer;var chCount     &#58; integer;var ccCount     &#58; integer;var count       &#58; string;var controls    &#58; array of  midiCC;var name          &#58; string;var number        &#58; integer;var filename    &#58; string;var dirPath     &#58; string;var fileIn      &#58; Tparameter;   // file namevar dirIn       &#58; Tparameter;   // directory addressvar midiIn      &#58; Tparameter;   // midi INvar parCountOUT &#58; Tparameter;   // length of parameterListvar midiOut     &#58; Tparameter;   // midi outputvar enableIN        &#58; Array of Tparameter;   // enable controlvar ccnumberIN      &#58; Array of Tparameter;var vstParamIN      &#58; Array of Tparameter;var captionOUT      &#58; Array of Tparameter;var valHueOUT      &#58; Array of Tparameter;var valueOUT        &#58; Array of Tparameter;var enabled         &#58; Array of boolean;var inputCCs        &#58; Array of integer;  //these are the input CC#s to look for a matchvar parameterOuts   &#58; Array of integer;  //this is the key to get the output param#var interval        &#58; integer;var cycle           &#58; integer;var parameterIndex  &#58; integer;//var key             &#58; integer;var first           &#58; boolean;var midi           &#58; TMidi;var msgCount       &#58; integer;var msgNumber      &#58; integer;var current        &#58; integer;//var control        &#58; integer;var red            &#58; integer;var green          &#58; integer;var blue           &#58; integer;// initialisation &#58; create parametersprocedure init;begin      chCount &#58;= 4;    cycle &#58;= 0;    interval &#58;= 64;    first &#58;= TRUE;    fileIn      &#58;= CreateParam&#40;'fileName',ptTextField&#41;;     SetIsOutput&#40;fileIn,false&#41;;    setStringValue&#40;fileIn, 'pro5CCs.txt'&#41;;     dirIn       &#58;= CreateParam&#40;'dirPath',ptTextField&#41;;      SetIsOutput&#40;dirIn,false&#41;;    setStringValue&#40;dirIn, 'c&#58;usinedata'&#41;;    midiIn &#58;= CreateParam&#40;'MIDIin',ptMidi&#41;;                 SetIsOutput&#40;midiIn,false&#41;;     midiOut &#58;= CreateParam&#40;'MIDIout',ptMidi&#41;;               SetIsInput&#40;midiOut,false&#41;;        parCountOUT  &#58;= CreateParam&#40;'ccCount', ptdataField&#41;;    SetIsInput&#40;parCountOUT,false&#41;;    setDefaultValue&#40;parCountOUT, 127&#41;;           // set array lengths    SetArrayLength&#40;ccNumberIN, chCount&#41;;    SetArrayLength&#40;enableIN, chCount&#41;;    SetArrayLength&#40;vstParamIN, chCount&#41;;    //SetArrayLength&#40;ctrlTypeIN, chCount&#41;;    SetArrayLength&#40;enableIN, chCount&#41;;    SetArrayLength&#40;captionOUT, chCount&#41;;    SetArrayLength&#40;valueOUT, chCount&#41;;    SetArrayLength&#40;valHueOUT, chCount&#41;;           SetArrayLength&#40;enabled, chCount&#41;;     SetArrayLength&#40;inputCCs, chCount&#41;;    SetArrayLength&#40;parameterOuts, chCount&#41;;            // create channels     for i &#58;= 0 to &#40;chCount - 1&#41; do begin                count &#58;= IntToStr&#40;i+1&#41;;                // chCount        ccNumberIN&#91;i&#93;&#58;= CreateParam&#40;'ccNum' + count, ptdataField&#41;;        setMax&#40;ccNumberIN&#91;i&#93;, 127&#41;;        setMin&#40;ccNumberIN&#91;i&#93;, 0&#41;;        SetFormat&#40;ccNumberIN&#91;i&#93;,'%.0f'&#41;;        SetIsOutput&#40;ccNumberIN&#91;i&#93;, false&#41;;                enableIN&#91;i&#93; &#58;= CreateParam&#40;'enable' + count, ptSwitch&#41;;                     SetIsOutput&#40;enableIN&#91;i&#93;,false&#41;;            vstParamIN&#91;i&#93; &#58;= CreateParam&#40;'vstParam'+ count, ptdataFader&#41;;        SetIsOutput&#40;vstParamIN&#91;i&#93;, false&#41;;        setMax&#40;vstParamIN&#91;i&#93;, 127&#41;;        setMin&#40;vstParamIN&#91;i&#93;, 0&#41;;        SetFormat&#40;vstParamIN&#91;i&#93;,'%.0f'&#41;;        // outs        captionOUT&#91;i&#93; &#58;= CreateParam&#40;'name' + count, ptTextField&#41;;        SetIsInput&#40;captionOut&#91;i&#93;, false&#41;;                // use for text of enable switch        valueOUT&#91;i&#93; &#58;= CreateParam&#40;'value' + count, ptTextField&#41;;        // use for background of parameter fader        valHueOUT&#91;i&#93; &#58;= CreateParam&#40;'valHUE' + count, ptDataField&#41;;                SetIsInput&#40;valueOUT&#91;i&#93;, false&#41;;        SetIsInput&#40;valHueOUT&#91;i&#93;, false&#41;;    end;    end;function midiDecStr&#40;val &#58; integer&#41; &#58; string;begin    result &#58;= intToStr&#40;trunc&#40;&#40;val * 100/128&#41;&#41;&#41;;end;function boolToStr&#40;isOn &#58; boolean&#41; &#58; string;begin    if isOn then    begin        result &#58;= 'ON';    end    else    begin        result &#58;= '--';    end;end;function singleToBool&#40;val &#58; single&#41; &#58; boolean ;begin    if val = 0 then    begin        result &#58;= FALSE;    end    else    begin        result &#58;= TRUE;    end;end;function midiToColor&#40;midiVal &#58; integer&#41;&#58; integer;begin    midiVal &#58;= &#40;midiVal * 2&#41;;    red &#58;= midiVal;    if &#40;midiVal > 128&#41; then    begin        green &#58;= &#40;256 - midival&#41; * 2;    end else    begin        green &#58;= midival * 2;    end;    blue &#58;= 256 - midiVal;    midiVal&#58;= red + &#40;green * 256&#41; + &#40;blue * 256 * 256&#41;;    writeln&#40;'rgb = ' + intToStr&#40;red&#41; + ', ' + intToStr&#40;green&#41; + ', ' + intToStr&#40;blue&#41;&#41;;    result &#58;= midiVal;end;    procedure processCCs; // here we figure out if it's a cc# that we want to process....begin    current &#58;= midi.data1;    writeln&#40;'control ' + intToStr&#40;i&#41; + '  ' + intToStr&#40;inputCCs&#91;i&#93;&#41;&#41;;    if &#40;current = inputCCs&#91;i&#93;&#41; then        begin        midi.data1 &#58;= parameterOuts&#91;i&#93;;           SetMidiArrayValue&#40;midiOUT, msgNumber, midi&#41;;        SetStringValue&#40;valueOUT&#91;i&#93;, midiDecStr&#40;midi.data2&#41;&#41;;        SetValue&#40;valHueOUT&#91;i&#93;, midiToColor&#40;midi.data2&#41;&#41;;            end;end;procedure loadCCs;  // a post-init method to load the filebegin    filename  &#58;= getStringValue&#40;fileIn&#41;;    dirPath  &#58;= getStringValue&#40;dirIn&#41;;    delimiter &#58;= '$';    st &#58;= TStringList.create;    st.clear;    st.loadfromFile&#40;dirPath + '' + filename&#41;;        ccCount &#58;= st.count;    setArrayLength&#40;controls, ccCount&#41;;    setValue&#40;parCountOUT, ccCount - 1&#41;;    for i &#58;= 0 to &#40;st.count-1&#41; do    begin            line &#58;= st.strings&#91;i&#93;;        position &#58;= pos&#40;delimiter, line&#41;;                        name &#58;= copy&#40;line, position + 1, length&#40;line&#41;&#41;;        number &#58;= strtoInt&#40;copy&#40;line, 0, position - 1&#41;&#41;;        controls&#91;i&#93;.name &#58;= name;        controls&#91;i&#93;.number &#58;= number;        writeln&#40;controls&#91;0&#93;.name + ' ' + intToStr&#40;controls&#91;0&#93;.number&#41;&#41;;    end;     st.free;end;//////////////////////////////// main procbegin        if first then    begin        loadCCs;        first &#58;= false;    end;        cycle &#58;= &#40;cycle + 1&#41; MOD 2000;        IF &#40;&#40;cycle MOD interval&#41; = 0&#41; THEN    begin        for i &#58;= 0 to &#40;chCount - 1&#41; do        begin                          parameterIndex &#58;= trunc&#40;getValue&#40;vstParamIN&#91;i&#93;&#41;&#41;; // this is the key for the param map            parameterOUts&#91;i&#93; &#58;= controls&#91;parameterIndex&#93;.number;  // these are the output parameter #s            setStringValue&#40;captionOUT&#91;i&#93;, controls&#91;parameterIndex&#93;.name&#41;; // set the string outs            enabled&#91;i&#93; &#58;= singleToBool&#40;getValue&#40;enableIn&#91;i&#93;&#41;&#41;;            inputCCs&#91;i&#93; &#58;= trunc&#40;getValue&#40;ccNumberIN&#91;i&#93;&#41;&#41;;                if &#40;enabled&#91;i&#93; = FALSE&#41; then            begin                setStringValue&#40;valueOUT&#91;i&#93;,'--'&#41;;            end;                   end;           end;            msgCount &#58;= GetLength&#40;midiIN&#41;;  // get the number of incoming midi codes     SetLength&#40;midiOut, msgCount&#41;;    if msgCount > 0 then     begin        for msgNumber &#58;= 0 to msgCount-1 do        begin             GetMidiArrayValue&#40;midiIN, msgNumber, midi&#41;;            for i &#58;= 0 to &#40;chCount - 1&#41; do            begin                if &#40;midi.msg = 176&#41; and &#40;enabled&#91;i&#93;&#41;                then                begin                    processCCs;                end                else            end;        end;    end        // no midi in this block....    ELSE BEGIN        SetLength&#40;midiOut, 0&#41;;    END;end.
cheers!
-eric

Statistics: Posted by woodslanding — 06 Dec 2008, 05:37


]]>
2008-12-05T00:04:35+02:00 2008-12-05T00:04:35+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6485#p6485 <![CDATA[scripts--midi output array size question]]>
I assume I don't need to worry if I don't fill up the output array--if I filter some messages, I don't need to create 'dummy' messages for the output array do I?
No - just add the MIDI messages you want and set the size when you're through. I'm pretty sure that the maximum length is 512 messages per execution block/array though, but you would have to create a really OTT patch to have problems with that limit. That said, I do have a feeling that your MIDI patches are bigger and more complex than most of us would ever dream of creating.... :)

Looking forward to to have a look at the ideas and solutions you've come up with!

Statistics: Posted by bsork — 04 Dec 2008, 23:04


]]>
2008-12-04T19:49:03+02:00 2008-12-04T19:49:03+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6477#p6477 <![CDATA[scripts--midi output array size question]]>
I assume I don't need to worry if I don't fill up the output array--if I filter some messages, I don't need to create 'dummy' messages for the output array do I?

I have my module working now. After some testing, I'll upload to the user section. Then you can tell me how to make it twice as efficient ;)

-e

Statistics: Posted by woodslanding — 04 Dec 2008, 18:49


]]>
2008-12-04T09:53:09+02:00 2008-12-04T09:53:09+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6466#p6466 <![CDATA[scripts--midi output array size question]]> Statistics: Posted by bsork — 04 Dec 2008, 08:53


]]>
2008-12-04T00:55:35+02:00 2008-12-04T00:55:35+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6459#p6459 <![CDATA[scripts--midi output array size question]]>
Thanks!
-e

Statistics: Posted by woodslanding — 03 Dec 2008, 23:55


]]>
2008-12-04T00:14:10+02:00 2008-12-04T00:14:10+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6456#p6456 <![CDATA[scripts--midi output array size question]]>
Just use a counter when populating the output array, and set the size after filling it. Remember that the size is the last index number + 1. It may seem a bit weird that you can enter values in the array even beyond the existing size, but you can. You can see examples of that in a lot of the MIDI scripts in Usine.

And if you think it's confusing, I can tell you that I more than once have had to check that this really is the way it's being done...

Statistics: Posted by bsork — 03 Dec 2008, 23:14


]]>
2008-12-03T21:10:14+02:00 2008-12-03T21:10:14+02:00 https://brainmodular.org/forums/viewtopic.php?t=1195&p=6451#p6451 <![CDATA[scripts--midi output array size question]]>
Or is this not really possible?

Thanks as ever!
-eric

Statistics: Posted by woodslanding — 03 Dec 2008, 20:10


]]>