setPreset method

  1. @override
void setPreset(
  1. ReverbPreset preset, {
  2. double? fadeTime,
})
override

Update the reverb settings.

Implementation

@override
void setPreset(
  final ReverbPreset preset, {
  final double? fadeTime,
}) {
  final startTime = backend.context.currentTime.value;
  final endTime = startTime + (fadeTime ?? 0.1);
  for (final changeSetting in [
    _ChangeReverbSetting(property: reverb.gain, value: preset.gain),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsDelay,
      value: preset.lateReflectionsDelay,
    ),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsDiffusion,
      value: preset.lateReflectionsDiffusion,
    ),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsHfReference,
      value: preset.lateReflectionsHfReference,
    ),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsHfRolloff,
      value: preset.lateReflectionsHfRolloff,
    ),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsLfReference,
      value: preset.lateReflectionsLfReference,
    ),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsLfRolloff,
      value: preset.lateReflectionsLfRolloff,
    ),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsModulationDepth,
      value: preset.lateReflectionsModulationDepth,
    ),
    _ChangeReverbSetting(
      property: reverb.lateReflectionsModulationFrequency,
      value: preset.lateReflectionsModulationFrequency,
    ),
    _ChangeReverbSetting(
      property: reverb.meanFreePath,
      value: preset.meanFreePath,
    ),
    _ChangeReverbSetting(property: reverb.t60, value: preset.t60),
  ]) {
    final property = changeSetting.property;
    if (fadeTime == null) {
      property.value = changeSetting.value;
    } else {
      changeSetting.property.automate(
        startTime: startTime,
        startValue: property.value,
        endTime: endTime,
        endValue: changeSetting.value,
      );
    }
  }
}