Fixing subtle bugs

This commit is contained in:
2026-01-27 13:40:52 +01:00
parent 574625735b
commit a3a39ea28e
8 changed files with 194 additions and 55 deletions

View File

@@ -88,4 +88,5 @@ pub enum Op {
DivEnd,
StackStart,
EmitN,
ClearCmd,
}

View File

@@ -135,7 +135,14 @@ impl CmdRegister {
}
pub(super) fn snapshot(&self) -> Option<(Value, Vec<(String, Value)>)> {
self.sound.as_ref().map(|s| (s.clone(), self.params.clone()))
self.sound
.as_ref()
.map(|s| (s.clone(), self.params.clone()))
}
pub(super) fn clear(&mut self) {
self.sound = None;
self.params.clear();
}
}

View File

@@ -742,6 +742,10 @@ impl Forth {
scope_stack.push(new_scope);
}
Op::ClearCmd => {
cmd.clear();
}
Op::EmitN => {
let n = stack.pop().ok_or("stack underflow")?.as_int()?;
if n < 0 {

View File

@@ -1534,6 +1534,54 @@ pub const WORDS: &[Word] = &[
example: "0.02 chorusdelay",
compile: Param,
},
Word {
name: "eqlo",
category: "EQ",
stack: "(f --)",
desc: "Set low shelf gain (dB)",
example: "3 eqlo",
compile: Param,
},
Word {
name: "eqmid",
category: "EQ",
stack: "(f --)",
desc: "Set mid peak gain (dB)",
example: "-2 eqmid",
compile: Param,
},
Word {
name: "eqhi",
category: "EQ",
stack: "(f --)",
desc: "Set high shelf gain (dB)",
example: "1 eqhi",
compile: Param,
},
Word {
name: "tilt",
category: "EQ",
stack: "(f --)",
desc: "Set tilt EQ (-1 dark, 1 bright)",
example: "-0.5 tilt",
compile: Param,
},
Word {
name: "width",
category: "Stereo",
stack: "(f --)",
desc: "Set stereo width (0 mono, 1 normal, 2 wide)",
example: "0 width",
compile: Param,
},
Word {
name: "haas",
category: "Stereo",
stack: "(f --)",
desc: "Set Haas delay in ms (spatial placement)",
example: "8 haas",
compile: Param,
},
Word {
name: "comb",
category: "Filter",
@@ -1766,6 +1814,14 @@ pub const WORDS: &[Word] = &[
example: "1 reset",
compile: Param,
},
Word {
name: "clear",
category: "Sound",
stack: "(--)",
desc: "Clear sound register (sound and all params)",
example: "\"kick\" s 0.5 gain . clear \"hat\" s .",
compile: Simple,
},
// Quotation execution
Word {
name: "apply",
@@ -1871,6 +1927,7 @@ pub(super) fn simple_op(name: &str) -> Option<Op> {
"stack" => Op::StackStart,
"~" => Op::DivEnd,
".!" => Op::EmitN,
"clear" => Op::ClearCmd,
_ => return None,
})
}