110 |
#endif // CONFIG_DEVMODE |
#endif // CONFIG_DEVMODE |
111 |
|
|
112 |
Type = VoiceType; |
Type = VoiceType; |
113 |
MIDIKey = itNoteOnEvent->Param.Note.Key; |
pNote = pEngineChannel->pEngine->NoteByID( itNoteOnEvent->Param.Note.ID ); |
|
MIDIVelocity = itNoteOnEvent->Param.Note.Velocity; |
|
114 |
PlaybackState = playback_state_init; // mark voice as triggered, but no audio rendered yet |
PlaybackState = playback_state_init; // mark voice as triggered, but no audio rendered yet |
115 |
Delay = itNoteOnEvent->FragmentPos(); |
Delay = itNoteOnEvent->FragmentPos(); |
116 |
itTriggerEvent = itNoteOnEvent; |
itTriggerEvent = itNoteOnEvent; |
117 |
itKillEvent = Pool<Event>::Iterator(); |
itKillEvent = Pool<Event>::Iterator(); |
118 |
MidiKeyBase* pKeyInfo = GetMidiKeyInfo(MIDIKey); |
MidiKeyBase* pKeyInfo = GetMidiKeyInfo(MIDIKey()); |
119 |
|
|
120 |
pGroupEvents = iKeyGroup ? pEngineChannel->ActiveKeyGroups[iKeyGroup] : 0; |
pGroupEvents = iKeyGroup ? pEngineChannel->ActiveKeyGroups[iKeyGroup] : 0; |
121 |
|
|
247 |
// if portamento mode is on, we dedicate EG3 purely for portamento, otherwise if portamento is off we do as told by the patch |
// if portamento mode is on, we dedicate EG3 purely for portamento, otherwise if portamento is off we do as told by the patch |
248 |
bool bPortamento = pEngineChannel->PortamentoMode && pEngineChannel->PortamentoPos >= 0.0f; |
bool bPortamento = pEngineChannel->PortamentoMode && pEngineChannel->PortamentoPos >= 0.0f; |
249 |
float eg3depth = (bPortamento) |
float eg3depth = (bPortamento) |
250 |
? RTMath::CentsToFreqRatio((pEngineChannel->PortamentoPos - (float) MIDIKey) * 100) |
? RTMath::CentsToFreqRatio((pEngineChannel->PortamentoPos - (float) MIDIKey()) * 100) |
251 |
: RTMath::CentsToFreqRatio(RgnInfo.EG3Depth); |
: RTMath::CentsToFreqRatio(RgnInfo.EG3Depth); |
252 |
float eg3time = (bPortamento) |
float eg3time = (bPortamento) |
253 |
? pEngineChannel->PortamentoTime |
? pEngineChannel->PortamentoTime |
352 |
} |
} |
353 |
|
|
354 |
AbstractEngineChannel* pChannel = pEngineChannel; |
AbstractEngineChannel* pChannel = pEngineChannel; |
355 |
MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey); |
MidiKeyBase* pMidiKeyInfo = GetMidiKeyInfo(MIDIKey()); |
356 |
|
|
357 |
const bool bVoiceRequiresDedicatedRouting = |
const bool bVoiceRequiresDedicatedRouting = |
358 |
pEngineChannel->GetFxSendCount() > 0 && |
pEngineChannel->GetFxSendCount() > 0 && |
378 |
|
|
379 |
RTList<Event>::Iterator itCCEvent = pChannel->pEvents->first(); |
RTList<Event>::Iterator itCCEvent = pChannel->pEvents->first(); |
380 |
RTList<Event>::Iterator itNoteEvent; |
RTList<Event>::Iterator itNoteEvent; |
381 |
GetFirstEventOnKey(MIDIKey, itNoteEvent); |
GetFirstEventOnKey(HostKey(), itNoteEvent); |
382 |
|
|
383 |
RTList<Event>::Iterator itGroupEvent; |
RTList<Event>::Iterator itGroupEvent; |
384 |
if (pGroupEvents && !Orphan) itGroupEvent = pGroupEvents->first(); |
if (pGroupEvents && !Orphan) itGroupEvent = pGroupEvents->first(); |
718 |
void AbstractVoice::UpdatePortamentoPos(Pool<Event>::Iterator& itNoteOffEvent) { |
void AbstractVoice::UpdatePortamentoPos(Pool<Event>::Iterator& itNoteOffEvent) { |
719 |
if (pSignalUnitRack == NULL) { |
if (pSignalUnitRack == NULL) { |
720 |
const float fFinalEG3Level = EG3.level(itNoteOffEvent->FragmentPos()); |
const float fFinalEG3Level = EG3.level(itNoteOffEvent->FragmentPos()); |
721 |
pEngineChannel->PortamentoPos = (float) MIDIKey + RTMath::FreqRatioToCents(fFinalEG3Level) * 0.01f; |
pEngineChannel->PortamentoPos = (float) MIDIKey() + RTMath::FreqRatioToCents(fFinalEG3Level) * 0.01f; |
722 |
} else { |
} else { |
723 |
// TODO: |
// TODO: |
724 |
} |
} |
745 |
|
|
746 |
Voice::PitchInfo AbstractVoice::CalculatePitchInfo(int PitchBend) { |
Voice::PitchInfo AbstractVoice::CalculatePitchInfo(int PitchBend) { |
747 |
PitchInfo pitch; |
PitchInfo pitch; |
748 |
double pitchbasecents = InstrInfo.FineTune + RgnInfo.FineTune + GetEngine()->ScaleTuning[MIDIKey % 12]; |
double pitchbasecents = InstrInfo.FineTune + RgnInfo.FineTune + GetEngine()->ScaleTuning[MIDIKey() % 12]; |
749 |
|
|
750 |
// GSt behaviour: maximum transpose up is 40 semitones. If |
// GSt behaviour: maximum transpose up is 40 semitones. If |
751 |
// MIDI key is more than 40 semitones above unity note, |
// MIDI key is more than 40 semitones above unity note, |
752 |
// the transpose is not done. |
// the transpose is not done. |
753 |
if (!SmplInfo.Unpitched && (MIDIKey - (int) RgnInfo.UnityNote) < 40) pitchbasecents += (MIDIKey - (int) RgnInfo.UnityNote) * 100; |
if (!SmplInfo.Unpitched && (MIDIKey() - (int) RgnInfo.UnityNote) < 40) pitchbasecents += (MIDIKey() - (int) RgnInfo.UnityNote) * 100; |
754 |
|
|
755 |
pitch.PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(SmplInfo.SampleRate) / double(GetEngine()->SampleRate)); |
pitch.PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(SmplInfo.SampleRate) / double(GetEngine()->SampleRate)); |
756 |
pitch.PitchBendRange = 1.0 / 8192.0 * 100.0 * InstrInfo.PitchbendRange; |
pitch.PitchBendRange = 1.0 / 8192.0 * 100.0 * InstrInfo.PitchbendRange; |
761 |
|
|
762 |
void AbstractVoice::onScaleTuningChanged() { |
void AbstractVoice::onScaleTuningChanged() { |
763 |
PitchInfo pitch = this->Pitch; |
PitchInfo pitch = this->Pitch; |
764 |
double pitchbasecents = InstrInfo.FineTune + RgnInfo.FineTune + GetEngine()->ScaleTuning[MIDIKey % 12]; |
double pitchbasecents = InstrInfo.FineTune + RgnInfo.FineTune + GetEngine()->ScaleTuning[MIDIKey() % 12]; |
765 |
|
|
766 |
// GSt behaviour: maximum transpose up is 40 semitones. If |
// GSt behaviour: maximum transpose up is 40 semitones. If |
767 |
// MIDI key is more than 40 semitones above unity note, |
// MIDI key is more than 40 semitones above unity note, |
768 |
// the transpose is not done. |
// the transpose is not done. |
769 |
if (!SmplInfo.Unpitched && (MIDIKey - (int) RgnInfo.UnityNote) < 40) pitchbasecents += (MIDIKey - (int) RgnInfo.UnityNote) * 100; |
if (!SmplInfo.Unpitched && (MIDIKey() - (int) RgnInfo.UnityNote) < 40) pitchbasecents += (MIDIKey() - (int) RgnInfo.UnityNote) * 100; |
770 |
|
|
771 |
pitch.PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(SmplInfo.SampleRate) / double(GetEngine()->SampleRate)); |
pitch.PitchBase = RTMath::CentsToFreqRatioUnlimited(pitchbasecents) * (double(SmplInfo.SampleRate) / double(GetEngine()->SampleRate)); |
772 |
this->Pitch = pitch; |
this->Pitch = pitch; |
783 |
// the volume of release triggered samples depends on note length |
// the volume of release triggered samples depends on note length |
784 |
if (Type & Voice::type_release_trigger) { |
if (Type & Voice::type_release_trigger) { |
785 |
float noteLength = float(GetEngine()->FrameTime + Delay - |
float noteLength = float(GetEngine()->FrameTime + Delay - |
786 |
GetNoteOnTime(MIDIKey) ) / GetEngine()->SampleRate; |
GetNoteOnTime(MIDIKey()) ) / GetEngine()->SampleRate; |
787 |
|
|
788 |
volume *= GetReleaseTriggerAttenuation(noteLength); |
volume *= GetReleaseTriggerAttenuation(noteLength); |
789 |
} |
} |