--- linuxsampler/trunk/src/engines/gig/Voice.cpp 2005/10/02 14:40:52 783 +++ linuxsampler/trunk/src/engines/gig/Voice.cpp 2005/10/30 08:35:13 796 @@ -494,6 +494,7 @@ if (VCFCutoffCtrl.controller) { cvalue = pEngineChannel->ControllerTable[VCFCutoffCtrl.controller]; if (pDimRgn->VCFCutoffControllerInvert) cvalue = 127 - cvalue; + // VCFVelocityScale in this case means Minimum cutoff if (cvalue < pDimRgn->VCFVelocityScale) cvalue = pDimRgn->VCFVelocityScale; } else { @@ -501,16 +502,13 @@ } cutoff *= float(cvalue) * 0.00787402f; // (1 / 127) if (cutoff > 1.0) cutoff = 1.0; - cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN; + cutoff = (cutoff < 0.5 ? cutoff * 4826 - 1 : cutoff * 5715 - 449); + if (cutoff < 1.0) cutoff = 1.0; // calculate resonance - float resonance = (float) VCFResonanceCtrl.value * 0.00787f; // 0.0..1.0 - if (pDimRgn->VCFKeyboardTracking) { - resonance += (float) (itNoteOnEvent->Param.Note.Key - pDimRgn->VCFKeyboardTrackingBreakpoint) * 0.00787f; - } - Constrain(resonance, 0.0, 1.0); // correct resonance if outside allowed value range (0.0..1.0) + float resonance = (float) (VCFResonanceCtrl.controller ? VCFResonanceCtrl.value : pDimRgn->VCFResonance) * 0.00787f; // 0.0..1.0 - VCFCutoffCtrl.fvalue = cutoff - CONFIG_FILTER_CUTOFF_MIN; + VCFCutoffCtrl.fvalue = cutoff - 1.0; VCFResonanceCtrl.fvalue = resonance; } else { @@ -714,8 +712,10 @@ if (ccvalue < pDimRgn->VCFVelocityScale) ccvalue = pDimRgn->VCFVelocityScale; float cutoff = CutoffBase * float(ccvalue) * 0.00787402f; // (1 / 127) if (cutoff > 1.0) cutoff = 1.0; - cutoff = exp(cutoff * FILTER_CUTOFF_COEFF) * CONFIG_FILTER_CUTOFF_MIN - CONFIG_FILTER_CUTOFF_MIN; - VCFCutoffCtrl.fvalue = cutoff; // needed for initialization of fFinalCutoff next time + cutoff = (cutoff < 0.5 ? cutoff * 4826 - 1 : cutoff * 5715 - 449); + if (cutoff < 1.0) cutoff = 1.0; + + VCFCutoffCtrl.fvalue = cutoff - 1.0; // needed for initialization of fFinalCutoff next time fFinalCutoff = cutoff; } @@ -750,6 +750,9 @@ while (itNoteEvent && itNoteEvent->FragmentPos() <= Skip) ++itNoteEvent; } + uint killPos; + if (itKillEvent) killPos = RTMath::Min(itKillEvent->FragmentPos(), pEngine->MaxFadeOutPos); + uint i = Skip; while (i < Samples) { int iSubFragmentEnd = RTMath::Min(i + CONFIG_DEFAULT_SUBFRAGMENT_SIZE, Samples); @@ -770,6 +773,12 @@ // process transition events (note on, note off & sustain pedal) processTransitionEvents(itNoteEvent, iSubFragmentEnd); + // if the voice was killed in this subfragment switch EG1 to fade out stage + if (itKillEvent && killPos <= iSubFragmentEnd) { + EG1.enterFadeOutStage(); + itKillEvent = Pool::Iterator(); + } + // process envelope generators switch (EG1.getSegmentType()) { case EGADSR::segment_lin: @@ -802,8 +811,8 @@ // if filter enabled then update filter coefficients if (SYNTHESIS_MODE_GET_FILTER(SynthesisMode)) { - finalSynthesisParameters.filterLeft.SetParameters(fFinalCutoff, fFinalResonance, pEngine->SampleRate); - finalSynthesisParameters.filterRight.SetParameters(fFinalCutoff, fFinalResonance, pEngine->SampleRate); + finalSynthesisParameters.filterLeft.SetParameters(fFinalCutoff + 1.0, fFinalResonance, pEngine->SampleRate); + finalSynthesisParameters.filterRight.SetParameters(fFinalCutoff + 1.0, fFinalResonance, pEngine->SampleRate); } // do we need resampling?