146 |
float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
float subfragmentRate = GetEngine()->SampleRate / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; |
147 |
CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate); |
CrossfadeSmoother.trigger(crossfadeVolume, subfragmentRate); |
148 |
VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate); |
VolumeSmoother.trigger(pEngineChannel->MidiVolume, subfragmentRate); |
149 |
|
NoteVolumeSmoother.trigger(pNote ? pNote->Override.Volume : 1.f, subfragmentRate); |
150 |
|
|
151 |
// Check if the sample needs disk streaming or is too short for that |
// Check if the sample needs disk streaming or is too short for that |
152 |
long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize; |
long cachedsamples = GetSampleCacheSize() / SmplInfo.FrameSize; |
186 |
} |
} |
187 |
|
|
188 |
Pitch = CalculatePitchInfo(PitchBend); |
Pitch = CalculatePitchInfo(PitchBend); |
189 |
|
NotePitch = (pNote) ? pNote->Override.Pitch : 1.0f; |
190 |
|
|
191 |
// the length of the decay and release curves are dependent on the velocity |
// the length of the decay and release curves are dependent on the velocity |
192 |
const double velrelease = 1 / GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity); |
const double velrelease = 1 / GetVelocityRelease(itNoteOnEvent->Param.Note.Velocity); |
203 |
pSignalUnitRack->Trigger(); |
pSignalUnitRack->Trigger(); |
204 |
} |
} |
205 |
|
|
206 |
uint8_t pan = MIDIPan; |
const uint8_t pan = (pSignalUnitRack) ? pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan) : MIDIPan; |
207 |
if (pSignalUnitRack) pan = pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan); |
NotePanLeft = (pNote) ? AbstractEngine::PanCurveValueNorm(pNote->Override.Pan, 0 /*left*/ ) : 1.f; |
208 |
PanLeftSmoother.trigger(AbstractEngine::PanCurve[128 - pan], subfragmentRate); |
NotePanRight = (pNote) ? AbstractEngine::PanCurveValueNorm(pNote->Override.Pan, 1 /*right*/) : 1.f; |
209 |
PanRightSmoother.trigger(AbstractEngine::PanCurve[pan], subfragmentRate); |
PanLeftSmoother.trigger( |
210 |
|
AbstractEngine::PanCurve[128 - pan] * NotePanLeft, |
211 |
|
subfragmentRate |
212 |
|
); |
213 |
|
PanRightSmoother.trigger( |
214 |
|
AbstractEngine::PanCurve[pan] * NotePanRight, |
215 |
|
subfragmentRate |
216 |
|
); |
217 |
|
|
218 |
#ifdef CONFIG_INTERPOLATE_VOLUME |
#ifdef CONFIG_INTERPOLATE_VOLUME |
219 |
// setup initial volume in synthesis parameters |
// setup initial volume in synthesis parameters |
439 |
processCCEvents(itCCEvent, iSubFragmentEnd); |
processCCEvents(itCCEvent, iSubFragmentEnd); |
440 |
uint8_t pan = MIDIPan; |
uint8_t pan = MIDIPan; |
441 |
if (pSignalUnitRack != NULL) pan = pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan); |
if (pSignalUnitRack != NULL) pan = pSignalUnitRack->GetEndpointUnit()->CalculatePan(MIDIPan); |
|
|
|
|
PanLeftSmoother.update(AbstractEngine::PanCurve[128 - pan]); |
|
|
PanRightSmoother.update(AbstractEngine::PanCurve[pan]); |
|
442 |
|
|
443 |
finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend; |
PanLeftSmoother.update(AbstractEngine::PanCurve[128 - pan] * NotePanLeft); |
444 |
float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render(); |
PanRightSmoother.update(AbstractEngine::PanCurve[pan] * NotePanRight); |
445 |
|
|
446 |
|
finalSynthesisParameters.fFinalPitch = Pitch.PitchBase * Pitch.PitchBend * NotePitch; |
447 |
|
|
448 |
|
float fFinalVolume = VolumeSmoother.render() * CrossfadeSmoother.render() * NoteVolumeSmoother.render(); |
449 |
#ifdef CONFIG_PROCESS_MUTED_CHANNELS |
#ifdef CONFIG_PROCESS_MUTED_CHANNELS |
450 |
if (pChannel->GetMute()) fFinalVolume = 0; |
if (pChannel->GetMute()) fFinalVolume = 0; |
451 |
#endif |
#endif |
681 |
} |
} |
682 |
|
|
683 |
/** |
/** |
684 |
* Process given list of MIDI note on, note off and sustain pedal events |
* Process given list of MIDI note on, note off, sustain pedal events and |
685 |
* for the given time. |
* note synthesis parameter events for the given time. |
686 |
* |
* |
687 |
* @param itEvent - iterator pointing to the next event to be processed |
* @param itEvent - iterator pointing to the next event to be processed |
688 |
* @param End - youngest time stamp where processing should be stopped |
* @param End - youngest time stamp where processing should be stopped |
702 |
} |
} |
703 |
} |
} |
704 |
} |
} |
705 |
|
// process synthesis parameter events (caused by built-in realt-time instrument script functions) |
706 |
|
if (itEvent->Type == Event::type_note_synth_param && pNote && |
707 |
|
pEngineChannel->pEngine->NoteByID( itEvent->Param.NoteSynthParam.NoteID ) == pNote) |
708 |
|
{ |
709 |
|
switch (itEvent->Param.NoteSynthParam.Type) { |
710 |
|
case Event::synth_param_volume: |
711 |
|
NoteVolumeSmoother.update(itEvent->Param.NoteSynthParam.AbsValue); |
712 |
|
break; |
713 |
|
case Event::synth_param_pitch: |
714 |
|
NotePitch = itEvent->Param.NoteSynthParam.AbsValue; |
715 |
|
break; |
716 |
|
case Event::synth_param_pan: |
717 |
|
NotePanLeft = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 0 /*left*/); |
718 |
|
NotePanRight = AbstractEngine::PanCurveValueNorm(itEvent->Param.NoteSynthParam.AbsValue, 1 /*right*/); |
719 |
|
break; |
720 |
|
} |
721 |
|
} |
722 |
} |
} |
723 |
} |
} |
724 |
|
|