Welcome to %s forums

BrainModular Users Forum

Login Register

[script] delta and unpack

I need help on a Patch
Post Reply
23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 12 Aug 2010, 01:10

this are two concepts i fail a bit via script, the rest start slowly to enter my head.

how can we get delta of an input, or of an array elmt?, ...and probably more complex, how could i 'unpack' values of an array to be processed bloc after bloc.

ie instead of using 8 osc modules or sending a bloc each time the value(s) of an array has changed for polyphonic, i dlike to
use a single module, and a script would decode changes in the array, index positions and values of datas that have
changed, then if some are simultaneous it would eiteir be able to generate an adapted sized array out, or
"unpack" the values to be processed one after the other, bloc after bloc.

any advice/trick/approach MasterZ?


to make it simpler exemple:
ie feed an array of size 16, i move fader 1,3 and 5 simultaneously, and the script:
_detects only values that changed in array, tracks index and value
_A) generate a 3size array with indexs, and a 3size Values arrays
or B) output bloc after bloc index1value1, id3val3, id5val5.

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 12 Aug 2010, 02:03

is this something like creating an array using only the non-zero elements of a matrix, while keeping track of the original index positions from the matrix?

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 12 Aug 2010, 03:09

mmm, kind of, but ideally it should also work if i set an element to 0, it would be more 'tracking wich elements have changed",
but yes, get their values and original indexes.
matrix is not multitouch yet , but steps are,so it's finding a solution when simultaneous steps are edited, ie dual touch
to send only the values that changed, with a single midi/osc module. ..

edit: i finally found the solution by patch, maybe got to figure how to convert to script now..

the solution i found is for case B) 'unpack' bloc after bloc,
and if i make a little script i should have A)variable size arrays, as well.. this need a sub block operation so can't do by
patch.

basically used a delta on the array in, if delta <>0 the array element are 1, i count sum array to get nb of simultaneous events,
i multiply by another 'indexed' array that goes from 1 to 16 to get the indexes,data that are 0 didn't changed, otherwise it's index value. so then sort array and extract the small array with only values that changed indexes,a counter scan the original array for those indexes to get values and send them one after the other. a bit tricky but seems working nice.

hope it's an optimized way when dealing with midi/osc to avoid overloads or too much data sending by sending each time
whole array. here it toggles one data after the other in case of dual touch or more, also i will get an extra latency/ reduced sampling rate if too much simultaneous events, cause if 5 touches each data is scaned each 5 blocs, but that's
15ms for 5 touch at 128samples, and most of the time it will be single or dual touch i guess so it must be ok....

if some are interested i can clean the patch and post, let me know.

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 12 Aug 2010, 04:13

I'm building a pianoroll using matrix and I think your module could be useful for me when dealing with simultaneous notes in the same time position (poliphony): I need a way to count the number of different notes and their position in the index (time index).

At the same time, I want to do the same for velocity and eventually for many other parameters like pan, volume, etc. Considering the note number ranges between 0 and 127, I believe it is challenging to keep the sync on track.

bsork
Site Admin
Posts: 1334
Location: Asker, Norway
Contact:

Unread post by bsork » 12 Aug 2010, 08:23

You seemed to have found a smart way of using modules to extract the deltas! :) However, here's an idea of how to accomplish the same within a script:

Create an internal array with the old input values, make a loop to check which values has changed every time time there's a callback on the input array. Put the changed indexes and values into a queue (similar to eg the Make Monophonic MIDI script), update the internal array, and finally output one or several index/value pairs per block (as long as there's something in the queue, of course).
Bjørn S

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 12 Aug 2010, 12:25

@ floego: by waiting a script ican post ya the patch tonight, you ll just need to replace my "have changed" array by "is <>0?" in your case, to check the column array relating time index, but it should work the same then for unpack function,
i lltry to make a quick test to replace to what ya need.

@ bsork. yup i need to test that!!!

i have just some pb seeing how to deal 'old/new' values in callbacks, when/how should i store the 'old' values, as i guess it's not as the same time of input change, maybe one bloc later in process? but i will have a look at mono midi, i knew ive seen some unpackin script somewhere. thanks!

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 12 Aug 2010, 12:41

Ok.
thank you :)

gurulogic
Member
Posts: 1019
Contact:

Unread post by gurulogic » 12 Aug 2010, 22:17

hehe, maybe we need a separate scripting questions section of the forum so that all the scripting tips can be in the same place?
Seems to be more scripting than patching these days...
(I am still probably never going to understand scripting regardless, but maybe slowly some of it will start to make sense for me!)

23fx23
Member
Posts: 2545
Contact:

Unread post by 23fx23 » 13 Aug 2010, 00:15

@ guru, you re right, I think so, would be cool! exemples help a lot and there are a lot but spread all over the forum,
put them in a single place with ressources and discussions could be nice...

@ floego
sorry man i went very late back from work,
ive uploaded my test patch, with a second version that should more match your needz for matrix col,
unfortunately couldn't test, but logically should work, let me know...

[http://sensomusic.com/forums/uploads.ph ... ck%20F.wkp]Unpack Array Patch version[/url]

now the big deal, make the same via script .. maybe this we..

Floego
Member
Posts: 319
Location: Venezuela
Contact:

Unread post by Floego » 13 Aug 2010, 01:33

Thanks!! :D
Testing...

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests