moonshot

technical

noter

noter is the format lira saves songs in. a .not file holds the notes themselves, which pitch, when, for how long and how hard, and no sound at all. the sound is made from the notes every time the song plays, through oljud.

the layout

every field is a 64-bit little-endian number, so a c0 program reads any field with one load64.

offset  field
 0      magic           "noter" and three zero bytes
 8      version         2
16      steps per beat  lira uses 4, so a step is a sixteenth note
24      tempo           beats per minute
32      note count      n
40      n notes, 40 bytes each:
          +0  pitch      midi note number, 0-127, 60 is middle c
          +8  start      in steps
          +16 length     in steps, at least 1
          +24 velocity   1-127
          +32 instrument 0 square, 1 triangle, 2 sawtooth, 3 drum

notes are sorted by start, then by pitch, and no two notes share both. a file that breaks any rule of the format is refused as a whole. version 1 files, which have no instrument, still load as square waves.

from notes to sound

the synthesizer runs in ring 3 next to the format. a note's instrument picks its wave, and its velocity how loud it is. up to eight notes sound at once, and the notes sounding at the same moment are added together.