Feat: new harmony / melodic words and demo

This commit is contained in:
2026-02-23 02:25:32 +01:00
parent d9e6505e07
commit e7137cc7ed
9 changed files with 624 additions and 9 deletions

View File

@@ -108,6 +108,12 @@ pub(super) fn simple_op(name: &str) -> Option<Op> {
"mstop" => Op::MidiStop,
"mcont" => Op::MidiContinue,
"forget" => Op::Forget,
"key!" => Op::SetKey,
"tp" => Op::Transpose,
"inv" => Op::Invert,
"dinv" => Op::DownInvert,
"drop2" => Op::VoiceDrop2,
"drop3" => Op::VoiceDrop3,
"lfo" => Op::ModLfo(0),
"tlfo" => Op::ModLfo(1),
"wlfo" => Op::ModLfo(2),
@@ -227,6 +233,20 @@ pub(crate) fn compile_word(
_ => {}
}
if name == "triad" || name == "seventh" {
if let Some(Op::Degree(pattern)) = ops.last() {
let pattern = *pattern;
ops.pop();
ops.push(if name == "triad" {
Op::DiatonicTriad(pattern)
} else {
Op::DiatonicSeventh(pattern)
});
return true;
}
return false;
}
if let Some(pattern) = theory::lookup(name) {
ops.push(Op::Degree(pattern));
return true;

View File

@@ -23,7 +23,100 @@ pub(super) const WORDS: &[Word] = &[
compile: Simple,
varargs: false,
},
// Harmony
Word {
name: "key!",
aliases: &[],
category: "Harmony",
stack: "(root --)",
desc: "Set tonal center for scale operations",
example: "g3 key! 0 major => 55",
compile: Simple,
varargs: false,
},
Word {
name: "triad",
aliases: &[],
category: "Harmony",
stack: "(degree -- n1 n2 n3)",
desc: "Diatonic triad from scale degree (follows a scale word)",
example: "0 major triad => 60 64 67",
compile: Simple,
varargs: true,
},
Word {
name: "seventh",
aliases: &[],
category: "Harmony",
stack: "(degree -- n1 n2 n3 n4)",
desc: "Diatonic seventh from scale degree (follows a scale word)",
example: "0 major seventh => 60 64 67 71",
compile: Simple,
varargs: true,
},
// Chord voicings
Word {
name: "inv",
aliases: &[],
category: "Chord",
stack: "(a b c.. -- b c.. a+12)",
desc: "Inversion: bottom note moves up an octave",
example: "c4 maj inv => 64 67 72",
compile: Simple,
varargs: true,
},
Word {
name: "dinv",
aliases: &[],
category: "Chord",
stack: "(a b.. z -- z-12 a b..)",
desc: "Down inversion: top note moves down an octave",
example: "c4 maj dinv => 55 60 64",
compile: Simple,
varargs: true,
},
Word {
name: "drop2",
aliases: &[],
category: "Chord",
stack: "(a b c d -- b-12 a c d)",
desc: "Drop-2 voicing: 2nd from top moves down an octave",
example: "c4 maj7 drop2 => 55 60 64 71",
compile: Simple,
varargs: true,
},
Word {
name: "drop3",
aliases: &[],
category: "Chord",
stack: "(a b c d -- c-12 a b d)",
desc: "Drop-3 voicing: 3rd from top moves down an octave",
example: "c4 maj7 drop3 => 52 60 67 71",
compile: Simple,
varargs: true,
},
// Transpose
Word {
name: "tp",
aliases: &[],
category: "Harmony",
stack: "(n --)",
desc: "Transpose all ints on stack by N semitones",
example: "c4 maj 3 tp => 63 67 70",
compile: Simple,
varargs: true,
},
// Chords - Triads
Word {
name: "pwr",
aliases: &[],
category: "Chord",
stack: "(root -- root fifth)",
desc: "Power chord",
example: "c4 pwr => 60 67",
compile: Simple,
varargs: true,
},
Word {
name: "maj",
aliases: &[],
@@ -155,6 +248,36 @@ pub(super) const WORDS: &[Word] = &[
compile: Simple,
varargs: true,
},
Word {
name: "augmaj7",
aliases: &[],
category: "Chord",
stack: "(root -- root third fifth seventh)",
desc: "Augmented major 7th",
example: "c4 augmaj7 => 60 64 68 71",
compile: Simple,
varargs: true,
},
Word {
name: "7sus4",
aliases: &[],
category: "Chord",
stack: "(root -- root fourth fifth seventh)",
desc: "Dominant 7 sus4",
example: "c4 7sus4 => 60 65 67 70",
compile: Simple,
varargs: true,
},
Word {
name: "9sus4",
aliases: &[],
category: "Chord",
stack: "(root -- root fourth fifth seventh ninth)",
desc: "9 sus4",
example: "c4 9sus4 => 60 65 67 70 74",
compile: Simple,
varargs: true,
},
// Chords - Sixth
Word {
name: "maj6",
@@ -176,6 +299,26 @@ pub(super) const WORDS: &[Word] = &[
compile: Simple,
varargs: true,
},
Word {
name: "maj69",
aliases: &[],
category: "Chord",
stack: "(root -- root third fifth sixth ninth)",
desc: "Major 6/9",
example: "c4 maj69 => 60 64 67 69 74",
compile: Simple,
varargs: true,
},
Word {
name: "min69",
aliases: &[],
category: "Chord",
stack: "(root -- root third fifth sixth ninth)",
desc: "Minor 6/9",
example: "c4 min69 => 60 63 67 69 74",
compile: Simple,
varargs: true,
},
// Chords - Extended
Word {
name: "dom9",
@@ -217,6 +360,16 @@ pub(super) const WORDS: &[Word] = &[
compile: Simple,
varargs: true,
},
Word {
name: "maj11",
aliases: &[],
category: "Chord",
stack: "(root -- root third fifth seventh ninth eleventh)",
desc: "Major 11th",
example: "c4 maj11 => 60 64 67 71 74 77",
compile: Simple,
varargs: true,
},
Word {
name: "min11",
aliases: &[],
@@ -237,6 +390,26 @@ pub(super) const WORDS: &[Word] = &[
compile: Simple,
varargs: true,
},
Word {
name: "maj13",
aliases: &[],
category: "Chord",
stack: "(root -- root third fifth seventh ninth thirteenth)",
desc: "Major 13th",
example: "c4 maj13 => 60 64 67 71 74 81",
compile: Simple,
varargs: true,
},
Word {
name: "min13",
aliases: &[],
category: "Chord",
stack: "(root -- root third fifth seventh ninth thirteenth)",
desc: "Minor 13th",
example: "c4 min13 => 60 63 67 70 74 81",
compile: Simple,
varargs: true,
},
// Chords - Add
Word {
name: "add9",
@@ -309,4 +482,14 @@ pub(super) const WORDS: &[Word] = &[
compile: Simple,
varargs: true,
},
Word {
name: "dom7s11",
aliases: &[],
category: "Chord",
stack: "(root -- root third fifth seventh sharpelev)",
desc: "7th sharp 11 (lydian dominant)",
example: "c4 dom7s11 => 60 64 67 70 78",
compile: Simple,
varargs: true,
},
];