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

Dec 5, 2008 at 7:16pm

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

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

#41208
Dec 5, 2008 at 7:22pm

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

#146525
Dec 5, 2008 at 7:32pm

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

#146526
Dec 5, 2008 at 7:34pm

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

#146527
Dec 5, 2008 at 10:11pm

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

#146528
Dec 6, 2008 at 3:06pm

Thanks to all for the help.
Mitch

#146529
Dec 8, 2008 at 4:32am

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
>

#146530

You must be logged in to reply to this topic.