--- linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp 2011/07/28 17:17:42 2221 +++ linuxsampler/trunk/src/engines/sfz/SfzSignalUnitRack.cpp 2011/07/29 13:39:58 2223 @@ -78,13 +78,33 @@ GetSampleRate()); } + + void FilEGUnit::Trigger() { + ::sfz::Region* const pRegion = pVoice->pRegion; + depth = pRegion->fileg_depth; + + // the length of the decay and release curves are dependent on the velocity + const double velrelease = 1 / pVoice->GetVelocityRelease(pVoice->MIDIVelocity); + + // set the delay trigger + uiDelayTrigger = (pRegion->fileg_delay + pRegion->fileg_vel2delay * velrelease) * GetSampleRate(); + + EG.trigger(uint(pRegion->fileg_start * 10), + std::max(0.0, pRegion->fileg_attack + pRegion->fileg_vel2attack * velrelease), + std::max(0.0, pRegion->fileg_hold + pRegion->fileg_vel2hold * velrelease), + std::max(0.0, pRegion->fileg_decay + pRegion->fileg_vel2decay * velrelease), + uint(std::min(std::max(0.0, 10 * (pRegion->fileg_sustain + pRegion->fileg_vel2sustain * velrelease)), 1000.0)), + std::max(0.0, pRegion->fileg_release + pRegion->fileg_vel2release * velrelease), + GetSampleRate()); + } + void LFOUnit::Increment() { if (DelayStage()) return; SignalUnit::Increment(); - Level = lfo.render(); + Level = pLFO->Render(); } void LFOUnit::Trigger() { @@ -106,15 +126,33 @@ lfo.update(0); } + + LFOv2Unit::LFOv2Unit(SfzSignalUnitRack* rack) + : LFOUnit(rack), lfos(8), lfo0(1200.0f), lfo1(1200.0f), lfo2(1200.0f), + lfo3(1200.0f), lfo4(1200.0f), lfo5(1200.0f), lfo6(1200.0f), lfo7(1200.0f) + { + lfos.add(&lfo0); + lfos.add(&lfo1); + lfos.add(&lfo2); + lfos.add(&lfo3); + lfos.add(&lfo4); + lfos.add(&lfo5); + lfos.add(&lfo6); + lfos.add(&lfo7); + } + void LFOv2Unit::Trigger() { LFOUnit::Trigger(); - lfo.trigger ( + if (pLfoInfo->wave < 0 || pLfoInfo->wave >= lfos.size()) pLFO = &lfo0; + else pLFO = lfos[pLfoInfo->wave]; + + pLFO->Trigger ( pLfoInfo->freq, start_level_mid, 1, 0, false, GetSampleRate() ); - lfo.update(0); + pLFO->Update(0); } void AmpLFOUnit::Trigger() { @@ -189,6 +227,9 @@ FilLFOUnit* u = &(GetRack()->suFilLFO); val = u->Active() ? RTMath::CentsToFreqRatioUnlimited(u->GetLevel() * u->pLfoInfo->cutoff) : 1; + FilEGUnit* u2 = &(GetRack()->suFilEG); + val *= u2->Active() ? RTMath::CentsToFreqRatioUnlimited(u2->GetLevel() * u2->depth) : 1; + for (int i = 0; i < GetRack()->filLFOs.size(); i++) { LFOv2Unit* lfo = GetRack()->filLFOs[i]; if (!lfo->Active()) continue; @@ -242,12 +283,12 @@ SfzSignalUnitRack::SfzSignalUnitRack(Voice* voice) - : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suPitchEG(this), + : SignalUnitRack(MaxUnitCount), pVoice(voice), suEndpoint(this), suVolEG(this), suFilEG(this), suPitchEG(this), EGs(maxEgCount), volEGs(maxEgCount), pitchEGs(maxEgCount), suAmpLFO(this), suPitchLFO(this), suFilLFO(this), LFOs(maxLfoCount), filLFOs(maxLfoCount), resLFOs(maxLfoCount), panLFOs(maxLfoCount) { - suEndpoint.pVoice = suVolEG.pVoice = suPitchEG.pVoice = voice; + suEndpoint.pVoice = suVolEG.pVoice = suFilEG.pVoice = suPitchEG.pVoice = voice; suAmpLFO.pVoice = suPitchLFO.pVoice = suFilLFO.pVoice = voice; for (int i = 0; i < EGs.capacity(); i++) { @@ -332,6 +373,7 @@ Units.clear(); Units.add(&suVolEG); + Units.add(&suFilEG); Units.add(&suPitchEG); Units.add(&suPitchLFO); Units.add(&suAmpLFO);