[sdiy] MIDI volume to volts formula

Pete Hartman pete.hartman at gmail.com
Tue Jun 5 02:09:28 CEST 2018


I have always done a linear function, e.g. Vpp * (vel / 127).

However, now that you mention it, it does seem like a log function of some
sort (like the rising side of a traditional analog envelope) would be more
appropriate.

That rising envelope is capacitor time charging Vc = Vs ( 1 - e^(-t/RC))
and it's expected that full charge is at t = 5RC.  You could probably fudge
and say 4RC, because the last of the 5 time constants is nearly level
anyway.  Mapping that function to what we're talking about and using 4RC as
the standard, for Vpp max == 1V, you'd have Vpp = 1 - e ^ -(4 * vel / 127).

Do beware: it is best to avoid floating point operations unless you have a
really solid processor (e.g. I bet a teensy could handle it; a PIC
definitely can't).  So ultimately you'll likely have a 127 entry lookup
table.  That would let you create any function you care to, quite
honestly.  I would just precompute the entries for the Vpp function just
mentioned, and scale them so they're integers (probably *1024 or whatever
resolution your DAC has).


On Mon, Jun 4, 2018 at 6:43 PM, John Speth <john.speth at andrews-cooper.com>
wrote:

> I have been having a difficult time finding a workable formula for
> converting the MIDI velocity value (the third byte in a note on/off
> message) to a Vpp value.  Does anybody know the mathematical formula for
> this conversion?  Something like Vpp = func(velocity).  Let’s assume
> Vpp(max, when velocity is 127) is 1.0V.
>
>
>
> The reason I need to know is I have device that I can control frequency in
> terms of Hz and velocity in terms of Vpp.  I’m not sure if I need a
> function based on log10() or antilog10().
>
>
>
> Thanks and sorry for the dopey question.
>
>
>
> JJS
>
>
>
> _______________________________________________
> Synth-diy mailing list
> Synth-diy at synth-diy.org
> http://synth-diy.org/mailman/listinfo/synth-diy
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://synth-diy.org/pipermail/synth-diy/attachments/20180604/aff7f3a6/attachment.htm>


More information about the Synth-diy mailing list