ArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2010-01-19T20:55:27+02:00 https://brainmodular.org/forums/app.php/feed/topic/1855 2010-01-19T20:55:27+02:00 2010-01-19T20:55:27+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11253#p11253 <![CDATA[[script] data delays]]>
I'll study this. I see there is a litte trickery to get the output length set to zero at the beginning....

Statistics: Posted by woodslanding — 19 Jan 2010, 19:55


]]>
2010-01-19T13:05:57+02:00 2010-01-19T13:05:57+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11251#p11251 <![CDATA[[script] data delays]]>
Callback is called once for each updated input parameter in a execution before Process is called. Setting the length or value of a parameter can be done from either procedure, but any assignments done in Process will override anything called from Callback.

BTW, I really welcome the new structure: It makes for much cleaner coding. For a small script like yours, there's not much too gain, but with a lot parameters things get a lot simpler when one can fetch all or most of the data in one place, for instance:

CODE:

VAR pMidiIn, pMidiOut, pSwitch, pButton &#58; tParameter;VAR numIn &#58; Integer;VAR switchOn &#58; Boolean;...PROCEDURE Init;BEGIN    pMidiIn &#58;= CreateParam&#40;'midi in', ptMidi&#41;; SetIsOutput&#40;pMidiIn, FALSE&#41;;    pMidiOut &#58;= CreateParam&#40;'midi out', ptMidi&#41;; SetIsInput&#40;pMidiIn, FALSE&#41;;    pSwitch &#58;= CreateParam&#40;'switch', ptSwitch&#41;; SetIsOutput&#40;pSwitch, FALSE&#41;;    pButton &#58;= CreateParam&#40;'switch', ptButton&#41;; SetIsOutput&#40;pButton, FALSE&#41;;   ...END;...PROCEDURE Callback&#40;n &#58; Integer&#41;;BEGIN   CASE n OF     pMidiIn &#58; numIn &#58;= trunc&#40;GetValue&#40;n&#41;&#41;;     pSwitch &#58; switchOn &#58;= &#40;GetValue&#40;n&#41; > 0.0&#41;;     pButton &#58; DoSomeThing;     ...   END;END;PROCEDURE Process;   VAR i &#58; Integer;   VAR m &#58; tMidi;BEGIN   IF &#40;switchOn&#41; THEN       ...   FOR i &#58;= 0 TO &#40;numIn - 1&#41; THEN DO      GetMidiArrayValue&#40;pMidiIn, i, m&#41;;      ...END;

Statistics: Posted by bsork — 19 Jan 2010, 12:05


]]>
2010-01-19T02:29:42+02:00 2010-01-19T02:29:42+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11250#p11250 <![CDATA[[script] data delays]]>

It's getting late, so this is probably not the most elegant code, but it works:

CODE:

// resets Mr ray's oscillators on a patch changevar startTime &#58; Single;var doChange, noteOnsSent, setZeroLength, noteOffsSent &#58; Boolean;var i            &#58; integer;var noteOn       &#58; TMidi;var noteOff      &#58; TMidi;var output  &#58; Tparameter;var volOut  &#58; Tparameter;var trigger &#58; Tparameter;// initialisation &#58; create parametersprocedure init;begin   Output &#58;= CreateParam&#40;'Midi Out',ptMidi&#41;;                   SetIsInput&#40;Output,false&#41;; VolOut &#58;= CreateParam&#40;'Vol Out',ptDataField&#41;;               SetIsInput&#40;volOut,false&#41;; trigger &#58;= CreateParam&#40;'trig',ptButton&#41;;                    SetIsOutput&#40;Trigger,false&#41;; end;Procedure SendNoteOns;begin    SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 0 to 23         // loop for all input codes, for polyphonic data &#40;chords&#41;    do begin      noteOn.data1 &#58;= i;      noteOn.data2 &#58;= 1;      noteOn.msg &#58;= 144;       noteOn.channel &#58;= 1;      SetMidiArrayValue&#40;output,i,noteOn&#41;; // set output value    endend;Procedure SendNoteOffs;begin                   SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 0 to 23 do begin                       noteOff.data1 &#58;= i;        noteOff.data2 &#58;= 0;        noteOff.msg &#58;= 128;        noteOff.channel &#58;= 1;        SetMidiArrayValue&#40;output,i,noteOff&#41;; // set output value     end;end;PROCEDURE Callback &#40;n &#58; Integer&#41;;  // only 1 input, trigger....begin       if n = trigger then begin         startTime &#58;= TimeMs;       doChange &#58;=  TRUE;       noteOffsSent &#58;= FALSE;       SetValue&#40;volOut, 0&#41;;       SendNoteOns;       noteOnsSent &#58;= TRUE;       setZeroLength &#58;= FALSE;   end;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 700.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END      ELSE IF &#40;noteOnsSent AND NOT setZeroLength&#41; THEN BEGIN         setZeroLength &#58;= TRUE;      END      ELSE IF &#40;setZeroLength&#41; THEN BEGIN         SetLength&#40;outPut, 0&#41;;      END;   END;END;
Doesn't ray22 recognize the lowest octave, or why else do you start at NoteNo 12? If that's the case, you can use the loop construction 0..23 with 12 added to data1 for both Ons and Offs.There's no need to "keep counting" from where you left off.

Statistics: Posted by bsork — 19 Jan 2010, 01:29


]]>
2010-01-19T02:10:54+02:00 2010-01-19T02:10:54+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11249#p11249 <![CDATA[[script] data delays]]>
i believe you have to set the length of outpout parameter to 0 at the end of the IF (doChange) block, or the midi message is fired each time Process is executed.

CODE:

BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 7000.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;      SetLength&#40;outPut,48&#41;;   END;END;

Statistics: Posted by martignasse — 19 Jan 2010, 01:10


]]>
2010-01-19T02:03:00+02:00 2010-01-19T02:03:00+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11248#p11248 <![CDATA[[script] data delays]]>
I want to try making this contingent on the value of trigger, but I cannot test for

getValue(trigger) = 1

without getting a compile error. What am I doing wrong? Doesn't getValue() return a SINGLE??
try

CODE:

round&#40;getValue&#40;trigger&#41;&#41; = 1;
because you are comparing a single against an integer.

hope it help

Statistics: Posted by martignasse — 19 Jan 2010, 01:03


]]>
2010-01-19T01:50:15+02:00 2010-01-19T01:50:15+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11247#p11247 <![CDATA[[script] data delays]]>
getValue(trigger) = 1

without getting a compile error. What am I doing wrong? Doesn't getValue() return a SINGLE??

Statistics: Posted by woodslanding — 19 Jan 2010, 00:50


]]>
2010-01-19T01:47:08+02:00 2010-01-19T01:47:08+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11246#p11246 <![CDATA[[script] data delays]]>

CODE:

// resets Mr ray's oscillators on a patch changevar startTime &#58; Single;var doChange, noteOffsSent &#58; Boolean;var i            &#58; integer;var noteOn       &#58; TMidi;var noteOff      &#58; TMidi;var output  &#58; Tparameter;var volOut  &#58; Tparameter;var trigger &#58; Tparameter;// initialisation &#58; create parametersprocedure init;begin   Output &#58;= CreateParam&#40;'Midi Out',ptMidi&#41;;                   SetIsInput&#40;Output,false&#41;; VolOut &#58;= CreateParam&#40;'Vol Out',ptDataField&#41;;               SetIsInput&#40;volOut,false&#41;; trigger &#58;= CreateParam&#40;'trig',ptDataField&#41;;                    SetIsOutput&#40;Trigger,false&#41;; end;Procedure SendNoteOns;begin    SetLength&#40;outPut,48&#41;;      // set the number of output codes    for i &#58;= 0 to 23         // loop for all input codes, for polyphonic data &#40;chords&#41;    do begin      noteOn.data1 &#58;= i + 12;      noteOn.data2 &#58;= 1;      noteOn.msg &#58;= 144;       noteOn.channel &#58;= 1;      SetMidiArrayValue&#40;output,i,noteOn&#41;; // set output value    endend;Procedure SendNoteOffs;begin                   //SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 24 to 47 do begin                       noteOff.data1 &#58;= i - 12;        noteOff.data2 &#58;= 0;        noteOff.msg &#58;= 128;        noteOff.channel &#58;= 1;        SetMidiArrayValue&#40;output,i,noteOff&#41;; // set output value     end;end;PROCEDURE Callback &#40;n &#58; Integer&#41;;  // only 1 input, trigger....begin       if n = trigger then begin         startTime &#58;= TimeMs;       doChange &#58;=  TRUE;       noteOffsSent &#58;= FALSE;       SetValue&#40;volOut, 0&#41;;       SendNoteOns;          end;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 7000.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;   END;END;

Statistics: Posted by woodslanding — 19 Jan 2010, 00:47


]]>
2010-01-19T01:39:40+02:00 2010-01-19T01:39:40+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11245#p11245 <![CDATA[[script] data delays]]>
I'm not sure why you are checking whether noteoffs are sent. I'll look into that.

EDIT: Actually this version sends one noteOFF, but if I move the noteON method to process, I lose even that one.

CODE:

// resets Mr ray's oscillators on a patch changevar startTime &#58; Single;var doChange, noteOffsSent &#58; Boolean;var i            &#58; integer;var noteOn       &#58; TMidi;var noteOff      &#58; TMidi;var output  &#58; Tparameter;var volOut  &#58; Tparameter;var trigger &#58; Tparameter;// initialisation &#58; create parametersprocedure init;begin   Output &#58;= CreateParam&#40;'Midi Out',ptMidi&#41;;                   SetIsInput&#40;Output,false&#41;; VolOut &#58;= CreateParam&#40;'Vol Out',ptDataField&#41;;               SetIsInput&#40;volOut,false&#41;; trigger &#58;= CreateParam&#40;'trig',ptDataField&#41;;                    SetIsOutput&#40;Trigger,false&#41;; end;Procedure SendNoteOns;begin    SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 1 to 24         // loop for all input codes, for polyphonic data &#40;chords&#41;    do begin      noteOn.data1 &#58;= i + 12;      noteOn.data2 &#58;= 1;      noteOn.msg &#58;= 144;       noteOn.channel &#58;= 1;      SetMidiArrayValue&#40;output,i,noteOn&#41;; // set output value    endend;Procedure SendNoteOffs;begin                   SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 1 to 24 do begin                       noteOff.data1 &#58;= i - 12;        noteOff.data2 &#58;= 0;        noteOff.msg &#58;= 128;        noteOff.channel &#58;= 1;        SetMidiArrayValue&#40;output,i,noteOff&#41;; // set output value     end;end;PROCEDURE Callback &#40;n &#58; Integer&#41;;  // only 1 input, trigger....begin       if n = trigger then begin         startTime &#58;= TimeMs;       doChange &#58;=  TRUE;       noteOffsSent &#58;= FALSE;       SetValue&#40;volOut, 0&#41;;       SendNoteOns;          end;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 7000.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;   END;END;

Statistics: Posted by woodslanding — 19 Jan 2010, 00:39


]]>
2010-01-19T01:01:18+02:00 2010-01-19T01:01:18+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11244#p11244 <![CDATA[[script] data delays]]>
I'll try it both ways and see what works.....

Statistics: Posted by woodslanding — 19 Jan 2010, 00:01


]]>
2010-01-19T00:53:41+02:00 2010-01-19T00:53:41+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11243#p11243 <![CDATA[[script] data delays]]>
The code reads like butter!

I've realized it's not so easy in Delphi when you don't have capitalization to set things apart.....

Statistics: Posted by woodslanding — 18 Jan 2010, 23:53


]]>
2010-01-19T00:46:42+02:00 2010-01-19T00:46:42+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11242#p11242 <![CDATA[[script] data delays]]> Statistics: Posted by woodslanding — 18 Jan 2010, 23:46


]]>
2010-01-18T13:00:24+02:00 2010-01-18T13:00:24+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11240#p11240 <![CDATA[[script] data delays]]>

CODE:

var onPM &#58; tParameter;var startTime &#58; Single;var doChange, noteOffsSent &#58; Boolean;...PROCEDURE Callback &#40;n &#58; Integer&#41;;begin   startTime &#58;= TimeMs;   doChange &#58;= TRUE;   noteOffsSent &#58;= FALSE;   SendVol0AndNoteOns;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 700.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SendVol1;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;   END;END;
Just a tiny bit of CPU to check the doChange variable in Process.

I can't think of any way of doing something like this where somethings are going to happen after the initial trigger event that wouldn't use any CPU to check whatever needs checking (in this case the elapsed). Well, you could always put the script inside a separate (sub-)patch and turn activation on and off with some similar to keep track of the proceedings, but as long as you can use something as simple as a boolean, I doubt you'll gain anything. For all that I know, the patching needed could even use a bit more CPU.

Statistics: Posted by bsork — 18 Jan 2010, 12:00


]]>
2010-01-18T10:57:15+02:00 2010-01-18T10:57:15+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11237#p11237 <![CDATA[[script] data delays]]>
Just wondering what it entails to delay some data with the new script. I don't need precision.... well, here's what I need:

I use mr ray22 which is an excellent rhodes emulation. Problem is, when you change patches, you get nasty clicks on every note until all 24 have been played at least once. The easy way to do this is to lay your arm on the keyboard with the volume down. Now it plays pretty!

So I created in V4 a 'virtual arm' that, when it sees a patch change, sends out a 0 to control the volume, spits out 24 different note ons, spits out another 24 about 200 ms. later, and then about 500 ms after that (so the sound can decay) sends a 1 on the volume out.

Works great, but I used three data delay modules, and three midi scripts. Now I think I could do it all with one script pretty easily if I understood delays better.

Obviously, I'd also like to make it as efficient as possible--shouldn't use any cpu except when it sees a program change.

Thoughts??

Thanks in advance!
-e

Statistics: Posted by woodslanding — 18 Jan 2010, 09:57


]]>
BrainModular BrainModular Users Forum 2010-01-19T20:55:27+02:00 https://brainmodular.org/forums/app.php/feed/topic/1855 2010-01-19T20:55:27+02:00 2010-01-19T20:55:27+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11253#p11253 <![CDATA[[script] data delays]]>
I'll study this. I see there is a litte trickery to get the output length set to zero at the beginning....

Statistics: Posted by woodslanding — 19 Jan 2010, 19:55


]]>
2010-01-19T13:05:57+02:00 2010-01-19T13:05:57+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11251#p11251 <![CDATA[[script] data delays]]>
Callback is called once for each updated input parameter in a execution before Process is called. Setting the length or value of a parameter can be done from either procedure, but any assignments done in Process will override anything called from Callback.

BTW, I really welcome the new structure: It makes for much cleaner coding. For a small script like yours, there's not much too gain, but with a lot parameters things get a lot simpler when one can fetch all or most of the data in one place, for instance:

CODE:

VAR pMidiIn, pMidiOut, pSwitch, pButton &#58; tParameter;VAR numIn &#58; Integer;VAR switchOn &#58; Boolean;...PROCEDURE Init;BEGIN    pMidiIn &#58;= CreateParam&#40;'midi in', ptMidi&#41;; SetIsOutput&#40;pMidiIn, FALSE&#41;;    pMidiOut &#58;= CreateParam&#40;'midi out', ptMidi&#41;; SetIsInput&#40;pMidiIn, FALSE&#41;;    pSwitch &#58;= CreateParam&#40;'switch', ptSwitch&#41;; SetIsOutput&#40;pSwitch, FALSE&#41;;    pButton &#58;= CreateParam&#40;'switch', ptButton&#41;; SetIsOutput&#40;pButton, FALSE&#41;;   ...END;...PROCEDURE Callback&#40;n &#58; Integer&#41;;BEGIN   CASE n OF     pMidiIn &#58; numIn &#58;= trunc&#40;GetValue&#40;n&#41;&#41;;     pSwitch &#58; switchOn &#58;= &#40;GetValue&#40;n&#41; > 0.0&#41;;     pButton &#58; DoSomeThing;     ...   END;END;PROCEDURE Process;   VAR i &#58; Integer;   VAR m &#58; tMidi;BEGIN   IF &#40;switchOn&#41; THEN       ...   FOR i &#58;= 0 TO &#40;numIn - 1&#41; THEN DO      GetMidiArrayValue&#40;pMidiIn, i, m&#41;;      ...END;

Statistics: Posted by bsork — 19 Jan 2010, 12:05


]]>
2010-01-19T02:29:42+02:00 2010-01-19T02:29:42+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11250#p11250 <![CDATA[[script] data delays]]>

It's getting late, so this is probably not the most elegant code, but it works:

CODE:

// resets Mr ray's oscillators on a patch changevar startTime &#58; Single;var doChange, noteOnsSent, setZeroLength, noteOffsSent &#58; Boolean;var i            &#58; integer;var noteOn       &#58; TMidi;var noteOff      &#58; TMidi;var output  &#58; Tparameter;var volOut  &#58; Tparameter;var trigger &#58; Tparameter;// initialisation &#58; create parametersprocedure init;begin   Output &#58;= CreateParam&#40;'Midi Out',ptMidi&#41;;                   SetIsInput&#40;Output,false&#41;; VolOut &#58;= CreateParam&#40;'Vol Out',ptDataField&#41;;               SetIsInput&#40;volOut,false&#41;; trigger &#58;= CreateParam&#40;'trig',ptButton&#41;;                    SetIsOutput&#40;Trigger,false&#41;; end;Procedure SendNoteOns;begin    SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 0 to 23         // loop for all input codes, for polyphonic data &#40;chords&#41;    do begin      noteOn.data1 &#58;= i;      noteOn.data2 &#58;= 1;      noteOn.msg &#58;= 144;       noteOn.channel &#58;= 1;      SetMidiArrayValue&#40;output,i,noteOn&#41;; // set output value    endend;Procedure SendNoteOffs;begin                   SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 0 to 23 do begin                       noteOff.data1 &#58;= i;        noteOff.data2 &#58;= 0;        noteOff.msg &#58;= 128;        noteOff.channel &#58;= 1;        SetMidiArrayValue&#40;output,i,noteOff&#41;; // set output value     end;end;PROCEDURE Callback &#40;n &#58; Integer&#41;;  // only 1 input, trigger....begin       if n = trigger then begin         startTime &#58;= TimeMs;       doChange &#58;=  TRUE;       noteOffsSent &#58;= FALSE;       SetValue&#40;volOut, 0&#41;;       SendNoteOns;       noteOnsSent &#58;= TRUE;       setZeroLength &#58;= FALSE;   end;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 700.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END      ELSE IF &#40;noteOnsSent AND NOT setZeroLength&#41; THEN BEGIN         setZeroLength &#58;= TRUE;      END      ELSE IF &#40;setZeroLength&#41; THEN BEGIN         SetLength&#40;outPut, 0&#41;;      END;   END;END;
Doesn't ray22 recognize the lowest octave, or why else do you start at NoteNo 12? If that's the case, you can use the loop construction 0..23 with 12 added to data1 for both Ons and Offs.There's no need to "keep counting" from where you left off.

Statistics: Posted by bsork — 19 Jan 2010, 01:29


]]>
2010-01-19T02:10:54+02:00 2010-01-19T02:10:54+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11249#p11249 <![CDATA[[script] data delays]]>
i believe you have to set the length of outpout parameter to 0 at the end of the IF (doChange) block, or the midi message is fired each time Process is executed.

CODE:

BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 7000.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;      SetLength&#40;outPut,48&#41;;   END;END;

Statistics: Posted by martignasse — 19 Jan 2010, 01:10


]]>
2010-01-19T02:03:00+02:00 2010-01-19T02:03:00+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11248#p11248 <![CDATA[[script] data delays]]>
I want to try making this contingent on the value of trigger, but I cannot test for

getValue(trigger) = 1

without getting a compile error. What am I doing wrong? Doesn't getValue() return a SINGLE??
try

CODE:

round&#40;getValue&#40;trigger&#41;&#41; = 1;
because you are comparing a single against an integer.

hope it help

Statistics: Posted by martignasse — 19 Jan 2010, 01:03


]]>
2010-01-19T01:50:15+02:00 2010-01-19T01:50:15+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11247#p11247 <![CDATA[[script] data delays]]>
getValue(trigger) = 1

without getting a compile error. What am I doing wrong? Doesn't getValue() return a SINGLE??

Statistics: Posted by woodslanding — 19 Jan 2010, 00:50


]]>
2010-01-19T01:47:08+02:00 2010-01-19T01:47:08+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11246#p11246 <![CDATA[[script] data delays]]>

CODE:

// resets Mr ray's oscillators on a patch changevar startTime &#58; Single;var doChange, noteOffsSent &#58; Boolean;var i            &#58; integer;var noteOn       &#58; TMidi;var noteOff      &#58; TMidi;var output  &#58; Tparameter;var volOut  &#58; Tparameter;var trigger &#58; Tparameter;// initialisation &#58; create parametersprocedure init;begin   Output &#58;= CreateParam&#40;'Midi Out',ptMidi&#41;;                   SetIsInput&#40;Output,false&#41;; VolOut &#58;= CreateParam&#40;'Vol Out',ptDataField&#41;;               SetIsInput&#40;volOut,false&#41;; trigger &#58;= CreateParam&#40;'trig',ptDataField&#41;;                    SetIsOutput&#40;Trigger,false&#41;; end;Procedure SendNoteOns;begin    SetLength&#40;outPut,48&#41;;      // set the number of output codes    for i &#58;= 0 to 23         // loop for all input codes, for polyphonic data &#40;chords&#41;    do begin      noteOn.data1 &#58;= i + 12;      noteOn.data2 &#58;= 1;      noteOn.msg &#58;= 144;       noteOn.channel &#58;= 1;      SetMidiArrayValue&#40;output,i,noteOn&#41;; // set output value    endend;Procedure SendNoteOffs;begin                   //SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 24 to 47 do begin                       noteOff.data1 &#58;= i - 12;        noteOff.data2 &#58;= 0;        noteOff.msg &#58;= 128;        noteOff.channel &#58;= 1;        SetMidiArrayValue&#40;output,i,noteOff&#41;; // set output value     end;end;PROCEDURE Callback &#40;n &#58; Integer&#41;;  // only 1 input, trigger....begin       if n = trigger then begin         startTime &#58;= TimeMs;       doChange &#58;=  TRUE;       noteOffsSent &#58;= FALSE;       SetValue&#40;volOut, 0&#41;;       SendNoteOns;          end;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 7000.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;   END;END;

Statistics: Posted by woodslanding — 19 Jan 2010, 00:47


]]>
2010-01-19T01:39:40+02:00 2010-01-19T01:39:40+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11245#p11245 <![CDATA[[script] data delays]]>
I'm not sure why you are checking whether noteoffs are sent. I'll look into that.

EDIT: Actually this version sends one noteOFF, but if I move the noteON method to process, I lose even that one.

CODE:

// resets Mr ray's oscillators on a patch changevar startTime &#58; Single;var doChange, noteOffsSent &#58; Boolean;var i            &#58; integer;var noteOn       &#58; TMidi;var noteOff      &#58; TMidi;var output  &#58; Tparameter;var volOut  &#58; Tparameter;var trigger &#58; Tparameter;// initialisation &#58; create parametersprocedure init;begin   Output &#58;= CreateParam&#40;'Midi Out',ptMidi&#41;;                   SetIsInput&#40;Output,false&#41;; VolOut &#58;= CreateParam&#40;'Vol Out',ptDataField&#41;;               SetIsInput&#40;volOut,false&#41;; trigger &#58;= CreateParam&#40;'trig',ptDataField&#41;;                    SetIsOutput&#40;Trigger,false&#41;; end;Procedure SendNoteOns;begin    SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 1 to 24         // loop for all input codes, for polyphonic data &#40;chords&#41;    do begin      noteOn.data1 &#58;= i + 12;      noteOn.data2 &#58;= 1;      noteOn.msg &#58;= 144;       noteOn.channel &#58;= 1;      SetMidiArrayValue&#40;output,i,noteOn&#41;; // set output value    endend;Procedure SendNoteOffs;begin                   SetLength&#40;outPut,24&#41;;      // set the number of output codes    for i &#58;= 1 to 24 do begin                       noteOff.data1 &#58;= i - 12;        noteOff.data2 &#58;= 0;        noteOff.msg &#58;= 128;        noteOff.channel &#58;= 1;        SetMidiArrayValue&#40;output,i,noteOff&#41;; // set output value     end;end;PROCEDURE Callback &#40;n &#58; Integer&#41;;  // only 1 input, trigger....begin       if n = trigger then begin         startTime &#58;= TimeMs;       doChange &#58;=  TRUE;       noteOffsSent &#58;= FALSE;       SetValue&#40;volOut, 0&#41;;       SendNoteOns;          end;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 7000.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SetValue&#40;volOut, 1&#41;;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;   END;END;

Statistics: Posted by woodslanding — 19 Jan 2010, 00:39


]]>
2010-01-19T01:01:18+02:00 2010-01-19T01:01:18+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11244#p11244 <![CDATA[[script] data delays]]>
I'll try it both ways and see what works.....

Statistics: Posted by woodslanding — 19 Jan 2010, 00:01


]]>
2010-01-19T00:53:41+02:00 2010-01-19T00:53:41+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11243#p11243 <![CDATA[[script] data delays]]>
The code reads like butter!

I've realized it's not so easy in Delphi when you don't have capitalization to set things apart.....

Statistics: Posted by woodslanding — 18 Jan 2010, 23:53


]]>
2010-01-19T00:46:42+02:00 2010-01-19T00:46:42+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11242#p11242 <![CDATA[[script] data delays]]> Statistics: Posted by woodslanding — 18 Jan 2010, 23:46


]]>
2010-01-18T13:00:24+02:00 2010-01-18T13:00:24+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11240#p11240 <![CDATA[[script] data delays]]>

CODE:

var onPM &#58; tParameter;var startTime &#58; Single;var doChange, noteOffsSent &#58; Boolean;...PROCEDURE Callback &#40;n &#58; Integer&#41;;begin   startTime &#58;= TimeMs;   doChange &#58;= TRUE;   noteOffsSent &#58;= FALSE;   SendVol0AndNoteOns;end;PROCEDURE Process;BEGIN   IF &#40;doChange&#41; THEN BEGIN      IF &#40;&#40;TimeMs - startTime&#41; >= 700.0&#41; THEN BEGIN         doChange &#58;= FALSE;         SendVol1;      END      ELSE IF &#40;&#40;&#40;TimeMs - startTime&#41; >= 200.0&#41; AND &#40;NOT noteOffsSent&#41;&#41; THEN BEGIN         SendNoteOffs;         noteOffsSent &#58;= TRUE;      END;   END;END;
Just a tiny bit of CPU to check the doChange variable in Process.

I can't think of any way of doing something like this where somethings are going to happen after the initial trigger event that wouldn't use any CPU to check whatever needs checking (in this case the elapsed). Well, you could always put the script inside a separate (sub-)patch and turn activation on and off with some similar to keep track of the proceedings, but as long as you can use something as simple as a boolean, I doubt you'll gain anything. For all that I know, the patching needed could even use a bit more CPU.

Statistics: Posted by bsork — 18 Jan 2010, 12:00


]]>
2010-01-18T10:57:15+02:00 2010-01-18T10:57:15+02:00 https://brainmodular.org/forums/viewtopic.php?t=1855&p=11237#p11237 <![CDATA[[script] data delays]]>
Just wondering what it entails to delay some data with the new script. I don't need precision.... well, here's what I need:

I use mr ray22 which is an excellent rhodes emulation. Problem is, when you change patches, you get nasty clicks on every note until all 24 have been played at least once. The easy way to do this is to lay your arm on the keyboard with the volume down. Now it plays pretty!

So I created in V4 a 'virtual arm' that, when it sees a patch change, sends out a 0 to control the volume, spits out 24 different note ons, spits out another 24 about 200 ms. later, and then about 500 ms after that (so the sound can decay) sends a 1 on the volume out.

Works great, but I used three data delay modules, and three midi scripts. Now I think I could do it all with one script pretty easily if I understood delays better.

Obviously, I'd also like to make it as efficient as possible--shouldn't use any cpu except when it sees a program change.

Thoughts??

Thanks in advance!
-e

Statistics: Posted by woodslanding — 18 Jan 2010, 09:57


]]>