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() { |
69 |
Voice::RegionInfo Voice::GetRegionInfo() { |
Voice::RegionInfo Voice::GetRegionInfo() { |
70 |
RegionInfo ri; |
RegionInfo ri; |
71 |
ri.UnityNote = pRegion->pitch_keycenter; |
ri.UnityNote = pRegion->pitch_keycenter; |
72 |
ri.FineTune = pRegion->tune; |
ri.FineTune = pRegion->tune + pRegion->transpose * 100; |
73 |
ri.Pan = int(pRegion->pan * 0.63); // convert from -100..100 to -64..63 |
ri.Pan = int(pRegion->pan * 0.63); // convert from -100..100 to -64..63 |
74 |
ri.SampleStartOffset = 0; // TODO: |
ri.SampleStartOffset = 0; // TODO: |
75 |
|
|
97 |
ri.VCFType = ::gig::vcf_type_lowpass; // TODO: |
ri.VCFType = ::gig::vcf_type_lowpass; // TODO: |
98 |
ri.VCFResonance = 0; // TODO: |
ri.VCFResonance = 0; // TODO: |
99 |
|
|
100 |
ri.ReleaseTriggerDecay = 0; |
// rt_decay is in dB. Precalculate a suitable value for exp in |
101 |
|
// GetReleaseTriggerAttenuation: -ln(10) / 20 * rt_decay |
102 |
|
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) { |
120 |
return double(MIDIKeyVelocity) / 127.0f; // TODO: |
return pRegion->amp_velcurve[MIDIKeyVelocity]; |
121 |
} |
} |
122 |
|
|
123 |
double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) { |
double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) { |
496 |
return 0; |
return 0; |
497 |
} |
} |
498 |
|
|
499 |
|
float Voice::GetReleaseTriggerAttenuation(float noteLength) { |
500 |
|
// pow(10, -rt_decay * noteLength / 20): |
501 |
|
return expf(RgnInfo.ReleaseTriggerDecay * noteLength); |
502 |
|
} |
503 |
|
|
504 |
}} // namespace LinuxSampler::sfz |
}} // namespace LinuxSampler::sfz |