mapping MIDI velocity to 0. to 1. range (non-linear)

Mitch Turner's icon

I want to efficiently map MIDI velocity (0 to 127) into an amplitude range from 0 to 1. I want it to be a non-linear mapping.

I'm doing this:

input_value (0 to 127 MIDI velocities)
|
[pow 4.]
|
[/ 260144640.]
|
output_value (0. to 1. for use with a [*~] object)

Is there a more efficient way to do this using standard math objects?

Also, how would I write the above using the [expr ] object?

Thanks in advance,
Mitch

MIB's icon

do you know about linedrive and scale?? both can do exponential mapping.

Mitch Turner's icon

Yes, I know about them. I'd like to be able to port this over to Pd very easily. I'n not sure they are available for Pd.

Mitch

Luke Hall's icon

I usually use [expr pow(($i1/127.),$f2)]. If the right inlet is 1 the conversion is linear. I'd recommend starting with something like 0.7 and adjusting it from there.

lh

Peter Castine's icon

The lp.scampf object from Litter Power will do this with its default settings and a 'pow $1' or 'exp $1' message, where the parameter controls the steepness of the curve.

Later on I read you want a Pd solution. In that case you'll probably have to roll your own. For better or worse, I do not see a Litter Power for Pd in the immediate future.

Good luck anyway,
Peter

Mitch Turner's icon

Thanks to all for the help.
Mitch

dodgeroo's icon

you can create curves in a buffer

On Sat, Dec 6, 2008 at 4:06 PM, Mitch Turner wrote:

>
> Thanks to all for the help.
> Mitch
> --
> http://home.lagrange.edu/mturner
>