The sound effect editor in PICO-8 is a good tool for making retro style sound effects. While it fits well into the work flow of the environment that it lives in. Maybe we can take this functionality outside of the PICO-8 world.
The crew behind the system has implemented a function export to extract content from the cartridges. This function can be called from both the internal command line interface and the scripted game code.
Because memorizing this command is cumbersome we will write this in the code editor. Like this:
As a result new sound files will be created in the working directory each time we run the cartridge. Trimming the silence
Consequently all sound effects that don’t make use of the full length available in the sound editor will contain silence for remaining time of the sound. Either you accept this since the audience of the effect wont hear it. Or you trim of the silence.
Since game engines doesn’t have infinite sound buffers to play sounds with, we’ll cut it off.
SoX – Sound eXchange is a program that can manipulate sound files. For this post we will use the ability to remove silence.
For Debian users; installation of SoX can be done with this command:
apt-get install sox
To begin with the removal of silence, we can execute this command on a sound file:
sox input.wav output.wav silence -l 0 1 0.5 0.1%
For the purpose of automation and applying this to many files, we can put a few rules in a Makefile.
IDIR=input ODIR=output INPUT=$(wildcard input/*.wav) OUTPUT=$(INPUT:input/%.wav=output/%.wav) all: $(OUTPUT) $(ODIR)/%.wav: $(IDIR)/%.wav sox $< $@ silence -l 0 1 0.5 0.1%
So far the export has been done on all sound effects. For the purpose of getting the music out, a different procedure has to be done. As it turns out, depending on what view the user is in the editor, different things will be exported.
To export music, the music view has to be active in the editor. Then the following command will export the music.
With that in mind the user has to be in the music view in the editor when the cartridge is executed. And with regards to the sound effects, as long a the enumeration flag %d is in the export command, they will be exported. Finally we can update our export script in the editor:
Thus music and trimmed sound effects are at our disposal!