Convert CC to note velocity

cnzlf's icon

Hello,

How do I assign a midi knob (CC22) to control the velocity of a note?

For example, if I play C4 in my Akai keyboard, I want the position of the knob CC22 to set the velocity, instead of the key I'm playing.

I can't find a way to override the key velocity without triggering a second note when I release the key (apparently it won't send a proper note off).

Thanks!

Source Audio's icon

separate on velocities from off velocities, then use CC value as note on Velocity value.

cnzlf's icon

I'm new to Max, as you can tell, and completely lost reading the midi tutorials. I can't seem to find a way to separate the velocities, could you please point me in the right direction?

Roman Thilenius's icon

the principle of a register:

set up a [int], send the CC v alue into right inlet, then let the note on event fetch the current value from the left inlet.

pls go for the helpfiles of all objects used here...

#P window setfont "Sans Serif" 9.;

#P window linecount 1;

#P newex 230 38 139 9109513 midiin;

#P newex 220 164 64 9109513 unpack 0 0;

#P newex 327 164 64 9109513 route 3;

#P newex 230 67 139 9109513 midiparse;

#P newex 177 509 60 9109513 print;

#P newex 273 498 100 9109513 midiout;

#P newex 239 306 50 9109513 t i b;

#P newex 239 374 50 9109513 list 0 0;

#P newex 273 466 100 9109513 midiformat;

#P user dial 443 152 40 40 128 1 0 0 159 270 1 1. 170 170 170 221 221 221 120 120 120 225 225 225 0 0 0 0 0 0;

#P user kslider 95 143 54 0 60 12 31 12 0 128 128 128 128 128 128 255 255 255 0 0 0 0 0 0;

#P number 429 211 54 9 0 127 3 139 0 0 0 221 221 221 222 222 222 0 0 0;

#P newex 309 339 50 9109513 i;

#B color 14;

#P connect 4 0 8 0;

#P connect 4 0 7 0;

#P connect 12 0 9 0;

#P connect 11 0 6 0;

#P connect 9 0 11 0;

#P connect 10 0 0 1;

#P connect 9 2 10 0;

#P connect 2 0 6 0;

#P connect 5 0 4 0;

#P connect 0 0 5 1;

#P connect 6 0 5 0;

#P connect 6 1 0 0;

#P connect 3 0 1 0;

#P connect 1 0 0 1;

#P window clipboard copycount 13;

cnzlf's icon

Roman, thanks a lot for chiming in. It's still triggering a second note (audible) whenever I release the key on the Akai. And sustains forever.

If I play with the mouse on the kslider, it will play a single note but the note sustains, as if didn't trigger a note off.

Any ideas?

Roman Thilenius's icon

i simply forgot about that because i am no using it with midi here.

add a [route 0] behind the [unpack] object and take its second output. this filters out all note offs :)

Roman Thilenius's icon

oh, and it sustains forever, right. just a second ...

there are six dozen possible solutions, but as for simple-to-read tutorial patch i go for this one: we reverse the order of pitch and velocity, this way on/off is easy to filter with [route].

#P window setfont "Sans Serif" 9.;

#P window linecount 1;

#P newex 335 189 64 9109513 unpack 0 0;

#P message 209 84 50 9109513 30 0;

#P message 242 57 50 9109513 30 100;

#P newex 102 398 64 9109513 append 0;

#P comment 347 225 53 9109513 note on;

#P newex 280 164 64 9109513 route 0;

#P newex 293 120 64 9109513 zl rev;

#P newex 335 43 139 9109513 midiin;

#P newex 454 146 64 9109513 route 22;

#P newex 335 72 139 9109513 midiparse;

#P newex 291 578 60 9109513 print;

#P newex 387 567 100 9109513 midiout;

#P newex 299 370 50 9109513 t i b;

#P newex 299 438 50 9109513 list 0 0;

#P newex 387 535 100 9109513 midiformat;

#P user dial 600 153 40 40 128 1 0 0 159 270 1 1. 170 170 170 221 221 221 120 120 120 225 225 225 0 0 0 0 0 0;

#P user kslider 29 111 54 0 60 12 31 12 0 128 128 128 128 128 128 255 255 255 0 0 0 0 0 0;

#P number 586 212 54 9 0 127 3 139 0 0 0 221 221 221 222 222 222 0 0 0;

#P newex 369 403 50 9109513 i;

#B color 14;

#P comment 212 190 53 9109513 note off;

#P connect 19 1 7 0;

#P connect 14 1 19 0;

#P connect 13 0 14 0;

#P connect 14 0 16 0;

#P connect 17 0 13 0;

#P connect 18 0 13 0;

#P connect 16 0 5 0;

#P connect 10 0 13 0;

#P connect 5 0 8 0;

#P connect 2 0 1 1;

#P connect 4 0 2 0;

#P connect 7 1 1 0;

#P connect 7 0 6 0;

#P connect 1 0 6 1;

#P connect 6 0 5 0;

#P connect 3 0 7 0;

#P connect 10 2 11 0;

#P connect 11 0 1 1;

#P connect 12 0 10 0;

#P window clipboard copycount 20;

cnzlf's icon

Roman, It works perfectly now with the Akai. I would have never figured that out by myself, I sincerely appreciate your time and kind help in this matter. Cheers!

Source Audio's icon

Hi CNZLF...

Luckily You got Roman to guide You through the midi jungle.

I'd like to add few words.

Midi in Max as such is a bit confusing, because it can be interpreted

using different objects, but in reality, midi is a stream of bytes which one has to learn, in order to manipulate them.

Every kind of midi data has indentifier or status byte, or whatever You want to call it, followed by

values which make the midi message complete.

You can get the raw midi data out of midiin object, or have midiparse, or even notein, ctlin

and all other specific midi objects which interpret midi messages for You.

But if You are going to use midi in the future, You have to learn the midi messages at the root.

In max 3 we had nice printed midi specification manual, covering all possible

midi messages.

Here is a part of midi specs, as part of max 4 Fundamentals...

No filename
No file type

Source Audio's icon

.

MidiFundamentals.pdf
application/download 102.18 KB