Expand description
The demoโs two pieces of music, written out as MIDI events.
The demo carries no MIDI asset: both tracks are short enough to state, and stating them keeps the notes in the source that shapes them.
Re-exportsยง
use std::sync::Arc;๐use unlit3dx::prelude::MidiEvent;๐use unlit3dx::prelude::MidiEventKind;๐use unlit3dx::prelude::midi_file;๐use unlit3dx::synth::MidiFile;๐
Constantsยง
- BGM_
ARPEGGIO ๐ - Which chord key sounds on each of a barโs eight eighths: up the chord and back down again, so the accompaniment moves with the balls.
- BGM_
BAR_ ๐SECONDS - How long one bar of the background loop lasts, in seconds.
- BGM_
CHORDS ๐ - The bars of the background loop, as chords: three keys each, root first. Four bars of a I-vi-IV-V turnround, twice, so the loop breathes without changing key.
- BGM_
MELODY ๐ - The melody over the loop, as scale degrees: an index into
SCALE, orNonefor a rest. One entry per half bar. - ELECTRIC_
PIANO_ PROGRAM - The General MIDI electric piano, as a zero-based program number: soft enough to sit under the sequence without competing with it.
- MUSIC_
BOX_ PROGRAM - The General MIDI music box, as a zero-based program number: a bell like plucked timbre that stays smooth where a piano turns brash.
- SCALE
- The pentatonic scale the sequence walks, as MIDI keys.
Functionsยง
- bgm_
midi - The looping background music: a bass note per bar, the chordโs keys arpeggiated across its eight eighths, and a slow melody on top, all on the electric piano. Written out as events rather than read from a file: the demo carries no MIDI asset, and the loop is short enough to state.
- note ๐
- Push one note onto an event list: a press at
start, a releaseholdseconds later, both onchannel. - sequence_
midi - The demoโs MIDI sequence: the scale walked up and back down, one note every 0.28 seconds, each held for 0.25 of them, on the music box.