diff --git a/src/config.rs b/src/config.rs index a4fc31d..e895ee8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -54,6 +54,7 @@ impl FileConfig { pitch_semitones: c.pitch.unwrap_or(0.0), formant_ratio: c.formant.unwrap_or(1.0), effects: c.effects.clone().unwrap_or_default(), + gain: 1.0, }) .collect() }) diff --git a/src/dsp/chain.rs b/src/dsp/chain.rs index 7e5dfe0..d731905 100644 --- a/src/dsp/chain.rs +++ b/src/dsp/chain.rs @@ -132,6 +132,7 @@ impl Processor { formant, gate_db, gain, + preset_gain, mute, record, mode, @@ -149,6 +150,7 @@ impl Processor { preset.formant_ratio * ratio_from_semitones(ctrl.formant_delta), ctrl.gate_threshold_db, ctrl.gain, + preset.gain, ctrl.mute, ctrl.record, ctrl.mode, @@ -222,7 +224,7 @@ impl Processor { } for s in mono.iter_mut() { - *s *= gain; + *s *= preset_gain * gain; } } diff --git a/src/dsp/presets.rs b/src/dsp/presets.rs index 40fce43..c5f78af 100644 --- a/src/dsp/presets.rs +++ b/src/dsp/presets.rs @@ -14,6 +14,8 @@ pub struct Preset { pub formant_ratio: f32, /// Effects applied in order after pitch/formant. pub effects: Vec, + /// Output makeup gain so every preset sounds equally loud. + pub gain: f32, } #[derive(Clone, Copy, Debug, Serialize, Deserialize)] @@ -79,18 +81,21 @@ fn builtin_presets() -> Vec { pitch_semitones: 0.0, formant_ratio: 1.0, effects: vec![], + gain: 1.10, }, Preset { name: "Girl / Anime".into(), pitch_semitones: 5.0, formant_ratio: 1.25, effects: vec![], + gain: 1.50, }, Preset { name: "Boy".into(), pitch_semitones: 3.0, formant_ratio: 1.12, effects: vec![], + gain: 1.00, }, Preset { name: "Manly / Deep".into(), @@ -101,6 +106,7 @@ fn builtin_presets() -> Vec { ratio: 3.0, makeup_db: 2.0, }], + gain: 1.50, }, Preset { name: "Demon".into(), @@ -117,6 +123,7 @@ fn builtin_presets() -> Vec { wet: 0.4, }, ], + gain: 1.00, }, Preset { name: "Robot".into(), @@ -135,6 +142,7 @@ fn builtin_presets() -> Vec { target: 0.6, }, ], + gain: 6.00, }, Preset { name: "8-bit".into(), @@ -146,6 +154,7 @@ fn builtin_presets() -> Vec { max_gain: 32.0, target: 0.6, }], + gain: 1.00, }, Preset { name: "Alien".into(), @@ -162,6 +171,7 @@ fn builtin_presets() -> Vec { wet: 0.4, }, ], + gain: 5.50, }, Preset { name: "Radio".into(), @@ -180,6 +190,7 @@ fn builtin_presets() -> Vec { makeup_db: 6.0, }, ], + gain: 1.00, }, Preset { name: "Megaphone".into(), @@ -201,6 +212,7 @@ fn builtin_presets() -> Vec { makeup_db: 4.0, }, ], + gain: 1.60, }, Preset { name: "Ghost".into(), @@ -218,6 +230,7 @@ fn builtin_presets() -> Vec { wet: 0.5, }, ], + gain: 1.00, }, Preset { name: "Cyborg".into(), @@ -236,6 +249,7 @@ fn builtin_presets() -> Vec { target: 0.6, }, ], + gain: 1.20, }, Preset { name: "Chipmunk".into(), @@ -247,6 +261,7 @@ fn builtin_presets() -> Vec { max_gain: 8.0, target: 0.5, }], + gain: 1.00, }, Preset { name: "Helium".into(), @@ -257,6 +272,7 @@ fn builtin_presets() -> Vec { rate_hz: 0.6, wet: 0.3, }], + gain: 1.20, }, Preset { name: "Vader".into(), @@ -267,6 +283,7 @@ fn builtin_presets() -> Vec { damp: 0.3, wet: 0.35, }], + gain: 2.80, }, Preset { name: "Telephone".into(), @@ -285,6 +302,7 @@ fn builtin_presets() -> Vec { makeup_db: 8.0, }, ], + gain: 1.00, }, Preset { name: "Growl".into(), @@ -301,6 +319,7 @@ fn builtin_presets() -> Vec { wet: 0.3, }, ], + gain: 1.00, }, ] }