gbaudio
Turn audio and MIDI files into Game Boy music and sound effects, as C for GBDK or a hUGETracker song for GB Studio. Runs in your browser.
Music
For background music: a song is turned into notes (melody, bass and drums) and played as a chiptune on hUGEDriver.
or try or
Echo delay and stereo
MIDI parts which part plays what
Channel 1 plays the melody, 2 the inner voice, 3 (wave) the bass, 4 (noise) the drums. Harmony fills channel 2 as an arpeggio when the inner voice rests.
Recordings type, length, key and stems
- 1 melody
- 2 inner voice
- 3 bass (wave)
Sound effects
For short sounds: a jump, a coin, a word. Copied as it is, so it sounds like the recording, on one channel that it borrows from the music while it plays.
or try
Tuning pitch, volume and noise
- 1 pulse
- 2 pulse
- 3 wave
- 4 noise
- bars: volume, lines: pitch
Saved you some time? Support me on Ko-fi
Questions
Sound effect or music?
A sound effect copies the recording itself, 60 times a second, onto one channel: right for a short sound that should sound like the original. Music turns a song into notes and plays those on three or four channels: a chiptune version, not the recording. A spoken "game over" is an effect; a theme song is music.
What does it make?
C source for a GBDK game: a sound effect as a stream of Game Boy sound register writes, and music as a hUGEDriver song. Music also downloads as a .uge file, the same song for hUGETracker (1.0 and up) and GB Studio (3.2.1 and up), to edit it or to use it in a GB Studio game, and as a MIDI file (the download button on the piano roll) for a DAW or notation program.
How do I use it in my game?
In GB Studio: download the .uge, put it in your project's assets/music folder and pick it in a Play Music event (with the hUGEDriver music driver, the default since GB Studio 3).
Music in GBDK: add the song's .c file and hUGEDriver 6.1 (6.1.0 to 6.1.3, the current release) to your project. Start the song once, and let the driver play it every frame from the VBlank interrupt, as hUGEDriver's own example does: called from your main loop instead, every frame your game runs late costs the song a tick, and the music drags and hurries.
#include "hUGEDriver.h"
extern const hUGESong_t my_song;
BANKREF_EXTERN(my_song)
NR52_REG = 0x80; NR51_REG = 0xFF; NR50_REG = 0x77; // sound on
SWITCH_ROM(BANK(my_song)); // keep the song's bank switched in
__critical {
hUGE_init(&my_song);
add_VBL(hUGE_dosound); // every frame, however long your game's frames take
}
while (1) {
vsync();
// your game
}
If your game switches ROM banks itself, play the song from a function of your own that switches to its bank around hUGE_dosound(); and back, and add that one instead.
Sound effects: add the effect's .c file and this small player, sfx.c and sfx.h. Play an effect with sfx_play(my_effect);, and call sfx_update(); every frame right after hUGE_dosound();, from the same interrupt: add a function that calls both instead of hUGE_dosound alone. While it plays, the effect borrows its channel from the music.
Which files work?
Anything your browser can decode (.wav, .ogg, .mp3 and more), and MIDI files for music. A MIDI file is a score, so its notes are used as they are; a recording is analysed for its melody, bass and drums.
How do I get better music from a recording?
Tick Notes via Basic Pitch under the drop box: Spotify's Basic Pitch writes down the recording's notes, right in your browser, the same ones its site gives you as a MIDI file, and gbaudio arranges those instead of its own guesses. A MIDI file of the song from elsewhere goes under Recordings › Stems / notes and works the same way.
How close is the preview?
Rough: it emulates the four channels with Web Audio, so you can hear the result without building a ROM. A real Game Boy or an emulator is the final word.
Is it private?
Yes. It's written in C and compiled to WebAssembly, so it runs in your browser and nothing gets uploaded.