ArrayArrayArrayArrayArrayArray BrainModular BrainModular Users Forum 2013-08-28T21:44:53+02:00 https://brainmodular.org/forums/app.php/feed/topic/3995 2013-08-28T21:44:53+02:00 2013-08-28T21:44:53+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27581#p27581 <![CDATA[New matrix combo for HH]]>
1. Need the reverse, in order to create ct for output. I assume there are commands for adding to the end of a string, I'll look that up.
2. I assume usine always uses a comma as a delimiter--but we never see them in usine. If we want support for commas in line text is that even possible?? It would be nice if usine used a more robust delimiter, like n. That's what the commatext in usine usually looks like. Anyway, a version of this specific to usine's chosen delimiter would be more usefull for most usine users.

Anyway, I've filed the commatext in scripts issue as a bug, so if Olivier fixes it internally, I won't mess with this. Otherwise I'll see what I can do.

Statistics: Posted by woodslanding — 28 Aug 2013, 21:44


]]>
2013-08-20T21:34:13+02:00 2013-08-20T21:34:13+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27524#p27524 <![CDATA[New matrix combo for HH]]>

Here's my split_string function. It's not quite an instant drop-in for TStringLists but shouldn't be too hard to figure out. It does not handle embedded quotes, but you can easily add that if you need with an inside_quote boolean or whatever. I haven't added it because my textual definition formats are too simple to need it.

CODE:

function split_string&#40;const sep, str&#58; string&#41; &#58; array of string; // &#123;&#123;&#123;2var i, start, cnt, endpos, seplen&#58; integer;begin    if &#40;str = ''&#41; thenbeginSetArrayLength&#40;Result, 0&#41;;Exit;end;if &#40;sep = ''&#41; thenbeginSetArrayLength&#40;Result, 1&#41;;Result&#91;0&#93; &#58;= str;Exit;end;seplen &#58;= Length&#40;sep&#41;;SetArrayLength&#40;result, &#40;Length&#40;str&#41; div seplen&#41; + 1&#41;;i &#58;= 1;start &#58;= i;cnt &#58;= 0;while &#40;i <= &#40;Length&#40;str&#41; - seplen + 1&#41;&#41; dobeginif &#40;str&#91;i&#93; = sep&#91;1&#93;&#41; thenif &#40;Copy&#40;str, i, seplen&#41; = sep&#41; thenbeginif &#40;start < i&#41; thenResult&#91;cnt&#93; &#58;= Copy&#40;str, start, i - start&#41;elseResult&#91;cnt&#93; &#58;= '';Inc&#40;cnt&#41;;Inc&#40;i, seplen - 1&#41;;start &#58;= i + 1;end;Inc&#40;i&#41;;end;endpos &#58;= Length&#40;str&#41; + 1;if &#40;start < endpos&#41; thenResult&#91;cnt&#93; &#58;= Copy&#40;str, start, endpos - start&#41;elseResult&#91;cnt&#93; &#58;= '';Inc&#40;cnt&#41;;SetArrayLength&#40;Result, cnt&#41;;end;

Statistics: Posted by ynohtna — 20 Aug 2013, 21:34


]]>
2013-08-20T01:09:55+02:00 2013-08-20T01:09:55+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27516#p27516 <![CDATA[New matrix combo for HH]]>
Does processIdle get called at the UI update rate then, I assume? That's probably the right choice for just selecting presets....

Statistics: Posted by woodslanding — 20 Aug 2013, 01:09


]]>
2013-08-18T17:47:46+02:00 2013-08-18T17:47:46+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27502#p27502 <![CDATA[New matrix combo for HH]]>

Couldn't find any issues in a quick run through the script, though.

I seem to recall having seen similar issues with my scripts when updating individual elements of an output array and not the entire set. What I've been doing is setting a XXX_needs_update boolean inside Callback and then setting the appropriate outputs within Process or ProcessIdle (depending on whether it's realtime or UI related data). Could be worth a try?

Oh, and I've also had the same problem with comma text parsing so I've been using my own split_string function. I'm happy to share the code if you're interested.

Statistics: Posted by ynohtna — 18 Aug 2013, 17:47


]]>
2013-08-17T17:31:18+02:00 2013-08-17T17:31:18+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27500#p27500 <![CDATA[New matrix combo for HH]]>
It's eating up tons of processor now, so unusable. Maybe it's a bug.... If anyone can test it out, I'd appreciate it.

Thanks!
-e

Statistics: Posted by woodslanding — 17 Aug 2013, 17:31


]]>
2013-08-10T07:57:58+02:00 2013-08-10T07:57:58+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27452#p27452 <![CDATA[New matrix combo for HH]]>
This one uses the first column to select pages, and the rest of the cells update accordingly. It can take a number in, and send a number out via a click on the matrix. I swapped the x and y axes, because I like to read down more than across....

It's basically working fine, but two small problems:

1. If I put any spaces in my pages commatext, it is mis-parsed into two elements. It looks at it as 'spaceText'.....
2. Although I'm only setting values of 1 or 0 for 'cells out', I'm seeing a lot of very small values, and the matrix buttons are changing shades (randomly?) when the first button in column 2 is pressed.

Here's the patch:
http://www.sensomusic.com/forums/upload ... omboHH.pat

and here's the code:

CODE:

////////////////////////////////////////////////////////////////////////////////////////////////CONST BUTTON_COUNT = 32;  //should be a multiple of page countCONST PAGE_COUNT = 8;VAR cellsOUT, namesOUT, presetOUT, presetsIN, pagesIN, clickedIN, presetIN&#58; tParameter;VAR pages, presets,buttonNames &#58; TStringList;var page, preset, presetCount, pageMax, ROW_COUNT, COL_COUNT, MATRIX_SIZE    &#58; integer;                   // destroyprocedure Destroy;begin   pages.free; presets.free;   buttonNames.free;end;   PROCEDURE Init;BEGIN    pagesIN &#58;= CreateParam&#40;'pages', ptTextfield&#41;; SetIsOutput&#40;pagesIN, FALSE&#41;;    presetsIN &#58;= CreateParam&#40;'presets', ptTextfield&#41;; SetIsOutput&#40;presetsIN, FALSE&#41;;    clickedIN &#58;= CreateParam&#40;'last clicked', ptDatafield&#41;; SetIsOutput&#40;clickedIN, FALSE&#41;;    presetIN &#58;= CreateParam&#40;'preset num', ptDatafield&#41;; SetIsOutput&#40;presetIN, FALSE&#41;;    cellsOut &#58;= CreateParam&#40;'cells out', ptArray&#41;; SetIsInput&#40;cellsOut, FALSE&#41;;    namesOut &#58;= CreateParam&#40;'captions out', ptTextfield&#41;; SetIsInput&#40;namesOut, FALSE&#41;;    presetOut &#58;= CreateParam&#40;'preset out', ptDatafield&#41;; SetIsInput&#40;presetOut, FALSE&#41;;    MATRIX_SIZE &#58;= PAGE_COUNT + BUTTON_COUNT;    COL_COUNT &#58;= BUTTON_COUNT div PAGE_COUNT;    ROW_COUNT &#58;= PAGE_COUNT;    setLength&#40;cellsOUT, MATRIX_SIZE &#41;;    pages.Create;    presets.Create;    buttonNames.Create;   END; // Init///////////////////////////////////////////////////////////////////////////////////////// to switch rows and columns.  x = row, y = col.  For x = 0, add the page name.  then// for x = 1 to 4, get items 0, 8, 16, and 24.  that's page_count * &#40;x-1&#41; + y//procedure UpdateButtons;var col,row,index &#58; integer;begin    buttonNames.Clear;    for row &#58;= 0 to &#40;ROW_COUNT - 1&#41; do begin  // for each row        for col &#58;= 0 to COL_COUNT do begin     // for each column--incl page column            if col = 0 then buttonNames.add&#40;pages.getStrings&#40;row&#41;&#41;  // add page row item            else begin                            index &#58;= &#40;PAGE_COUNT * &#40;col - 1&#41;&#41; + row; // get the row/col adjusted index....                if &#40;&#40;page * BUTTON_COUNT&#41; + index&#41; >= presetCount then begin                    buttonNames.add&#40;'---'&#41;;                   end else begin                          buttonNames.add&#40;presets.getStrings&#40;&#40;page * BUTTON_COUNT&#41; + index&#41;&#41;;                end;            end;        end;    end;    setStringValue&#40;namesOUT, buttonNames.getCommatext&#41;;end;PROCEDURE clearMatrix&#40;&#41;;             //////////////////CLEAR MATRIX////////////////////   var i &#58; integer;BEGIN       for i &#58;= 0 to &#40;MATRIX_SIZE - 1&#41; DO   BEGIN           setDataArrayValue&#40;cellsOUT,i,0&#41;;            strace&#40;'cell zeroed&#58; ' + intToStr&#40;i&#41;&#41;;           END;END;                                               PROCEDURE enable&#40;index &#58; integer&#41;;    /////////////////ENABLE////////////////////////BEGIN    setDataArrayValue&#40;cellsOUT, index, 1.0&#41;;END;PROCEDURE PageChanged&#40;&#41;;         /////////////////////PAGE CHANGED////////////////var index, cellNum&#58; integer;BEGIN    UpdateButtons&#40;&#41;;    ClearMatrix&#40;&#41;;    enable&#40;page * &#40;COL_COUNT + 1&#41;&#41;;    if &#40;preset div BUTTON_COUNT&#41; = page then  // if the preset is on the current page....    BEGIN        index&#58;= preset mod BUTTON_COUNT; // raw preset index        cellNum&#58;= &#40;&#40;index mod ROW_COUNT&#41; * &#40;COL_COUNT + 1&#41;&#41; + 1 + &#40;index div ROW_COUNT&#41;;// actual cell num        enable&#40;cellNum&#41;;    END;        END;PROCEDURE PresetChanged&#40;&#41;;         /////////////////////PRESET CHANGED////////////////var index, cellNum&#58; integer;BEGIN    page&#58;= preset div BUTTON_COUNT;  // figure out which page the preset is on      // strace&#40;'page = ' + intToStr&#40;page&#41;&#41;;     PageChanged&#40;&#41;;         setValue&#40;presetOUT, preset&#41;;END;PROCEDURE Callback&#40;n &#58; Integer&#41;;       ///////////////////////CALLBACK////////////////    VAR i, x, y, index, clicked, cellNum, column &#58; Integer;    BEGIN           CASE n of                presetsIN&#58;             BEGIN                presets.setCommaText&#40;GetStringValue&#40;presetsIN&#41;&#41;;                                       presetCount&#58;= presets.count;            END;        pagesIN&#58;             BEGIN                pages.setCommaText&#40;GetStringValue&#40;pagesIN&#41;&#41;;                              END;                                 presetIN&#58;            BEGIN                preset&#58;= trunc&#40;getValue&#40;presetIN&#41;&#41;;                PresetChanged&#40;&#41;;            END;        clickedIN&#58;            BEGIN                     cellNum&#58;= trunc&#40;getValue&#40;clickedIN&#41;&#41;;                  column &#58;= cellNum mod &#40;COL_COUNT + 1&#41;;                if &#40;column = 0&#41; then BEGIN  // it's a page number                    page &#58;= cellNum div &#40;COL_COUNT + 1&#41;;                    PageChanged&#40;&#41;;                END                 ELSE BEGIN                    index&#58;= &#40;column * ROW_COUNT&#41; + &#40;cellNum div &#40;COL_COUNT + 1&#41;&#41; - ROW_COUNT;// + ROW_COUNT;                     preset&#58;= &#40;BUTTON_COUNT * page&#41; + index;    // compute preset number                    PresetChanged&#40;&#41;;                END;             END;              END; //case    END; // Callback///////////////////////////////////////////////////////////////////////////////////////PROCEDURE Process;BEGINEND;
any tips most welcome! If I can get it working well, I'll post it to addons.

cheers,
-e

Statistics: Posted by woodslanding — 10 Aug 2013, 07:57


]]>
BrainModular BrainModular Users Forum 2013-08-28T21:44:53+02:00 https://brainmodular.org/forums/app.php/feed/topic/3995 2013-08-28T21:44:53+02:00 2013-08-28T21:44:53+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27581#p27581 <![CDATA[New matrix combo for HH]]>
1. Need the reverse, in order to create ct for output. I assume there are commands for adding to the end of a string, I'll look that up.
2. I assume usine always uses a comma as a delimiter--but we never see them in usine. If we want support for commas in line text is that even possible?? It would be nice if usine used a more robust delimiter, like n. That's what the commatext in usine usually looks like. Anyway, a version of this specific to usine's chosen delimiter would be more usefull for most usine users.

Anyway, I've filed the commatext in scripts issue as a bug, so if Olivier fixes it internally, I won't mess with this. Otherwise I'll see what I can do.

Statistics: Posted by woodslanding — 28 Aug 2013, 21:44


]]>
2013-08-20T21:34:13+02:00 2013-08-20T21:34:13+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27524#p27524 <![CDATA[New matrix combo for HH]]>

Here's my split_string function. It's not quite an instant drop-in for TStringLists but shouldn't be too hard to figure out. It does not handle embedded quotes, but you can easily add that if you need with an inside_quote boolean or whatever. I haven't added it because my textual definition formats are too simple to need it.

CODE:

function split_string&#40;const sep, str&#58; string&#41; &#58; array of string; // &#123;&#123;&#123;2var i, start, cnt, endpos, seplen&#58; integer;begin    if &#40;str = ''&#41; thenbeginSetArrayLength&#40;Result, 0&#41;;Exit;end;if &#40;sep = ''&#41; thenbeginSetArrayLength&#40;Result, 1&#41;;Result&#91;0&#93; &#58;= str;Exit;end;seplen &#58;= Length&#40;sep&#41;;SetArrayLength&#40;result, &#40;Length&#40;str&#41; div seplen&#41; + 1&#41;;i &#58;= 1;start &#58;= i;cnt &#58;= 0;while &#40;i <= &#40;Length&#40;str&#41; - seplen + 1&#41;&#41; dobeginif &#40;str&#91;i&#93; = sep&#91;1&#93;&#41; thenif &#40;Copy&#40;str, i, seplen&#41; = sep&#41; thenbeginif &#40;start < i&#41; thenResult&#91;cnt&#93; &#58;= Copy&#40;str, start, i - start&#41;elseResult&#91;cnt&#93; &#58;= '';Inc&#40;cnt&#41;;Inc&#40;i, seplen - 1&#41;;start &#58;= i + 1;end;Inc&#40;i&#41;;end;endpos &#58;= Length&#40;str&#41; + 1;if &#40;start < endpos&#41; thenResult&#91;cnt&#93; &#58;= Copy&#40;str, start, endpos - start&#41;elseResult&#91;cnt&#93; &#58;= '';Inc&#40;cnt&#41;;SetArrayLength&#40;Result, cnt&#41;;end;

Statistics: Posted by ynohtna — 20 Aug 2013, 21:34


]]>
2013-08-20T01:09:55+02:00 2013-08-20T01:09:55+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27516#p27516 <![CDATA[New matrix combo for HH]]>
Does processIdle get called at the UI update rate then, I assume? That's probably the right choice for just selecting presets....

Statistics: Posted by woodslanding — 20 Aug 2013, 01:09


]]>
2013-08-18T17:47:46+02:00 2013-08-18T17:47:46+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27502#p27502 <![CDATA[New matrix combo for HH]]>

Couldn't find any issues in a quick run through the script, though.

I seem to recall having seen similar issues with my scripts when updating individual elements of an output array and not the entire set. What I've been doing is setting a XXX_needs_update boolean inside Callback and then setting the appropriate outputs within Process or ProcessIdle (depending on whether it's realtime or UI related data). Could be worth a try?

Oh, and I've also had the same problem with comma text parsing so I've been using my own split_string function. I'm happy to share the code if you're interested.

Statistics: Posted by ynohtna — 18 Aug 2013, 17:47


]]>
2013-08-17T17:31:18+02:00 2013-08-17T17:31:18+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27500#p27500 <![CDATA[New matrix combo for HH]]>
It's eating up tons of processor now, so unusable. Maybe it's a bug.... If anyone can test it out, I'd appreciate it.

Thanks!
-e

Statistics: Posted by woodslanding — 17 Aug 2013, 17:31


]]>
2013-08-10T07:57:58+02:00 2013-08-10T07:57:58+02:00 https://brainmodular.org/forums/viewtopic.php?t=3995&p=27452#p27452 <![CDATA[New matrix combo for HH]]>
This one uses the first column to select pages, and the rest of the cells update accordingly. It can take a number in, and send a number out via a click on the matrix. I swapped the x and y axes, because I like to read down more than across....

It's basically working fine, but two small problems:

1. If I put any spaces in my pages commatext, it is mis-parsed into two elements. It looks at it as 'spaceText'.....
2. Although I'm only setting values of 1 or 0 for 'cells out', I'm seeing a lot of very small values, and the matrix buttons are changing shades (randomly?) when the first button in column 2 is pressed.

Here's the patch:
http://www.sensomusic.com/forums/upload ... omboHH.pat

and here's the code:

CODE:

////////////////////////////////////////////////////////////////////////////////////////////////CONST BUTTON_COUNT = 32;  //should be a multiple of page countCONST PAGE_COUNT = 8;VAR cellsOUT, namesOUT, presetOUT, presetsIN, pagesIN, clickedIN, presetIN&#58; tParameter;VAR pages, presets,buttonNames &#58; TStringList;var page, preset, presetCount, pageMax, ROW_COUNT, COL_COUNT, MATRIX_SIZE    &#58; integer;                   // destroyprocedure Destroy;begin   pages.free; presets.free;   buttonNames.free;end;   PROCEDURE Init;BEGIN    pagesIN &#58;= CreateParam&#40;'pages', ptTextfield&#41;; SetIsOutput&#40;pagesIN, FALSE&#41;;    presetsIN &#58;= CreateParam&#40;'presets', ptTextfield&#41;; SetIsOutput&#40;presetsIN, FALSE&#41;;    clickedIN &#58;= CreateParam&#40;'last clicked', ptDatafield&#41;; SetIsOutput&#40;clickedIN, FALSE&#41;;    presetIN &#58;= CreateParam&#40;'preset num', ptDatafield&#41;; SetIsOutput&#40;presetIN, FALSE&#41;;    cellsOut &#58;= CreateParam&#40;'cells out', ptArray&#41;; SetIsInput&#40;cellsOut, FALSE&#41;;    namesOut &#58;= CreateParam&#40;'captions out', ptTextfield&#41;; SetIsInput&#40;namesOut, FALSE&#41;;    presetOut &#58;= CreateParam&#40;'preset out', ptDatafield&#41;; SetIsInput&#40;presetOut, FALSE&#41;;    MATRIX_SIZE &#58;= PAGE_COUNT + BUTTON_COUNT;    COL_COUNT &#58;= BUTTON_COUNT div PAGE_COUNT;    ROW_COUNT &#58;= PAGE_COUNT;    setLength&#40;cellsOUT, MATRIX_SIZE &#41;;    pages.Create;    presets.Create;    buttonNames.Create;   END; // Init///////////////////////////////////////////////////////////////////////////////////////// to switch rows and columns.  x = row, y = col.  For x = 0, add the page name.  then// for x = 1 to 4, get items 0, 8, 16, and 24.  that's page_count * &#40;x-1&#41; + y//procedure UpdateButtons;var col,row,index &#58; integer;begin    buttonNames.Clear;    for row &#58;= 0 to &#40;ROW_COUNT - 1&#41; do begin  // for each row        for col &#58;= 0 to COL_COUNT do begin     // for each column--incl page column            if col = 0 then buttonNames.add&#40;pages.getStrings&#40;row&#41;&#41;  // add page row item            else begin                            index &#58;= &#40;PAGE_COUNT * &#40;col - 1&#41;&#41; + row; // get the row/col adjusted index....                if &#40;&#40;page * BUTTON_COUNT&#41; + index&#41; >= presetCount then begin                    buttonNames.add&#40;'---'&#41;;                   end else begin                          buttonNames.add&#40;presets.getStrings&#40;&#40;page * BUTTON_COUNT&#41; + index&#41;&#41;;                end;            end;        end;    end;    setStringValue&#40;namesOUT, buttonNames.getCommatext&#41;;end;PROCEDURE clearMatrix&#40;&#41;;             //////////////////CLEAR MATRIX////////////////////   var i &#58; integer;BEGIN       for i &#58;= 0 to &#40;MATRIX_SIZE - 1&#41; DO   BEGIN           setDataArrayValue&#40;cellsOUT,i,0&#41;;            strace&#40;'cell zeroed&#58; ' + intToStr&#40;i&#41;&#41;;           END;END;                                               PROCEDURE enable&#40;index &#58; integer&#41;;    /////////////////ENABLE////////////////////////BEGIN    setDataArrayValue&#40;cellsOUT, index, 1.0&#41;;END;PROCEDURE PageChanged&#40;&#41;;         /////////////////////PAGE CHANGED////////////////var index, cellNum&#58; integer;BEGIN    UpdateButtons&#40;&#41;;    ClearMatrix&#40;&#41;;    enable&#40;page * &#40;COL_COUNT + 1&#41;&#41;;    if &#40;preset div BUTTON_COUNT&#41; = page then  // if the preset is on the current page....    BEGIN        index&#58;= preset mod BUTTON_COUNT; // raw preset index        cellNum&#58;= &#40;&#40;index mod ROW_COUNT&#41; * &#40;COL_COUNT + 1&#41;&#41; + 1 + &#40;index div ROW_COUNT&#41;;// actual cell num        enable&#40;cellNum&#41;;    END;        END;PROCEDURE PresetChanged&#40;&#41;;         /////////////////////PRESET CHANGED////////////////var index, cellNum&#58; integer;BEGIN    page&#58;= preset div BUTTON_COUNT;  // figure out which page the preset is on      // strace&#40;'page = ' + intToStr&#40;page&#41;&#41;;     PageChanged&#40;&#41;;         setValue&#40;presetOUT, preset&#41;;END;PROCEDURE Callback&#40;n &#58; Integer&#41;;       ///////////////////////CALLBACK////////////////    VAR i, x, y, index, clicked, cellNum, column &#58; Integer;    BEGIN           CASE n of                presetsIN&#58;             BEGIN                presets.setCommaText&#40;GetStringValue&#40;presetsIN&#41;&#41;;                                       presetCount&#58;= presets.count;            END;        pagesIN&#58;             BEGIN                pages.setCommaText&#40;GetStringValue&#40;pagesIN&#41;&#41;;                              END;                                 presetIN&#58;            BEGIN                preset&#58;= trunc&#40;getValue&#40;presetIN&#41;&#41;;                PresetChanged&#40;&#41;;            END;        clickedIN&#58;            BEGIN                     cellNum&#58;= trunc&#40;getValue&#40;clickedIN&#41;&#41;;                  column &#58;= cellNum mod &#40;COL_COUNT + 1&#41;;                if &#40;column = 0&#41; then BEGIN  // it's a page number                    page &#58;= cellNum div &#40;COL_COUNT + 1&#41;;                    PageChanged&#40;&#41;;                END                 ELSE BEGIN                    index&#58;= &#40;column * ROW_COUNT&#41; + &#40;cellNum div &#40;COL_COUNT + 1&#41;&#41; - ROW_COUNT;// + ROW_COUNT;                     preset&#58;= &#40;BUTTON_COUNT * page&#41; + index;    // compute preset number                    PresetChanged&#40;&#41;;                END;             END;              END; //case    END; // Callback///////////////////////////////////////////////////////////////////////////////////////PROCEDURE Process;BEGINEND;
any tips most welcome! If I can get it working well, I'll post it to addons.

cheers,
-e

Statistics: Posted by woodslanding — 10 Aug 2013, 07:57


]]>