## Interpolating MIDI values

Oct 31, 2007 at 5:47am

# Interpolating MIDI values

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

#34393
Oct 31, 2007 at 8:44am

…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

#115939
Oct 31, 2007 at 9:45am

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

#115940
Oct 31, 2007 at 9:48am

you could also use a camera as an air ribbon

#115941
Oct 31, 2007 at 10:02am

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

#115942
Nov 1, 2007 at 11:04am

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

#115943
Nov 2, 2007 at 10:08am

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.

#115944
Nov 2, 2007 at 4:35pm

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

————————-

#P window setfont “Sans Serif” 14.;
#P window linecount 1;
#P comment 113 31 236 9109518 access presets by number;
#P window setfont “Sans Serif” 9.;
#P message 63 118 51 9109513 set \$1;
#P window setfont “Sans Serif” 14.;
#P number 64 31 44 14 1 256 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 132 56 77 9109518 clearall;
#P number 215 263 44 14 1 256 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P comment 349 239 153 9109518 256 max presets;
#P number 139 173 44 14 0 127 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 139 97 44 14 0 127 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P button 273 202 21 0;
#N counter 1 256;
#X flags 0 0;
#P newobj 215 235 128 9109518 counter 1 256;
#P newex 215 199 50 9109518 gate;
#P toggle 215 166 24 0;
#P message 216 288 77 9109518 store \$1;
#N vpreset 10;
#X append 1 1 1 133 139 table set 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
#X append 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
#X append 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0;
#X append 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ;;
#X append 2 1 1 133 139 table set 0 0 1 1 2 3 4 5 6 6 7 8 9 10 10 11 12 12 13 14 15 16 17 18 19 20 21 21 22 23 23 25 26 27 28;
#X append 2 1 29 29 31 32 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 53 54 55 55 56 58 59 59 60 61 62 63 64 65;
#X append 2 1 66 67 68 69 70 71 71 73 74 74 75 76 77 78 79 80 81 82 83 84 85 86 86 88 89 90 91 92 93 93 94 95 97 98 100 101 101 103 104 105;
#X append 2 1 106 108 109 110 111 112 115 116 117 119 120 121 123 127 ;;
#X append 3 1 1 133 139 table set 0 108 108 109 109 109 109 110 110 110 110 110 110 110 110 110 110 110 109 109 109 108 107 107 106 105 104 103 102 101 99 98 96 94 91;
#X append 3 1 90 87 84 79 74 70 67 64 62 61 60 58 57 56 56 55 55 55 55 55 55 56 56 56 57 57 57 58 58 59 59 60 61 61 62 62 63 63 64 65;
#X append 3 1 65 66 66 66 66 67 67 67 67 67 67 66 66 65 65 64 64 63 62 61 60 58 57 55 53 52 49 48 45 43 41 39 37 34 33 31 29 27 25 24;
#X append 3 1 21 19 16 13 12 10 9 7 5 4 3 1 0 0 ;;
#X append 4 1 1 133 139 table set 0 108 33 34 34 35 35 35 36 37 37 37 38 38 38 38 39 39 39 39 39 39 40 40 40 40 40 40 41 41 41 41 41 42 42;
#X append 4 1 42 42 42 42 42 42 42 42 42 41 41 41 40 40 39 39 39 39 38 38 38 37 37 37 37 37 37 37 37 37 37 37 38 38 39 39 39 40 40 41;
#X append 4 1 41 42 42 43 44 45 46 47 48 49 51 52 53 54 55 56 58 59 60 61 62 63 64 65 66 67 69 70 71 73 73 75 77 78 80 80 82 83 85 86;
#X append 4 1 88 89 91 93 95 97 99 101 103 106 110 112 116 127 ;;
#P preset 64 56 58 58;
#N vtable 128 633 134 1076 533 999901 128 undo;
#P newobj 139 133 115 9109518 table undo 1;
#P comment 300 205 123 9109518 restart undos;
#P hidden connect 13 0 2 0;
#P hidden connect 14 0 2 0;
#P hidden connect 2 1 14 0;
#P hidden connect 12 0 2 0;
#P hidden connect 2 0 1 0;
#P hidden connect 11 0 3 0;
#P hidden connect 6 0 11 0;
#P hidden connect 1 0 9 0;
#P hidden connect 8 0 1 0;
#P hidden fasten 3 0 2 0 51 288 51 42;
#P hidden connect 5 0 6 0;
#P hidden connect 7 0 6 2;
#P hidden connect 4 0 5 0;
#P hidden connect 1 1 5 1;
#P window clipboard copycount 16;

#115945
Nov 2, 2007 at 7:27pm

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
>
>
>
—————————————————-

#115946
Nov 6, 2007 at 9:01pm

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

#115947
Nov 8, 2007 at 7:54am

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

#115948
Nov 9, 2007 at 1:32pm

>
> 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

#115949

You must be logged in to reply to this topic.