converting absolute controllers to relative,

Apr 6, 2006 at 9:27pm

converting absolute controllers to relative,

Hello,

I’m about to build an object to convert absolute MIDI data to relative,
but before I do, I just wanted to make sure no one else has already done
this. A quick search of the forum and maxobjects tells me “no” – but you
never know…

Yes, it may seem strange to want to do this, but I have here the new
faderfox LV1 and it has 13 modes of absolute rotary knobs set to
absolute, which is silly, so I want to remap them to be relative [since
its rotary encoders]

wk,

seb.

#25271
Apr 7, 2006 at 9:01am

Hello,

If an abstraction rather than an object is OK for you, have a look at
this patcher…

Roald Baudoux

max v2;
#N vpatcher 10 58 742 557;
#P window setfont “Sans Serif” 9.;
#P number 347 262 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#N vpatcher 71 89 511 458;
#P window setfont “Sans Serif” 9.;
#P newex 126 81 27 196617 -1;
#P window linecount 0;
#P newex 157 266 27 196617 t b i;
#P newex 165 292 63 196617 pv stockage;
#P window linecount 1;
#P newex 126 230 39 196617 !- 128;
#P newex 126 203 70 196617 split -128 -1;
#P newex 85 81 27 196617 1;
#P newex 126 175 70 196617 +;
#P newex 126 152 63 196617 pv stockage;
#P newex 126 131 70 196617 t b i;
#P newex 186 231 40 196617 % 128;
#P newex 85 55 92 196617 sel -127 127;
#P inlet 85 35 15 0;
#P outlet 165 315 15 0;
#P connect 1 0 2 0;
#P connect 2 0 7 0;
#P connect 2 1 12 0;
#P connect 2 2 4 0;
#P connect 12 0 4 0;
#P connect 7 0 4 0;
#P connect 4 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 8 0;
#P connect 8 0 9 0;
#P connect 9 0 11 0;
#P connect 3 0 11 0;
#P connect 11 0 10 0;
#P connect 11 1 10 0;
#P connect 10 0 0 0;
#P connect 4 1 6 1;
#P connect 8 1 3 0;
#P pop;
#P newobj 347 290 48 196617 p rotary;
#P newex 347 236 27 196617 -;
#P newex 364 211 39 196617 bucket;
#P user dial 347 321 40 40 128 1 0 0 159 359 1 1. 170 170 170 221 221
221 120 120 120 225 225 225 0 0 0 0 0 0;
#P user dial 347 150 40 40 128 1 0 0 159 359 1 1. 170 170 170 221 221
221 120 120 120 225 225 225 0 0 0 0 0 0;
#P comment 294 92 148 196617 Absolute to relative controller;
#P comment 295 113 150 196617 Raold Baudoux , april 7th 2006.;
#P connect 2 0 5 0;
#P connect 5 0 7 0;
#P connect 7 0 6 0;
#P connect 6 0 3 0;
#P connect 2 0 4 0;
#P connect 4 0 5 1;
#P pop;

Roald Baudoux

#74244
Apr 7, 2006 at 12:25pm

wow thats more than i was expecting! thanks!
i especially like how you use the “bucket” object, elegant.

however, its not this simple, since i need to go from:

0-127

to:

1+ = up
127- = down

and at the edges, when the rot knob is spinning in only one direction it initially sends values say from 127 down to 0 and then it just keeps sending 0′s with every ‘tick’ in the left dir. Same thing with the updirection, great relative 2 bits until it hits 127 and then it just sends 127 out.

My follow up question is; how can I measure the the rate of the knob spin [to translate it into an integer in "relative 2's compared" format] in an elegant manner?

The only solution I can think of is to have a seperate clock/metro running which measures the rate at which the successive 0′s or 127′s enter to then translate that into a more meaningful value… but this doesn’t feel right; too complicated.

Would anyone have an alternative method for measuring “rate of change” at the edges?

Once i’ve built the converter for the faderfox LV2 [incl. listeners for the correct midi cc, ch its set to], I’ll post it so others can also use it.
:)

Here is what I have so far:

#P window setfont “Sans Serif” 9.;
#P window linecount 3;
#P comment 18 406 100 196617 out to other program via internal max midi port;
#P window linecount 2;
#P comment 236 37 100 196617 faderfox physical in port;
#P window linecount 1;
#P newex 132 329 125 196617 if $i1 > 0 then 1 else 127;
#P newex 132 216 20 196617 t b;
#P newex 132 238 27 196617 i 0;
#P newex 15 149 46 196617 select 0;
#P newex 63 306 35 196617 + 128;
#P newex 15 256 58 196617 split 0 127;
#P newex 15 119 27 196617 -;
#P newex 32 68 39 196617 bucket;
#P newex 15 385 218 196617 ctlout c;
#P newex 15 36 218 196617 ctlin a;
#P window linecount 6;
#P comment 259 346 100 196617 this works but limits you to a small distance change when the abs controller is at min or max… :-(;
#P window linecount 1;
#P comment 259 331 100 196617 < ---------;
#P fasten 8 1 6 0 56 190 20 190;
#P fasten 8 1 9 1 56 190 154 190;
#P connect 2 0 5 0;
#P connect 2 0 4 0;
#P connect 5 0 8 0;
#P connect 11 0 3 0;
#P fasten 7 0 3 0 68 352 20 352;
#P connect 6 0 3 0;
#P connect 2 1 3 1;
#P connect 2 2 3 2;
#P connect 4 0 5 1;
#P connect 6 1 7 0;
#P connect 8 0 10 0;
#P connect 10 0 9 0;
#P connect 9 0 11 0;
#P window clipboard copycount 14;

Thanks again,

S Chedal.

#74245
Apr 7, 2006 at 6:40pm

#74246
Apr 7, 2006 at 6:49pm

I guess it has something to do with the mouse tracking. The 0s and 127s
are there because you do not have a change of value for every mouse
displacement. That’s quite logical because you get only 128 values for
something like 360 degrees. You can get rid of these values by
inserting a change object at the output of the dial but I guess this
wouldnt’ happen with a slider or a real MIDI controller.

However some jumps still happen…

Roald Baudoux

#74247
Apr 7, 2006 at 8:28pm

Thanks Roald Baudoux,

Couple of things:

1st: I resolved the issue by realizing that the faderfox has a feedback
system so I don’t need to transform the abs to relative anymore! doh!
and: youpie!
:)

2nd: I have made a new feature for the LV2 called “auto track select on
fader touch” – many other LV2 owners may find this useful, you can find
the code at the bottom of this email.

For the book, let me at least clarify what the issue was:
Ok, I guess I was not very clear…

Here is an example:
When I turn the external abs controller to the right, it sends the
following data:
{123,124,125,126,127,127,127,127,127,…}

If I turn it fast to the right it could send something like this:
{100,104,108,112,120,127,127,127,127,127,…}

In both cases, the code works because it moves a relative signed 2 bit
controller in my software [Ableton live].

However, in “case one” I am turning slowly, in case two I am turning
fast. When i reach the end of the data range of the absolute controller
it sends out “127″ no mater how fast i am turning the knob; so I need
some other mechanism to determine how fast I am turning otherwise I get
a non-linear/unpredictable output. Hence my idea to use a counter to
measure the rate at which the “127″ data enters the system.

The output of the system is either 1 or 127. But the way relative 2 bit
works is that you can also have an output of 4 or 122. A “4″ means move
up 4 steps and a “122″ means move down 128-122=6 steps. this makes it
possible to “spin” these kinds of relative controllers quickly for rapid
changes – a form of smart acceleration.

What i was asking is if there was a smart / elegant way to measure a
rate of change, or if the only way to measure rate is to use a
time-control object; like metro?


LV2 feature addition: Auto select track on fader touch: Connect the out
port of your system back to the LV2 to have the LV2 auto-switch tracks
when moving a fader! Enjoy!
;)

#P window setfont “Sans Serif” 9.;
#P window linecount 8;
#P comment 139 482 124 196617 set the note out port to be the faderfox
to make the faderfox change its select track mode OR set this to be the
internal sequencer and then set that program to feedback to the faderfox
- patch by S. Chedal 2006;
#P window linecount 1;
#P newex 145 430 85 196617 unpack 127 1 15;
#P newex 145 461 85 196617 noteout b;
#P newex 47 171 52 196617 select 15;
#P newex 47 204 71 196617 listreg;
#P newex 47 142 25 196617 last;
#P newex 352 303 58 196617 t b 21 127;
#P newex 291 303 58 196617 t b 20 127;
#P newex 230 303 58 196617 t b 19 127;
#P newex 169 303 58 196617 t b 18 127;
#P newex 108 303 58 196617 t b 17 127;
#P newex 145 403 75 196617 pack 127 1 15;
#P window linecount 5;
#P comment 431 266 100 196617 if it matches one of these , make a note
- this row triggers a track select note for the faderfox LV2;
#P window linecount 1;
#P newex 47 303 58 196617 t b 16 127;
#P newex 47 104 45 196617 butfirst;
#P newex 47 269 380 196617 route 0 1 2 3 4 5;
#P newex 47 27 64 196617 ctlin a;
#P newex 47 74 64 196617 pack 1 1 1;
#P window linecount 2;
#P comment 99 103 123 196617 interpret the ch value , discard value data;
#P window linecount 1;
#P newex 116 372 118 196617 borax;
#N vpatcher 90 195 690 595;
#P window setfont “Sans Serif” 9.;
#P newex 14 52 44 196617 t i i i;
#P newex 14 169 46 196617 select 1;
#P newex 14 144 27 196617 != 0;
#P newex 14 199 27 196617 i 0;
#P newex 31 82 39 196617 bucket;
#P newex 14 112 27 196617 -;
#N comlet int: no doubles;
#P inlet 14 32 15 0;
#N comlet supress double outlet;
#P outlet 14 221 15 0;
#P connect 1 0 7 0;
#P connect 7 0 2 0;
#P connect 2 0 5 0;
#P connect 5 0 6 0;
#P connect 6 0 4 0;
#P connect 4 0 0 0;
#P connect 7 1 3 0;
#P connect 3 0 2 1;
#P fasten 7 2 4 1 53 73 81 73 81 194 36 194;
#P pop;
#P newobj 47 238 81 196617 p noDuplicateInt;
#P connect 5 5 14 0;
#P connect 5 4 13 0;
#P connect 5 3 12 0;
#P connect 7 0 1 2;
#P connect 10 0 1 2;
#P connect 11 0 1 2;
#P connect 12 0 1 2;
#P connect 13 0 1 2;
#P connect 14 0 1 2;
#P connect 19 2 18 2;
#P connect 19 1 18 1;
#P connect 1 4 9 1;
#P connect 7 2 1 1;
#P connect 10 2 1 1;
#P connect 11 2 1 1;
#P connect 12 2 1 1;
#P connect 13 2 1 1;
#P connect 14 2 1 1;
#P connect 5 2 11 0;
#P connect 19 0 18 0;
#P connect 9 0 19 0;
#P connect 1 3 9 0;
#P connect 7 1 1 0;
#P connect 10 1 1 0;
#P connect 11 1 1 0;
#P connect 12 1 1 0;
#P connect 13 1 1 0;
#P connect 14 1 1 0;
#P connect 5 1 10 0;
#P connect 6 0 15 0;
#P fasten 6 0 16 1 52 129 113 129;
#P connect 4 2 3 2;
#P connect 4 1 3 1;
#P connect 5 0 7 0;
#P connect 0 0 5 0;
#P connect 16 0 0 0;
#P fasten 17 0 16 0 52 209 52 209;
#P connect 15 0 17 0;
#P connect 3 0 6 0;
#P connect 4 0 3 0;
#P window clipboard copycount 21;

#74248
Apr 7, 2006 at 8:39pm

#74249
Apr 8, 2006 at 12:40am

If I understand correctly, you should be able to just trigger dec- or
incrementation. If you’re getting a stream of 127s, you should
transform that into a stream of +1s, if that makes sense… assuming
your controller does not skip values when used quickly. Otherwise it’s
unreliable.

For rate of change, off the top of my head, you might want to look into
thresh and zl len. Haven’t tried this one myself but it seems workable.

#74250
Apr 8, 2006 at 4:36am

Here is a version I made that responds to rate of the input from a relative controller. It was made for the jog wheel of a US-224 so its input values ( inc and dec) may need to be changed for your purposes.

HTH

S.

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 71 451 54 196617 line 0 200;
#P newex 68 265 32 196617 + 0.5;
#N comlet increment/decrement input from jog wheel (1 = up , 127 = down);
#P inlet 105 117 15 0;
#N comlet Output of variable rate controller (0-127);
#P outlet 71 498 15 0;
#P newex 81 311 45 196617 loadbang;
#P newex 145 203 27 196617 gate;
#P newex 227 205 27 196617 gate;
#P newex 71 422 58 196617 split 0 127;
#P newex 197 335 27 196617 int;
#P newex 163 335 27 196617 int;
#P newex 197 308 32 196617 * 1.;
#P newex 162 307 33 196617 * 1.;
#P message 81 349 14 196617 0;
#P flonum 68 286 58 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 69 226 20 196617 80;
#P newex 68 244 34 196617 / 1.;
#P number 92 203 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 92 182 33 196617 timer;
#P newex 141 417 27 196617 > 0;
#P newex 172 416 34 196617 < 127;
#P button 137 312 15 0;
#P message 196 242 19 196617 -1;
#P message 145 239 14 196617 1;
#P newex 141 379 82 196617 accum;
#P button 105 156 15 0;
#P newex 162 168 174 196617 sel 1 -1;
#P window setfont “Sans Serif” 10.;
#P window linecount 5;
#P comment 17 48 341 196618 Variable rate control wheel patch. Rapid changes in dial produce greater leaps in controller value output. Slow movements result in small values. Useful for converting relative rotary dials and jog dials to absolute. This version specifically designed for the US-224 jog wheel;
#P window setfont “Sans Serif” 9.;
#P window linecount 3;
#P comment 13 205 50 196617 overall rate ratio set here;
#P window linecount 2;
#P comment 158 461 100 196617 Values clamped to MIDI range (0-127);
#P window setfont “Sans Serif” 12.;
#P window linecount 1;
#P comment 16 26 261 196620 rotary->midi (relative->absolute);
#P connect 4 1 23 1;
#P fasten 11 0 23 0 146 447 273 447 273 194 232 194;
#P connect 16 0 18 1;
#P connect 16 0 19 1;
#P connect 19 0 21 0;
#P connect 8 0 9 0;
#P connect 8 0 19 0;
#P connect 23 0 8 0;
#P connect 20 0 6 1;
#P connect 21 0 6 1;
#P connect 6 0 22 0;
#P connect 6 0 11 0;
#P connect 6 0 10 0;
#P connect 18 0 20 0;
#P connect 7 0 9 0;
#P connect 7 0 18 0;
#P connect 4 0 24 1;
#P connect 27 0 5 0;
#P connect 27 0 4 0;
#P connect 24 0 7 0;
#P fasten 10 0 24 0 177 447 272 447 272 194 150 194;
#P connect 17 0 6 0;
#P connect 9 0 6 0;
#P connect 5 0 12 0;
#P connect 5 0 12 1;
#P connect 13 0 15 0;
#P connect 13 0 14 1;
#P connect 12 0 13 0;
#P connect 25 0 17 0;
#P connect 29 0 26 0;
#P connect 22 0 29 0;
#P connect 28 0 16 0;
#P connect 14 0 28 0;
#P connect 15 0 14 0;
#P window clipboard copycount 30;

#74251
Apr 8, 2006 at 6:38am

inforazor wrote:
> My follow up question is; how can I measure the the rate of the knob
> spin [to translate it into an integer in "relative 2's compared"
> format] in an elegant manner?

Have a look at my dialin objects @ cycling/share.

Stefan

[][] [][][] [][] [][][]
[][][][][][][][][][][][][][][]

Stefan Tiedje
Klanggestalter
Electronic Composition
&
Improvisation

/~~~~~
\ /|() ()|
))))) )| | |( \
/// _/)/ )))))
___/ ///

————————-x—-
–_____———–|———–
–(_|_ —-|—–|—–()—-
– _|_)—-|—–()———–
———-()————x—–

14, Av. Pr. Franklin Roosevelt,
94320 Thiais, France
Phone at CCMIX +33-1-57 42 91 09

#74252

You must be logged in to reply to this topic.