Skip to main content

Module music

Module music 

Source
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, or None for 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 release hold seconds later, both on channel.
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.