Engine Overview
MUSE loads song descriptions from JSON and turns them into MIDI compositions. The core flow looks like this:
- Load configuration –
SongLoaderdeserializes JSON into aSongobject (name, duration, tempo, scales, chord progressions, tracks, seed, etc.). - Initialize generator –
Programbuilds aGenerativeEngine, passing the song and timing information (ticks per second derived from tempo and time division). - Generative logic –
GenerativeEnginecreates oneTrackChunkper configured track. It walks the song timeline in seconds, derives active chords from the progression list, and uses a deterministic pseudo-random generator seeded withSong.Seedso that runs are repeatable. - Note rendering – Each note is produced through the
MidiExtensions.InsertNotehelper. This converts seconds to MIDI ticks and writesNote On/Offevents with channel, velocity, and duration. - Metadata – Tempo (
SetTempoEvent) and key signature events are written to a meta track so downstream DAWs understand the musical context.
Configuration Anatomy (song_f_minor.json)
{
"Name": "Nocturne of Shadows",
"BaseNote": 41,
"KeySignature": "F Minor",
"Tempo": 68,
"Duration": 420,
"ChordProgressions": [
{
"name": "Gathering Gloom",
"sequence": [ "i", "iv", "i", "VI", "iv", "ii°", "v", "i" ]
},
{
"name": "Midnight Climax",
"sequence": [ "i", "ii°", "v", "VI", "iv", "ii°", "v", "i" ]
},
{
"name": "Dawn Release",
"sequence": [ "iv", "VI", "iii", "VII", "i", "iv", "V", "i" ]
}
],
"Scales": [
{ "name": "F Natural Minor", "intervals": [ 0, 2, 3, 5, 7, 8, 10 ] },
{ "name": "F Harmonic Minor", "intervals": [ 0, 2, 3, 5, 7, 8, 11 ] },
{ "name": "F Phrygian", "intervals": [ 0, 1, 3, 5, 7, 8, 10 ] }
],
"Tracks": [
{
"name": "Fog Drone",
"octave": -1,
"offset": -3,
"period": 30,
"inPosition": 0,
"outPosition": 240,
"affluence": 2,
"chord": [ 0, 2, 5 ]
},
{
"name": "Pulse Undercurrent",
"octave": 0,
"offset": -1,
"period": 12,
"inPosition": 60,
"outPosition": 300,
"affluence": 4,
"chord": [ 0, 3, 6 ]
},
{
"name": "Embers Fade",
"octave": 1,
"offset": 0,
"period": 20,
"inPosition": 300,
"outPosition": 420,
"affluence": 3,
"chord": [ 0, 2, 5 ]
}
],
"Seed": [ 6, 1, 4, 9, 2, 7, 3, 5 ],
"Algorithm": "D"
}
- BaseNote / KeySignature / Tempo / Duration – Global musical context. Duration is in seconds; tempo feeds the ticks-per-second conversion.
- ChordProgressions – Ordered sets of roman-numeral chords that drive the harmonic timeline. The engine interpolates through these sequences so tracks emphasize appropriate tones.
- Scales – Pools of intervals the generator can draw from. Multiple scales let a song shift flavor (e.g., natural vs harmonic minor) while staying in key.
- Tracks – Each entry describes a performance layer. Parameters such as
octave,offset, andperioddefine the register, melodic movement frequency, and rhythmic spacing.inPosition/outPosition(seconds) gate when the track plays, andaffluenceaffects density and velocity. Optionalchordarrays bias the track toward specific chord tones when the progression calls for them. - Seed – Seeding the pseudo-random generator ensures deterministic results; change it to explore new variations without altering structure.
- Algorithm – Currently
Dtells the engine to use its chord-aware generative routine.