User Tools

Site Tools


music_file_format

This is an old revision of the document!


Music File Format

How to do it?

Proposal 1

MUSIC FILE FORMAT v1.0

  • Header (16 bytes):
    • +0: [2] Magic: “SD” ($53 $44)
    • +2: [1] Version (1)
    • +3: [1] Flags
    • +4: [2] Tempo (ms per row)
    • +6: [1] Number of instruments
    • +7: [1] Number of patterns
    • +8: [1] Song length (orders)
    • +9: [7] Reserved
  • Instrument Table (10 bytes each):
    • +0: [1] Instrument ID
    • +1: [1] Instrument Type
  • Waveforms:
    • +2: [1] Waveform (WAVE_xx constant)
    • +3: [1] Pulse width / duty cycle
    • +4: [1] Attack
    • +5: [1] Decay
    • +6: [1] Sustain
    • +7: [1] Release
    • +8: [1] Default volume
    • +9: [1] Reserved
  • Samples:
    • +2: [1] address (bank)
    • +3: [1] address (low byte)
    • +4: [1] address (high byte)
    • +5: [1] Volume
    • +6: [1] Playback speed
    • +7: [1] reserved
    • +8: [1] reserved
    • +9: [1] reserved

NOTE: need to do more research on what data we should include with samples. How does SNES/etc. do it?

  • Order List (1 byte each):
    • Pattern numbers in playback order
    • Terminated by $FF ($FFFF or $0000?)
  • Patterns:
    • Each pattern is a sequence of rows
    • Each row is a sequence of channel commands
    • Row terminated by $00
    • Pattern terminated by $FF (see above)

Row Command Format

Command Byte:

  • Bits 7-6: Channel (0-3)
  • Bits 5-4: Command type
  • Bits 3-0: Depends on command type

OR

  • Command Byte
  • Channel Byte
  • Data Word + Data Word + Data Word (Reserved)

Command Types:

  • 00 = Note On (3 bytes total)
    • [Cmd] [Note] [Instrument]
  • 01 = Note Off (1 byte)
    • [Cmd]
  • 10 = Set Volume (2 bytes)
    • [Cmd] [Volume]
  • 11 = Effect (3 bytes)
    • [Cmd] [Effect Type] [Effect Param]

Note data

  • $00 = Rest (no change)
  • $01-$60 = Notes (C0 to B7)
  • $61 = Note off
  • $FF = End of pattern
  • Note calculation:
    • Note = (Octave * 12) + Semitone + 1
    • C4 = (4 * 12) + 0 + 1 = 49 = $31
    • A4 = (4 * 12) + 9 + 1 = 58 = $3A

Possible TEXT format

  • on a row: CWND CWND CWND CWND
  • “Channel, Waveform, Note, Duration” ex 12G4Q is channel 1, waveform 2, note G4, quarter note
  • Can have commands like TEMPO = 90
music_file_format.1770038972.txt.gz · Last modified: by appledog

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki