Reverb.withSampleRate constructor

Reverb.withSampleRate(
  1. int sampleRate
)

Implementation

factory Reverb.withSampleRate(int sampleRate)
{
    List<CombFilter> cfsL = [
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL1)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL2)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL3)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL4)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL5)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL6)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL7)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningL8))
    ];

    List<CombFilter> cfsR = [
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR1)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR2)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR3)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR4)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR5)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR6)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR7)),
        CombFilter(bufferSize: scaleTuning(sampleRate, cfTuningR8))
    ];

    List<AllPassFilter> apfsL = [
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningL1)),
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningL2)),
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningL3)),
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningL4))
    ];

    List<AllPassFilter> apfsR = [
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningR1)),
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningR2)),
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningR3)),
        AllPassFilter(bufferSize: scaleTuning(sampleRate, apfTuningR4))
    ];

    for(AllPassFilter apf in apfsL)
    {
        apf.feedback = 0.5;
    }

    for(AllPassFilter apf in apfsR)
    {
        apf.feedback = 0.5;
    }

    Reverb r = Reverb(
        cfsL: cfsL,
        cfsR: cfsR,
        apfsL: apfsL,
        apfsR: apfsR
    );

    r.setWet(initialWet);
    r.setRoomSize(initialRoom);
    r.setDamp(initialDamp);
    r.setWidth(initialWidth);

    return r;
}