Converting audio with audioconv64

Now that we have our audio files ready and before we start writing any code, we need to convert our files into the correct format. Libdragon can work with three file formats:

  • WAV – Standard uncompressed audio file
  • XM – Extended module Fastracker format (MIDI-like audio)
  • YM – Atari ST audio format (used for chiptune tracks)

These then need to be converted to N64-compatible formats – .wav64, .xm64 and .ym64 respectively.

To do this, we use the audioconv64 tool included in Libdragon. It can be found at /libdragon/tools/audioconv64 within your project folder. This one is much easier to work with than mksprite since it doesn’t require non-standard libraries.

I’ll include an exe download in case you have trouble compiling. I had a bit of trouble compiling since it threw a bunch of “unknown conversion type character” errors, but those are gone once you remove warnings from the makefile.

Once you have the executable, place it in your PATH folder (for me it’s c:\libdragon) and run it by calling the executable with audioconv64. Here are the options it has (from the help file):

Usage:
   audioconv64 [flags] <file-or-dir> [[flags] <file-or-dir>..]

Supported conversions:
   * WAV => WAV64 (Waveforms)
   * XM  => XM64  (MilkyTracker, OpenMPT)
   * YM  => YM64  (Arkos Tracker II)

Global options:
   -o / --output <dir>       Specify output directory
   -v / --verbose            Verbose mode

WAV options:
   --wav-loop <true|false>   Activate playback loop by default
   --wav-loop-offset <N>     Set looping offset (in samples; default: 0)

YM options:
   --ym-compress <true|false>  Compress output file

Automating audio file conversion

You can add this executable to your Makefile process to make it a lot more streamlined. Here are some additions to the Makefile that can make the processing automatic. This is the file structure:

project_root
└───src
    ├───filesystem
    └───resources
        └───audio

And this it the Makefile that converts audio files to the correct format and moves them to the filesystem directory:

V=1
SOURCE_DIR=src
BUILD_DIR=build
RESOURCES_DIR=$(SOURCE_DIR)/resources
AUDIO_DIR=$(RESOURCES_DIR)/audio
FILESYSTEM_DIR=$(SOURCE_DIR)/filesystem
WAV_FILES=$(wildcard $(AUDIO_DIR)/*.wav)
XM_FILES=$(wildcard $(AUDIO_DIR)/*.xm)
YM_FILES=$(wildcard $(AUDIO_DIR)/*.ym)
AUDIO_FILES=$(WAV_FILES) $(XM_FILES) $(YM_FILES)
AUDIO_OUTPUT_FILES=$(subst resources/audio,filesystem,$(WAV_FILES:.wav=.wav64) $(XM_FILES:.xm=.xm64) $(YM_FILES:.ym=.ym64))

include $(N64_INST)/include/n64.mk

all: hello.z64
.PHONY: all

OBJS = $(BUILD_DIR)/main.o

hello.z64: N64_ROM_TITLE="Hello World"
hello.z64:$(BUILD_DIR)/hello.dfs

$(AUDIO_OUTPUT_FILES): $(AUDIO_FILES)
	@echo "Processing file" $(notdir $@)
	@# Generate and place the converted file in the root directory
	audioconv64 $(AUDIO_DIR)/$(subst .ym64,.ym,$(subst .xm64,.xm,$(subst .wav64,.wav,$(notdir $@))))
	@# Move it to the output directory
	mv $(notdir $@) $@

$(BUILD_DIR)/hello.dfs: $(AUDIO_OUTPUT_FILES)

$(BUILD_DIR)/hello.elf: $(OBJS)

clean:
	rm -f $(BUILD_DIR)/* *.z64
.PHONY: clean

-include $(wildcard $(BUILD_DIR)/*.d)

Loading audio files from the filesystem

There’s a whole page on the DFS that explains this in more detail. Audio files are treated the same as image files in this regard.

Search

Subscribe to the mailing list

Follow N64 Squid

  • RSS Feed
  • YouTube

Random featured posts