27 |
#include "Engine.h" |
#include "Engine.h" |
28 |
#include "EngineChannel.h" |
#include "EngineChannel.h" |
29 |
|
|
30 |
|
#define LN_10_DIV_20 0.115129254649702 |
31 |
|
|
32 |
namespace LinuxSampler { namespace sfz { |
namespace LinuxSampler { namespace sfz { |
33 |
|
|
34 |
Voice::Voice() { |
Voice::Voice() { |
99 |
|
|
100 |
// rt_decay is in dB. Precalculate a suitable value for exp in |
// rt_decay is in dB. Precalculate a suitable value for exp in |
101 |
// GetReleaseTriggerAttenuation: -ln(10) / 20 * rt_decay |
// GetReleaseTriggerAttenuation: -ln(10) / 20 * rt_decay |
102 |
ri.ReleaseTriggerDecay = -0.115129254649702 * pRegion->rt_decay; |
ri.ReleaseTriggerDecay = -LN_10_DIV_20 * pRegion->rt_decay; |
103 |
|
|
104 |
return ri; |
return ri; |
105 |
} |
} |
113 |
} |
} |
114 |
|
|
115 |
double Voice::GetSampleAttenuation() { |
double Voice::GetSampleAttenuation() { |
116 |
return 1.0; // TODO: |
return exp(LN_10_DIV_20 * pRegion->volume); |
117 |
} |
} |
118 |
|
|
119 |
double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) { |
double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) { |