## Velocity affecting amplitude

Sep 27, 2009 at 6:31pm

# Velocity affecting amplitude

I can’t for the life of me figure out the algorithm so i thought I would post. Can anyone give me a lead on the math if I want to affect a signal’s level based on a percentage of velocity? For example, on a lot of synths, like Ableton Operator, you can set a percentage that the oscillator’s level will be affected by the midi velocity. If set at 100%, a 127 would cause maximum volume, and a 1 would be barely audible. But if it is set to 50%, a 1 velocity would not necessarily cause an in-audible signal. Likewise, a -100% would cause a velocity of 127 to create an in-audible signal, but a velocity of 1 to cause maximum amplitude. I am aware one of the tutorial 19 sort of talk about this using an exponential expression, but it assumes you are always using the velocity to determine 100% of the amplitude. I want to be able to create a component that I could say the velocity affects the signal by say 80% (or -80%).

#45630
Sep 27, 2009 at 6:32pm

by the way, here is my miserable attempt, which works (but feels wrong) for positive percentage modifier amounts, but doesn’t have the inverse affect on negative percentage modifier amounts.

– Pasted Max Patch, click to expand. –
#164602
Sep 28, 2009 at 9:41pm

something like this?

– Pasted Max Patch, click to expand. –
#164603
Sep 28, 2009 at 10:47pm

…or like this?

going above 100% (or below -100%) will invert the velocity curve, so that higher velocity values will be more dynamic.
I’m not sure if you can literaly say percent thou…

– Pasted Max Patch, click to expand. –
#164604
Sep 29, 2009 at 2:35am

always break down things to a range of 0. 1. before you
calculate offsets and modulations, then you can work on
the linear layer.

velocity (input)
/127. (scaling)
* percentage/100 (mod amount)
+ current velocity (offset)

#164605
Sep 29, 2009 at 3:03am

thanks guys for the help, i tried both examples and they worked the exactly the way i was wanted, i am embarrassed to think how much time i sunk trying to figure this out, it appears i still don’t quite think in the max fashion of development, still trying to force programing paradigms from my day job where they don’t apply. it looks like from your examples i was sort of close in my latest attempts, but i was always trying to duplicate the signal, modify one by velocity then recombine the percentage of each vs. doing the math, then modifying the signal. I was always getting either the positive values to work, or the negative … not both. it seems sort of obvious now looking at your examples, that to get the inverse velocity affect, you just add 1!!!!!! doh

roman, thanks for the tip, i usually do do that outside of a given module in the ui or algorithm layer, always expecting something between 0 to 1 (or -1 to 1) in my re-usable component.

thanks again, i learned a lot in the process.

#164606

You must be logged in to reply to this topic.