Forums > MaxMSP

velocity control

April 1, 2007 | 3:39 pm

Hi all, I have been trying to set up some velocity control so that different strength key press will effect the values of the synth modules. I’ve listened to the effects of it on some other synths and know how i want it to sound but can’t figure out how to do it max. I have tried connecting the velocity of note in to things like the filter cut off, pan, volume etc… but the velocity causes the paramter to change very abruptly and causes some nasty pops and clicks.
So I just wondered if anyone had any tips on how to make it sound like it should.
Thanks for any advice,
Steve


April 1, 2007 | 6:47 pm


April 1, 2007 | 8:30 pm


April 1, 2007 | 8:34 pm

[line~.help]


April 1, 2007 | 8:42 pm


April 1, 2007 | 9:33 pm

Thanks for your advice. It got rid of the sudden drop to 0 and is working ok. I’m not quite sure what you meant by having velocity infuence the envelpoe of a parameter but I would like to have a way to control how much the parameters will be affected by velocity. Is there an easy way to achieve this? This simple patch shows how i’ve currently got it
Thanks you,
Steve

max v2;
#N vpatcher 989 397 1589 797;
#P window setfont "Sans Serif" 9.;
#P user umenu 71 86 78 196647 1 64 102 1;
#X add Filter freq;
#X add Pan;
#X add Pulse Width;
#X add Resonance;
#X add Volume;
#P window linecount 1;
#P newex 71 219 66 196617 gate 5;
#P newex 171 171 51 196617 stripnote;
#P newex 171 124 40 196617 notein;
#P connect 3 0 2 0;
#P connect 1 1 2 1;
#P connect 0 0 1 0;
#P connect 0 1 1 1;
#P pop;


April 1, 2007 | 10:26 pm

use scale.

Here is an example building on your patch-

max v2;
#N vpatcher 36 45 845 601;
#P window setfont "Sans Serif" 10.;
#P window linecount 1;
#P hidden newex 542 135 29 9109514 int 1;
#P comment 527 361 176 9109514 cutoff frequecy + deviation;
#P comment 546 449 225 9109514 or use high ramp times to create legato effects;
#P flonum 590 395 83 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 473 424 127 9109514 line~;
#P newex 473 391 70 9109514 clip 20. 2000.;
#P comment 54 260 261 9109514 0 = no effect. 1 = Current cutoff + (1 * current cutoff);
#P newex 460 320 50 9109514 * 0.;
#P window linecount 2;
#P comment 115 168 261 9109514 In this example , the velocity is scaled to alter the filter by up to an octave above the set cutoff frequency;
#P window linecount 1;
#P hidden newex 584 133 50 9109514 int 1000;
#P hidden newex 584 105 50 9109514 loadbang;
#P flonum 133 204 97 10 0. 1. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 611 265 50 9109514 t b f;
#P newex 473 360 50 9109514 + 0.;
#P newex 34 79 23 9109514 + 1;
#P flonum 611 223 96 10 20. 2000. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 452 469 50 9109514 lores~;
#P newex 34 234 86 9109514 scale 0 127 0. 1.;
#P window setfont "Sans Serif" 9.;
#P user umenu 34 42 78 9109543 1 64 58 1;
#X add Filter freq;
#X add Pan;
#X add Pulse Width;
#X add Resonance;
#X add Volume;
#P newex 34 175 66 9109513 gate 5 1;
#P newex 64 128 51 9109513 stripnote;
#P newex 64 81 93 9109513 notein;
#P window setfont "Sans Serif" 10.;
#P comment 618 205 106 9109514 Cutoff frequency (Hz);
#P comment 248 391 219 9109514 keep cutoff within audible range , for posterity;
#P comment 603 427 184 9109514 throw in a line to smooth out changes;
#P comment 282 322 176 9109514 0. to 1. * cutoff frequecy = deviation;
#P comment 123 237 137 9109514 scale midi velocity to 0. – 1.;
#P comment 235 207 348 9109514 Adjust high output of scale to regulate velocity effect on cutoff frequency;
#P connect 9 0 13 0;
#P connect 13 0 8 0;
#P connect 8 0 10 0;
#P connect 6 0 7 0;
#P fasten 7 1 8 1 110 160 95 160;
#P fasten 16 0 10 4 138 223 99 223;
#P connect 6 1 7 1;
#P hidden fasten 27 0 16 0 547 203 138 203;
#P fasten 15 0 20 0 616 294 465 294;
#P fasten 10 0 20 0 39 311 465 311;
#P connect 23 0 11 1;
#P fasten 20 0 14 0 465 355 478 355;
#P connect 14 0 22 0;
#P connect 22 0 23 0;
#P fasten 15 1 20 1 656 303 505 303;
#P fasten 15 1 14 1 656 354 518 354;
#P hidden fasten 17 0 27 0 589 130 547 130;
#P hidden connect 17 0 18 0;
#P connect 24 0 23 1;
#P hidden fasten 18 0 12 0 589 171 616 171;
#P connect 12 0 15 0;
#P pop;


April 2, 2007 | 10:09 am

Thanks for sending that patch. I’m not sure how to get it working. I’m using a poly~ with filtercoeff~ and biquad~ inside. I don’t understand why you scale the MIDI velocity between 0. and 1. I don’t see what effect this can have on the filter frequency that goes from 20-20000 Hz. Can you explain it a bit more and how I can use it with my patch? This patch shows how i’ve got the filter set up inside the poly~
Thanks,
Steve

max v2;
#N vpatcher 0 44 632 923;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 99 136 51 196617 stripnote;
#P newex 209 383 27 196617 *~;
#N in~ 38;
#P newobj 209 344 39 196617 in~ 38;
#P newex 163 650 27 196617 *~;
#N in~ 37;
#P newobj 163 608 39 196617 in~ 37;
#P message 369 329 14 196617 1;
#P newex 369 306 48 196617 loadbang;
#P newex 269 478 29 196617 sig~;
#P newex 330 471 27 196617 *~;
#P newex 244 446 27 196617 *~;
#N in 35;
#P newobj 261 306 33 196617 in 35;
#P newex 261 329 87 196617 scale 0 127 0. 1.;
#P window setfont "Fixedwidth Serif" 10.;
#P newex 347 359 68 1441802 expr 1-$f1;
#P window setfont Times 10.;
#P comment 336 381 62 1310730 Filter Cut Off;
#P window setfont "Fixedwidth Serif" 10.;
#P flonum 261 395 35 10 0. 1. 3 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 347 395 35 10 0. 1. 3 22 0 0 0 221 221 221 222 222 222 0 0 0;
#P window setfont Times 10.;
#P comment 256 381 46 1310730 Filter Env;
#P window setfont "Sans Serif" 9.;
#P newex 244 529 40 196617 +~ 20.;
#P newex 244 504 35 196617 *~ 1.;
#P newex 330 446 41 196617 sig~ 1.;
#P newex 457 629 29 196617 sig~;
#P newex 457 606 135 196617 scale 0 127 1. 100. 1.032;
#P newex 268 608 129 196617 scale 0 127 0 20000 1.06;
#N in 6;
#P newobj 268 649 25 196617 in 6;
#N in 22;
#P newobj 457 582 33 196617 in 22;
#N in 21;
#P newobj 268 582 33 196617 in 21;
#P newex 268 685 66 196617 filtercoeff~;
#N in 28;
#P newobj 392 229 33 196617 in 28;
#N in 27;
#P newobj 355 229 33 196617 in 27;
#N in 26;
#P newobj 318 229 33 196617 in 26;
#N in 25;
#P newobj 281 229 33 196617 in 25;
#P newex 244 277 158 196617 adsr~;
#N in 5;
#P newobj 178 229 25 196617 in 5;
#N in 4;
#P newobj 141 229 25 196617 in 4;
#N in 3;
#P newobj 104 229 25 196617 in 3;
#N in 2;
#P newobj 67 229 25 196617 in 2;
#P newex 30 161 40 196617 / 127.;
#P newex 30 111 33 196617 swap;
#P newex 30 67 40 196617 unpack;
#P newex 128 318 52 196617 thispoly~;
#N in 1;
#P newobj 30 37 25 196617 in 1;
#N out~ 1;
#P newobj 183 812 39 196617 out~ 1;
#P newex 254 715 80 196617 biquad~;
#P newex 30 274 158 196617 adsr~;
#P newex 183 779 27 196617 *~;
#P connect 4 0 6 0;
#P connect 6 0 7 0;
#P connect 7 0 8 0;
#P connect 8 0 1 0;
#P fasten 6 1 7 1 65 97 58 97;
#P connect 9 0 1 1;
#P fasten 6 0 44 0 35 97 104 97;
#P connect 10 0 1 2;
#P fasten 1 0 5 0 35 304 133 304;
#P connect 1 2 5 0;
#P fasten 6 1 44 1 65 97 145 97;
#P connect 11 0 1 3;
#P connect 40 0 41 0;
#P connect 12 0 1 4;
#P fasten 27 0 41 1 249 638 185 638;
#P fasten 2 0 0 0 259 755 188 755;
#P connect 0 0 3 0;
#P fasten 1 0 0 1 35 304 205 304;
#P connect 42 0 43 0;
#P fasten 13 0 43 1 249 375 231 375;
#P fasten 8 0 13 0 35 198 249 198;
#P connect 13 0 35 0;
#P fasten 43 0 35 0 214 418 249 418;
#P connect 35 0 26 0;
#P connect 26 0 27 0;
#P fasten 36 0 27 0 335 525 249 525;
#P connect 34 0 33 0;
#P connect 33 0 30 0;
#P connect 30 0 35 1;
#P connect 19 0 22 0;
#P fasten 27 0 18 0 249 675 273 675;
#P connect 21 0 18 0;
#P fasten 41 0 18 0 168 675 273 675;
#P connect 18 0 2 1;
#P fasten 22 0 37 0 273 675 233 675 233 469 274 469;
#P connect 37 0 26 1;
#P connect 14 0 13 1;
#P connect 18 1 2 2;
#P connect 18 2 2 3;
#P connect 18 3 2 4;
#P connect 15 0 13 2;
#P fasten 24 0 18 2 462 675 329 675;
#P connect 18 4 2 5;
#P fasten 22 0 25 0 273 676 233 676 233 418 335 418;
#P connect 25 0 36 0;
#P fasten 33 0 32 0 266 350 352 350;
#P connect 39 0 29 0;
#P fasten 32 0 29 0 352 378 352 378;
#P connect 29 0 36 1;
#P connect 16 0 13 3;
#P connect 38 0 39 0;
#P connect 17 0 13 4;
#P connect 20 0 23 0;
#P fasten 23 0 24 0 462 637 462 637;
#P pop;


April 2, 2007 | 9:39 pm

It may not have been the best example..

The scaled (0. to 1.) value is multiplied with the set cutoff on the right. The result of this multiplication is then added to the original.

So, for example, say you set the cutoff frequency to 1000Hz. If the velocity comes in at 127, it is scaled to 1.

1. * 1000 = 1000. This is added to the original cutoff frequency (1000Hz) making the new cutoff frequency 2000Hz.

If the input velocity was 64 it would be scaled to .5.

.5 * 1000 = 500. This would then be added to the original frequency of 1000, making the new cutoff at 1500Hz.

The reason I did this, rather than simple scale 0-127 to 20.-20000
is because I have found that I get better results by using velocity to deviate from some set response, rather than to fully set the entire frequency response. For example, if you have the velocity scaled to the full frequency spectrum, and you hit a note that had a low velocity (like 10 or something) then nearly all the frequencies sounded by that note would be filtered out.

However in this example, one could hit a note with a velocity of 1 and the lowest the cutoff frequency would go is 1000Hz.

Also, by doing it this way, you can limit how much the velocity bumps up the frequency reponse by adjusting the high output of scale.

However, this is just an example. I’m sure there are a ton of ways to do it.

Here is another example using your poly patch. This one works with an rslider (which should ideally lie outside of the poly, but I placed it inside to make things simple). I didn’t really analyze your patch enough to know what all the signal inputs to filtercoeff~ are doing, so I just isolated the parts that are relevant. If you like this example, I’m sure you can work it into your patch.

max v2;
#N vpatcher 211 16 1001 642;
#P origin 0 16;
#P window setfont "Sans Serif" 10.;
#P flonum 128 339 85 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 266 189 96 10 0 0 160 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 367 189 96 10 0 0 160 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P user rslider 266 154 156 22 20001 1 0 0 0;
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 31 131 51 9109513 stripnote;
#P newex 301 328 29 9109513 sig~;
#P newex 301 305 135 9109513 scale 0 127 1. 100. 1.032;
#P newex 112 307 129 9109513 scale 0 127 0 20000 1.06;
#N in 22;
#P newobj 301 281 33 9109513 in 22;
#P newex 112 384 66 9109513 filtercoeff~;
#P newex 30 51 40 9109513 unpack;
#N in 1;
#P newobj 30 21 25 9109513 in 1;
#N out~ 1;
#P newobj 27 511 39 9109513 out~ 1;
#P newex 98 414 80 9109513 biquad~;
#P newex 27 478 27 9109513 *~;
#P window setfont "Sans Serif" 10.;
#P comment 222 135 333 9109514 Set the range of high and low cutoff frequencies for the velocity scale;
#P fasten 2 0 1 0 103 454 32 454;
#P connect 1 0 3 0;
#P connect 4 0 5 0;
#P fasten 5 0 11 0 35 81 36 81;
#P lcolor 7;
#P fasten 5 1 11 1 65 81 77 81;
#P lcolor 7;
#P fasten 11 1 8 0 77 271 117 271;
#P lcolor 7;
#P connect 8 0 6 0;
#P connect 6 0 2 1;
#P connect 6 1 2 2;
#P fasten 8 0 15 0 117 332 133 332;
#P connect 6 2 2 3;
#P connect 6 3 2 4;
#P fasten 10 0 6 2 306 374 173 374;
#P connect 6 4 2 5;
#P fasten 14 0 8 3 271 210 186 210;
#P fasten 13 0 8 4 372 222 209 222;
#P connect 12 0 14 0;
#P connect 7 0 9 0;
#P fasten 9 0 10 0 306 336 306 336;
#P fasten 12 1 13 0 417 182 372 182;
#P pop;


April 3, 2007 | 6:42 pm

Not to beat a dead horse or anything, but I woke up this morning and realized that the first patch could be done more simply. I’m sure other people realized this but I’m glad no one beat me to it. Here is a revised version of the first patch, which should illustrate the example more clearly.

max v2;
#N vpatcher 36 45 650 491;
#P window setfont "Sans Serif" 9.;
#P newex 125 350 129 9109513 filtercoeff~ lowpass;
#B color 5;
#P window setfont "Sans Serif" 10.;
#P newex 96 387 157 9109514 biquad~;
#P newex 350 170 27 9109514 t b i;
#P number 350 139 35 10 1 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P hidden newex 160 74 200 9109514 unpack 1000. 2;
#P newex 174 200 203 9109514 * 2.;
#P flonum 243 268 83 10 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 126 297 127 9109514 line~;
#P hidden newex 160 45 94 9109514 loadmess 1000. 2;
#P newex 34 79 23 9109514 + 1;
#P flonum 160 139 96 10 20. 2000. 3 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 34 234 189 9109514 scale 0 127 0. 1.;
#P window setfont "Sans Serif" 9.;
#P user umenu 34 42 78 9109543 1 64 58 1;
#X add Filter freq;
#X add Pan;
#X add Pulse Width;
#X add Resonance;
#X add Volume;
#P newex 34 175 66 9109513 gate 5 1;
#P newex 64 128 51 9109513 stripnote;
#P newex 64 79 93 9109513 notein;
#P window setfont "Sans Serif" 10.;
#P comment 167 121 150 9109514 Cutoff frequency (Hz) (vel of 0);
#P comment 351 121 229 9109514 Integer multiple of cutoff frequency (vel of 127);
#P comment 230 102 241 9109514 Input velocity scales between these two values;
#P comment 327 268 56 9109514 ramp time;
#P connect 7 0 10 0;
#P connect 10 0 6 0;
#P connect 6 0 8 0;
#P connect 4 0 5 0;
#P fasten 5 1 6 1 110 160 95 160;
#P connect 4 1 5 1;
#P connect 12 0 19 0;
#P connect 19 0 18 1;
#P fasten 8 0 12 0 39 260 131 260;
#P fasten 9 0 8 3 165 194 144 194;
#P connect 19 1 18 2;
#P hidden connect 11 0 15 0;
#P hidden connect 15 0 9 0;
#P fasten 17 0 14 0 355 195 179 195;
#P fasten 9 0 14 0 165 178 179 178;
#P connect 14 0 8 4;
#P connect 19 2 18 3;
#P connect 19 3 18 4;
#P connect 19 4 18 5;
#P connect 13 0 12 1;
#P hidden connect 15 1 16 0;
#P fasten 16 0 17 0 355 163 355 163;
#P connect 17 1 14 1;
#P pop;

now I need to get on with my life ;]


Viewing 10 posts - 1 through 10 (of 10 total)