Skip to content

Commit 4fab34c

Browse files
authored
Add LevelStage test and cleanup unused fields (#46)
1 parent bb597bb commit 4fab34c

17 files changed

Lines changed: 54 additions & 100 deletions

presets/High_Gain.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"Filter": {
88
"filter_type": "Highpass",
9-
"cutoff_hz": 68.0,
9+
"cutoff_hz": 575.0,
1010
"resonance": 0.2
1111
}
1212
},
@@ -27,10 +27,10 @@
2727
{
2828
"ToneStack": {
2929
"model": "British",
30-
"bass": 0.65000004,
31-
"mid": 0.90000004,
32-
"treble": 0.7,
33-
"presence": 0.4
30+
"bass": 0.75,
31+
"mid": 0.8,
32+
"treble": 0.75,
33+
"presence": 0.65000004
3434
}
3535
},
3636
{
@@ -45,7 +45,7 @@
4545
{
4646
"Preamp": {
4747
"gain": 6.8,
48-
"bias": 0.0,
48+
"bias": 1.4901161e-8,
4949
"clipper_type": "Hard"
5050
}
5151
},
@@ -62,6 +62,11 @@
6262
"hold_ms": 10.0,
6363
"release_ms": 100.0
6464
}
65+
},
66+
{
67+
"Level": {
68+
"gain": 0.75
69+
}
6570
}
6671
]
6772
}

src/gui/app.rs

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -360,38 +360,28 @@ impl AmplifierApp {
360360
fn build_amplifier_chain(stages: &[StageConfig], sample_rate: f32) -> AmplifierChain {
361361
let mut chain = AmplifierChain::new();
362362

363-
for (idx, stage) in stages.iter().enumerate() {
363+
for stage in stages.iter() {
364364
match stage {
365365
StageConfig::Filter(cfg) => {
366-
chain.add_stage(Box::new(
367-
cfg.to_stage(&format!("Filter {idx}"), sample_rate),
368-
));
366+
chain.add_stage(Box::new(cfg.to_stage(sample_rate)));
369367
}
370368
StageConfig::Preamp(cfg) => {
371-
chain.add_stage(Box::new(cfg.to_stage(&format!("Preamp {idx}"))));
369+
chain.add_stage(Box::new(cfg.to_stage()));
372370
}
373371
StageConfig::Compressor(cfg) => {
374-
chain.add_stage(Box::new(
375-
cfg.to_stage(&format!("Compressor {idx}"), sample_rate),
376-
));
372+
chain.add_stage(Box::new(cfg.to_stage(sample_rate)));
377373
}
378374
StageConfig::ToneStack(cfg) => {
379-
chain.add_stage(Box::new(
380-
cfg.to_stage(&format!("ToneStack {idx}"), sample_rate),
381-
));
375+
chain.add_stage(Box::new(cfg.to_stage(sample_rate)));
382376
}
383377
StageConfig::PowerAmp(cfg) => {
384-
chain.add_stage(Box::new(
385-
cfg.to_stage(&format!("PowerAmp {idx}"), sample_rate),
386-
));
378+
chain.add_stage(Box::new(cfg.to_stage(sample_rate)));
387379
}
388380
StageConfig::Level(cfg) => {
389-
chain.add_stage(Box::new(cfg.to_stage(&format!("Level {idx}"))));
381+
chain.add_stage(Box::new(cfg.to_stage()));
390382
}
391383
StageConfig::NoiseGate(cfg) => {
392-
chain.add_stage(Box::new(
393-
cfg.to_stage(&format!("NoiseGate {idx}"), sample_rate),
394-
));
384+
chain.add_stage(Box::new(cfg.to_stage(sample_rate)));
395385
}
396386
}
397387
}

src/gui/config/compressor.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ impl Default for CompressorConfig {
2323
}
2424

2525
impl CompressorConfig {
26-
pub fn to_stage(&self, name: &str, sample_rate: f32) -> CompressorStage {
26+
pub fn to_stage(&self, sample_rate: f32) -> CompressorStage {
2727
CompressorStage::new(
28-
name,
2928
self.attack_ms,
3029
self.release_ms,
3130
self.threshold_db,

src/gui/config/filter.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,8 @@ impl Default for FilterConfig {
1919
}
2020

2121
impl FilterConfig {
22-
pub fn to_stage(&self, name: &str, sample_rate: f32) -> FilterStage {
22+
pub fn to_stage(&self, sample_rate: f32) -> FilterStage {
2323
FilterStage::new(
24-
name,
2524
self.filter_type,
2625
self.cutoff_hz,
2726
self.resonance,

src/gui/config/level.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ impl Default for LevelConfig {
1313
}
1414

1515
impl LevelConfig {
16-
pub fn to_stage(&self, name: &str) -> LevelStage {
17-
LevelStage::new(name, self.gain)
16+
pub fn to_stage(&self) -> LevelStage {
17+
LevelStage::new(self.gain)
1818
}
1919
}

src/gui/config/noise_gate.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ impl Default for NoiseGateConfig {
2323
}
2424

2525
impl NoiseGateConfig {
26-
pub fn to_stage(&self, name: &str, sample_rate: f32) -> NoiseGateStage {
26+
pub fn to_stage(&self, sample_rate: f32) -> NoiseGateStage {
2727
NoiseGateStage::new(
28-
name,
2928
self.threshold_db,
3029
self.ratio,
3130
self.attack_ms,

src/gui/config/poweramp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Default for PowerAmpConfig {
1919
}
2020

2121
impl PowerAmpConfig {
22-
pub fn to_stage(&self, name: &str, sample_rate: f32) -> PowerAmpStage {
23-
PowerAmpStage::new(name, self.drive, self.amp_type, self.sag, sample_rate)
22+
pub fn to_stage(&self, sample_rate: f32) -> PowerAmpStage {
23+
PowerAmpStage::new(self.drive, self.amp_type, self.sag, sample_rate)
2424
}
2525
}

src/gui/config/preamp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Default for PreampConfig {
1919
}
2020

2121
impl PreampConfig {
22-
pub fn to_stage(&self, name: &str) -> PreampStage {
23-
PreampStage::new(name, self.gain, self.bias, self.clipper_type)
22+
pub fn to_stage(&self) -> PreampStage {
23+
PreampStage::new(self.gain, self.bias, self.clipper_type)
2424
}
2525
}

src/gui/config/tonestack.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ impl Default for ToneStackConfig {
2323
}
2424

2525
impl ToneStackConfig {
26-
pub fn to_stage(&self, name: &str, sample_rate: f32) -> ToneStackStage {
26+
pub fn to_stage(&self, sample_rate: f32) -> ToneStackStage {
2727
ToneStackStage::new(
28-
name,
2928
self.model,
3029
self.bass,
3130
self.mid,

src/sim/stages/compressor.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::sim::stages::Stage;
22

33
pub struct CompressorStage {
4-
name: String,
54
attack: f32, // Attack coefficient (0-1)
65
release: f32, // Release coefficient (0-1)
76
attack_ms: f32, // Attack time in milliseconds
@@ -20,7 +19,6 @@ fn db_to_lin(db: f32) -> f32 {
2019

2120
impl CompressorStage {
2221
pub fn new(
23-
name: &str,
2422
attack_ms: f32,
2523
release_ms: f32,
2624
threshold_db: f32,
@@ -34,7 +32,6 @@ impl CompressorStage {
3432
let release = (-1.0 / (sample_rate * 0.001 * release_ms)).exp();
3533

3634
Self {
37-
name: name.to_string(),
3835
attack,
3936
release,
4037
attack_ms,
@@ -153,8 +150,4 @@ impl Stage for CompressorStage {
153150
_ => Err("Unknown parameter name"),
154151
}
155152
}
156-
157-
fn name(&self) -> &str {
158-
&self.name
159-
}
160153
}

0 commit comments

Comments
 (0)