SoundDriver - emutyworks/Learning-GB-Programming GitHub Wiki
Sound driver for Game Boy developed in Assembly language. (Generate sound data from DefleMask .DMF file)
I plan to develop a low-performance, lightweight sound driver :D
- Related project
SoundEditor
This is a tool to check the sound parameters to set in assembly code.
Changes from rgbds v0.6.1 to v0.9.1
The code on this page assumed the use of rgbds v0.6.1. When using rgbds v0.9.1, please modify as follows.
- Remove "-H" from options.
rgbasm -H -o main.o main.asm
-> rgbasm -o main.o main.asm
- Add DEF to the EQU declaration.
xxxxx EQU x
-> DEF xxxxx EQU x
Demo version ROM | Source | |
---|---|---|
sound_driver_v010.gbc | Supported Noise playback! :D | YouTube |
sound_driver_v09.gbc | Supported Wave playback. | YouTube |
sound_driver_v08.gbc | Supports 2 channel playback. | YouTube |
sound_driver_v07.gbc | RAM is no longer used when playing song data. |
Required resources
WRAM: 154 bytes
HRAM: 8 bytes
- Generate sound_data_tbl.inc from test.dmf
Ver 0.7 ROM 25 Bytes/No uses RAM! :D
Ver 0.6 ROM 25 Bytes/RAM 23 bytes
Ver 0.5 ROM 22 Bytes/RAM 96 bytes
Ver 0.4 ROM 96 bytes
Change log
- Supported Noise playback.
- Supported Wave playback.
- Supported 2 channel playback.
- RAM is no longer used when playing song data.
- Generate sound data from DefleMask .DMF file. (Envelope/Octave/Empty/Volume/Note)
- Compressed Sound and Musical scale data table.
- Download this file.
hardware.inc (GitHub)
https://github.com/emutyworks/Learning-GB-Programming/tree/main/SoundDriver
rgbasm -o main.o main.asm
rgblink -o sound_driver.gb main.o
rgbfix -v -p 0 sound_driver.gb
Generate Assembly code from DefleMask .DMF file
https://github.com/emutyworks/Learning-GB-Programming/tree/main/SoundDriver/tools
Usage:
php convDMF2Hex.php <input filename(dmf)>
Example:
php tools/convDMF2Hex.php tools/test.dmf
*Generating "sound_data_tbl.inc".
Result of generating assembly code from DefleMask .DMF file
*This is the result of the current analysis and may be incorrect. We will publish the program code soon.
Please check Analysis results of DefleMask .DMF file
[INSTRUMENTS_DATA][0][PER_SYSTEM_DATA]=> Array
(
[EnvelopeVolume] => 9
[EnvelopeDirection] => 1
[EnvelopeLength] => 3
[SoundLength] => 49
(
; [Envelope]
ld a,%7654xxxx ; EnvelopeVolume - Initial value of envelope
%xxxx3xxx ; EnvelopeDirection - Envelope 1:UP/0:DOWN
%xxxxx210 ; EnvelopeLength - Number of envelope sweep (# 0-7)
ldh [rAUD1ENV],a
; [Sound length/Wave pattern duty]
ld a,%76xxxxxx ; - Wave Pattern Duty (00:12.5% 01:25% 10:50% 11:75%)
%xx543210 ; SoundLength - Sound length data (# 0-63)
ldh [rAUD1LEN],a
GameBoy Sound Table (musical_scale_list.xlsx
)
Pan Docs: Channel wavelength low
[PATTERNS_DATA][SQ1][0][PATTERN_MATRIX] => Array
(
[0] => Array
(
[NoteForThisIndex] => 0100
[OctaveForThisIndex] => 0100 (NoteForThisIndex:0000 + OctaveForThisIndex:0000 = Empty)
[VolumeForThisIndex] => 0100 (ffff = Empty)
)
)
; [Envelope]
ld a,%7654xxxx ; VolumeForThisIndex - Initial value of envelope
ldh [rAUD1ENV],a
; NoteForThisIndex + OctaveForThisIndex -> GameBoy Sound Table
ld a,%76543210
ldh [rAUD1LOW],a ; Frequency low byte
ld a,%xxxxx210
ldh [rAUD1HIGH],a ; Frequency high byte
- Reference
Specs for DMF (DefleMask Module Format, for DefleMask v1.0.0 and above)
https://www.deflemask.com/DMF_SPECS.txt
Pan Docs: Audio Registers
https://gbdev.io/pandocs/Audio_Registers.html
hardware.inc: Gameboy Hardware definitions
https://github.com/gbdev/hardware.inc/tree/master
Reference
- Chibiakumas: Lesson P21 - Sound on the Gameboy and GBC
https://www.youtube.com/watch?v=LCPLGkYJk5M - Music Note To Frequency Chart
- DefleMask
DefleMask is a cross-platform chiptune music tracker. You can produce video game music for many soundchips and old school game-consoles and computers.