[script] delta and unpack
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.
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.
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?
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.
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.
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.
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.
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).
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
@ 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!
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!
Ok.
thank you
thank you
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!)
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!)
@ 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..
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..
Thanks!! 
Testing...
Testing...
Who is online
Users browsing this forum: No registered users and 69 guests
