--- linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp 2011/08/04 19:02:36 2229 +++ linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp 2011/08/08 13:40:04 2232 @@ -256,6 +256,7 @@ void CCUnit::Trigger() { for (int i = 0; i < Ctrls.size(); i++) { Ctrls[i].Value = pVoice->GetControllerValue(Ctrls[i].Controller); + if (Ctrls[i].pSmoother != NULL) Ctrls[i].pSmoother->setValue(Ctrls[i].Value); } CCSignalUnit::Trigger(); } @@ -270,7 +271,36 @@ void CCUnit::SetCCs(ArrayList< ::sfz::CC>& cc) { RemoveAllCCs(); for (int i = 0; i < cc.size(); i++) { - if (cc[i].Influence != 0) AddCC(cc[i].Controller, cc[i].Influence); + if (cc[i].Influence != 0) { + short int curve = cc[i].Curve; + if (curve >= GetCurveCount()) curve = -1; + AddSmoothCC(cc[i].Controller, cc[i].Influence, curve, cc[i].Smooth); + } + } + } + + void CCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { + AddCC(Controller, Influence, Curve); + } + + int CCUnit::GetCurveCount() { + return pVoice->pRegion->GetInstrument()->curves.size(); + } + + ::sfz::Curve* CCUnit::GetCurve(int idx) { + return &pVoice->pRegion->GetInstrument()->curves[idx]; + } + + double CCUnit::GetSampleRate() { + return pVoice->GetSampleRate() / CONFIG_DEFAULT_SUBFRAGMENT_SIZE; + } + + void SmoothCCUnit::AddSmoothCC(uint8_t Controller, float Influence, short int Curve, float Smooth) { + if (Smooth > 0) { + Smoothers[Controller].trigger(Smooth / 1000.0f, GetSampleRate()); + AddCC(Controller, Influence, Curve, &Smoothers[Controller]); + } else { + AddCC(Controller, Influence, Curve); } } @@ -311,6 +341,8 @@ AmpLFOUnit* u = &(GetRack()->suAmpLFO); vol *= u->Active() ? ::sf2::ToRatio((u->GetLevel() * u->pLfoInfo->volume) * 10.0) : 1; + vol *= ::sf2::ToRatio(GetRack()->suVolOnCC.GetLevel() * 10.0); + return vol; } @@ -387,12 +419,12 @@ SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), - EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), + EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), suVolOnCC(this), suAmpLFO(this), suPitchLFO(this), suFilLFO(this), LFOs(maxLfoCount), pitchLFOs(maxLfoCount), filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount) { suEndpoint.pVoice = suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; - suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = voice; + suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = suVolOnCC.pVoice = voice; suPitchLFO.suDepthCC.pVoice = suPitchLFO.suFadeEG.pVoice = suPitchLFO.suFreqOnCC.pVoice = voice; suFilLFO.suFadeEG.pVoice = suFilLFO.suFreqOnCC.pVoice = voice; suAmpLFO.suFadeEG.pVoice = suAmpLFO.suFreqOnCC.pVoice = voice; @@ -434,6 +466,8 @@ ::sfz::Region* const pRegion = pVoice->pRegion; + suVolOnCC.SetCCs(pRegion->volume_oncc); + for (int i = 0; i < pRegion->eg.size(); i++) { if (pRegion->eg[i].node.size() == 0) continue; @@ -496,6 +530,8 @@ Units.clear(); + Units.add(&suVolOnCC); + Units.add(&suVolEG); Units.add(&suFilEG); Units.add(&suPitchEG);