Interpolating MIDI values

MikEyhaTsis's icon

so I just received my Doepfer R2M today. Nice!! So one mode on this controller sends out:
1. a note on message when the ribbon controller is touched
2. a cc number and value when you slide your finger ( or any object ) across the ribbon.
3 a note off message when you release or pull off.

So, this thing is 50cm long id like to be able to break it up into say 3 "zones" at about 17cm each, each zone would have a range for incoming cc values of 42- then map the 42 values to the 127 possible cc values. for the first "zone" it would be something like:

incoming to max -> outgoing from max
1 -> 1
2 -> 4
3 -> 7
4 -> 10...
21 -> 64
42 -> 127
Great! that would work. but id like to get smooth transitions ( hit every cc value ) and be able to interpolate the missing cc values. basically have something like this:

incoming to max -> outgoing from max
1 -> 1,2,3
2 -> 4,5,6
3 -> 7,8,9
4 -> 10,11,12 ...
21 -> 63,64,65
42 -> 125,126,127

anyone know of an object, technique, suggestion that will let me do this possibly based on the acceleration of moving from one cc value to the next? Or maybe its time i break out my old college calculus book.

Any help would be really appreciated

seejayjames's icon

...calculus only if you're reeeeal into it.

You can use a function with the expr object, or play with the exponent of the scale object (something like "scale 0 41 0 127 1.02" might work). But more fun and a lot more flexible is to use a table with 42 points on the X and 128 (0 - 127) on the Y. Draw the curve (or other wackiness) that you want, then the incoming values (0 - 41) trigger the Y values. Draw additional tables for the other two zones if you want them to respond differently... Preset also works with tables, as does pattr, so you can save different curves and switch them on the fly. Lots of musicality there.

To make the in-between values, use an integer-based line object on the table's output Y values. Tweak the line time and time grain values to what you want -- you can easily make these settable too (more responsive / jerky with short times, or more smooth / sloppy with longer ones). This will fill in the missing values, to whatever degree you want, and can make "beats" of the changing values --- try a 1000 ms line and a 250 ms time grain, you get 4 250 ms "steps" in your values.

I'd like one a them ribbon controllers too...
have fun

--CJ

LoneMonad aka don malone's icon

you could use your trackpad as a ribbon with [mousestate]

i wonder if it is possible to separate the trackpad from the mouse

LoneMonad aka don malone's icon

you could also use a camera as an air ribbon

seejayjames's icon

Actually am using an infrared range sensor thru an Arduino for gestural CC's. Works pretty well though there's stutter (like all analog reads). Inexpensive and pretty straightforward to implement.

Raising one's hand to change pitch or volume is pretty intuitive, and gets one away from the mouse for a bit.

--CJ

Stefan Tiedje's icon

mHatsys schrieb:
> anyone know of an object, technique, suggestion that will let me do
> this possibly based on the acceleration of moving from one cc value
> to the next? Or maybe its time i break out my old college calculus
> book.

According to Doepfers web site, the controller is 12-bit. That means you
can receive the LSB's on a different controller number (+32) as well.
Use those for the higher precision.

Or use my ctl.in, which pulls out the a float value between 0. and 128.
as direct replacement for ctlin...
Then just calculate with floats to get the intermediate values...

(Ah, its not on the recent distri...)
I'll update my St.ools to carry the ctl.in abstraction soon...

But as you can set the R2M also to transmit pitchbend, I'd just set it
to that and receive with xbendin...

Stefan

--
Stefan Tiedje------------x-------
--_____-----------|--------------
--(_|_ ----|-----|-----()-------
-- _|_)----|-----()--------------
----------()--------www.ccmix.com

MikEyhaTsis's icon

Quote: seejayjames wrote on Wed, 31 October 2007 02:44
----------------------------------------------------
> ...calculus only if you're reeeeal into it.
>
> You can use a function with the expr object, or play with the exponent of the scale object (something like "scale 0 41 0 127 1.02" might work). But more fun and a lot more flexible is to use a table with 42 points on the X and 128 (0 - 127) on the Y. Draw the curve (or other wackiness) that you want, then the incoming values (0 - 41) trigger the Y values. Draw additional tables for the other two zones if you want them to respond differently... Preset also works with tables, as does pattr, so you can save different curves and switch them on the fly. Lots of musicality there.
>
> To make the in-between values, use an integer-based line object on the table's output Y values. Tweak the line time and time grain values to what you want -- you can easily make these settable too (more responsive / jerky with short times, or more smooth / sloppy with longer ones). This will fill in the missing values, to whatever degree you want, and can make "beats" of the changing values --- try a 1000 ms line and a 250 ms time grain, you get 4 250 ms "steps" in your values.
>
> I'd like one a them ribbon controllers too...
> have fun
>
> --CJ
----------------------------------------------------

Big Thanks...Tables work perfectly for this and as you said you can play with the curves! really funfor sweep fex. also i get to play with a new data structure... gonna look into the line object now but the stepped effect generated by missing cc values sounds really cool on some setups.

seejayjames's icon

That's great... tables are really handy. Wish you could colorize them, but hey.

The bang out the right outlet when the table is edited allows you to make "undo" states too, if you want... bang to counter, store $1 stores an incrementing preset of the table contents. Can be very handy, and then you can choose any of your previous states. Put a gate after the bang so you can choose whether to make undos at a given time. Especially useful for things like note selections, or creating a bunch of different curves. See patch below for an example.

The line isn't totally straightforward, read the help file carefully (sometimes some trickery is needed to get just what you want). It's very useful though.

Talking about data structures, look into pattr as soon as possible. This is real power for your data!

mtr is also fantastic and very useful... as an example, using mtr to record changing pattr access values is an easy way to get all kinds of changing parameters... dozens if you want...

Have fun,
CJ

-------------------------

Max Patch
Copy patch and select New From Clipboard in Max.


MikEyhaTsis's icon

Many Thanks...This is perfect. With the xbend receiving 12-bit i get a range of 0 - 14000. this combined with the table object is a great solution. thanks again.

Quote: Stefan Tiedje wrote on Thu, 01 November 2007 05:04
----------------------------------------------------

> According to Doepfers web site, the controller is 12-bit. That means you
> can receive the LSB's on a different controller number (+32) as well.
> Use those for the higher precision.
>
> Or use my ctl.in, which pulls out the a float value between 0. and 128.
> as direct replacement for ctlin...
> Then just calculate with floats to get the intermediate values...
>
> (Ah, its not on the recent distri...)
> I'll update my St.ools to carry the ctl.in abstraction soon...
>
> But as you can set the R2M also to transmit pitchbend, I'd just set it
> to that and receive with xbendin...
>
> Stefan
>
> --
> Stefan Tiedje------------x-------
> --_____-----------|--------------
> --(_|_ ----|-----|-----()-------
> -- _|_)----|-----()--------------
> ----------()--------www.ccmix.com
>
>
>
----------------------------------------------------

MikEyhaTsis's icon

Thanks again SeeJay!!!

Lots of fun stuff to try in your post. MTR is really fun. You can just step through undoes. Also record the MIDI input from the R2M and loop it back. possibilities are endless...

peace,
Mike

seejayjames's icon

endless is Max's middle name. Or is it MSP? I forget.

Look at the leftmost outlet of mtr. If you use a "next" to step thru values, you can tweak the delay times between them. So with only one track (easiest to implement) you can speed up or slow down the playback. seq can be used for this too.

also look at seq~, which will let you record control data and play it back at any speed you want. Doesn't have 32 tracks like mtr, but the variable rate is cool.

--CJ

chris cousin's icon

>
> To make the in-between values, use an integer-based line object on the table's output Y values. Tweak the line time and time grain values to what you want -- you can easily make these settable too (more responsive / jerky with short times, or more smooth / sloppy with longer ones). This will fill in the missing values, to whatever degree you want, and can make "beats" of the changing values --- try a 1000 ms line and a 250 ms time grain, you get 4 250 ms "steps" in your values.
>
hi seejayjames

how would you measure how quickly the knob was being turned to then apply a shorter or longer line time?

any recomended links / study for controllers, midi mapping and interpolation stuff?

thank

chris