OpenWareLaboratory
VelocityCurve.h
Go to the documentation of this file.
1 #ifndef __VelocityCurve_h__
2 #define __VelocityCurve_h__
3 
4 #include "basicmaths.h"
5 
15 private:
16  // defaults for 72dB range: r=10^(72/20), b=127/(126*sqrt(r)) - 1/126, m=(1-b)/127
17  float b = 0.00803821f;
18  float m = 0.00781072f;
19 public:
20  void setDynamicRange(float db){
21  float r = exp10f(db/20);
22  b = 127/(126*sqrtf(r)) - 1.0f/126;
23  m = (1-b)/127;
24  }
25  float velocityToGain(float v){
26  /* a = peak RMS value, v is velocity */
27  /* a = (m*v+b)^2 */
28  float root = m*v+b;
29  return root*root;
30  }
31 };
32 
33 #endif // __VelocityCurve_h__
General MIDI DLS Level 1 Specification: The MIDI Note Velocity value is converted to attenuation in d...
Definition: VelocityCurve.h:14
void setDynamicRange(float db)
Definition: VelocityCurve.h:20
float velocityToGain(float v)
Definition: VelocityCurve.h:25