4 |
* * |
* * |
5 |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
* Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * |
6 |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
* Copyright (C) 2005 - 2008 Christian Schoenebeck * |
7 |
* Copyright (C) 2009 - 2011 Christian Schoenebeck and Grigor Iliev * |
* Copyright (C) 2009 - 2015 Christian Schoenebeck and Grigor Iliev * |
8 |
* * |
* * |
9 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
10 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
34 |
typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoice; |
typedef LinuxSampler::VoiceBase<EngineChannel, ::sfz::Region, Sample, DiskThread> SfzVoice; |
35 |
Voice::Voice(): SignalRack(this), SfzVoice(&SignalRack) { |
Voice::Voice(): SignalRack(this), SfzVoice(&SignalRack) { |
36 |
pEngine = NULL; |
pEngine = NULL; |
37 |
|
bEqSupport = true; |
38 |
} |
} |
39 |
|
|
40 |
Voice::~Voice() { |
Voice::~Voice() { |
134 |
} |
} |
135 |
|
|
136 |
double Voice::GetSampleAttenuation() { |
double Voice::GetSampleAttenuation() { |
137 |
return exp(LN_10_DIV_20 * pRegion->volume); |
return exp(LN_10_DIV_20 * pRegion->volume) * pRegion->amplitude / 100; |
138 |
} |
} |
139 |
|
|
140 |
double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) { |
double Voice::GetVelocityAttenuation(uint8_t MIDIKeyVelocity) { |
141 |
return pRegion->amp_velcurve[MIDIKeyVelocity]; |
float offset = -pRegion->amp_veltrack; |
142 |
|
if (offset <= 0) offset += 100; |
143 |
|
return (offset + pRegion->amp_veltrack * pRegion->amp_velcurve[MIDIKeyVelocity]) / 100; |
144 |
} |
} |
145 |
|
|
146 |
double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) { |
double Voice::GetVelocityRelease(uint8_t MIDIKeyVelocity) { |
156 |
}*/ // TODO: ^^^ |
}*/ // TODO: ^^^ |
157 |
} |
} |
158 |
|
|
159 |
|
void Voice::ProcessChannelPressureEvent(RTList<Event>::Iterator& itEvent) { |
160 |
|
//TODO: ... |
161 |
|
} |
162 |
|
|
163 |
|
void Voice::ProcessPolyphonicKeyPressureEvent(RTList<Event>::Iterator& itEvent) { |
164 |
|
//TODO: ... |
165 |
|
} |
166 |
|
|
167 |
double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) { |
double Voice::CalculateCrossfadeVolume(uint8_t MIDIKeyVelocity) { |
168 |
/*float crossfadeVolume; |
/*float crossfadeVolume; |
169 |
switch (pRegion->AttenuationController.type) { |
switch (pRegion->AttenuationController.type) { |
264 |
float cutoff = *pRegion->cutoff; |
float cutoff = *pRegion->cutoff; |
265 |
cutoff *= RTMath::CentsToFreqRatioUnlimited( |
cutoff *= RTMath::CentsToFreqRatioUnlimited( |
266 |
MIDIKeyVelocity / 127.0f * pRegion->fil_veltrack + |
MIDIKeyVelocity / 127.0f * pRegion->fil_veltrack + |
267 |
(MIDIKey - pRegion->fil_keycenter) * pRegion->fil_keytrack); |
(MIDIKey() - pRegion->fil_keycenter) * pRegion->fil_keytrack); |
268 |
return cutoff; |
return cutoff; |
269 |
} |
} |
270 |
|
|
280 |
} |
} |
281 |
|
|
282 |
void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) { |
void Voice::ProcessGroupEvent(RTList<Event>::Iterator& itEvent) { |
283 |
dmsg(4,("Voice %x processGroupEvents event type=%d", this, itEvent->Type)); |
dmsg(4,("Voice %p processGroupEvents event type=%d", (void*)this, itEvent->Type)); |
284 |
if (itEvent->Type == Event::type_control_change || |
if (itEvent->Type == Event::type_control_change || |
285 |
(Type & Voice::type_controller_triggered) || |
(Type & Voice::type_controller_triggered) || |
286 |
itEvent->Param.Note.Key != MIDIKey) { |
itEvent->Param.Note.Key != HostKey()) { |
287 |
dmsg(4,("Voice %x - kill", this)); |
dmsg(4,("Voice %p - kill", (void*)this)); |
288 |
if (pRegion->off_mode == ::sfz::OFF_NORMAL) { |
if (pRegion->off_mode == ::sfz::OFF_NORMAL) { |
289 |
// turn off the voice by entering release envelope stage |
// turn off the voice by entering release envelope stage |
290 |
EnterReleaseStage(); |
EnterReleaseStage(); |
306 |
} |
} |
307 |
} |
} |
308 |
|
|
309 |
|
void Voice::CalculateFadeOutCoeff(float FadeOutTime, float SampleRate) { |
310 |
|
SignalRack.CalculateFadeOutCoeff(FadeOutTime, SampleRate); |
311 |
|
} |
312 |
|
|
313 |
|
int Voice::CalculatePan(uint8_t pan) { |
314 |
|
// the value isn't limited to [0, 127] here, as this is done |
315 |
|
// later in SignalUnit.CalculatePan |
316 |
|
return pan + RgnInfo.Pan; |
317 |
|
} |
318 |
|
|
319 |
}} // namespace LinuxSampler::sfz |
}} // namespace LinuxSampler::sfz |