In these past years, VUEngine has improved so much and become better and better in all areas imaginable… well, except a single one: music. As one of the oldest parts of the software, the engine’s sound manager has been seriously lagging behind, supporting only single track music and lacking any tools to actually produce any music, or convert some into the engine’s format.
But that’s history from now on! We have finally filled in the missing puzzle piece and rewritten the entirety of the engine’s sound code. From now on, it is possible to play either PCM, converted from WAV files, or MIDIs, converted to a special format readable by the music player. You can use all 6 tracks, which are automatically allocated and released, and there are fading effects and spatial positioning of audio sources, allowing you to locate the source of a sound thanks to the Virtual Boy’s stereo speakers. You can also modify sound while it is played, and for instance speed it up. See below for a full list of features that are already implemented, as well as possible future additions.
Of course we also added another tool to the existing range of debug tools to accompany the updated sound support. Build your project in tools or debug mode and press LR+RT+RDown in-game to bring up the Sound Test.
You can find a standalone version of the Sound Test tool attached to the post on our Patreon page, including a selection of sample songs and sound effects.
- PCM or MIDI playback
- Multi-track, stereo playback
- Dynamic allocation and release of sound channels
- Support for noise channel
- Playback events to facilitate the synchronization of playback state with game events
- Fade in and fade out effects
- Spatial positioning of audio sources
- Real time speed control
- Sound test accessible through the debugging tools
- Playback priority
- Pause and resume playback based on priorities
- Support for sweep and modulation
- Compressed PCM playback (not very likely due to the strain on the CPU)
- Compressed MIDI playback (may happen but as of now it is not necessary and will hit the performance)
All of this wouldn’t have been possible without the help of various individuals. Thank you! To name a few:
- thunderstruck, for sharing his music converter and playback code; we are using a modified version of the converter for MIDI conversion
- Frostgiant, whose WAV converter we are using to convert PCM music
- DanB, for sharing his MIDI player
- Guy Perfect, for all his valuable work documenting the VSU, among other things
Now that a much sought-after feature, according to our December poll, can be crossed off the list, we’ll go back to the highest priority task, according to that poll, and work towards another Formula V demo. This time, though, other than the first two demos, we plan to release a demo for all of our backers. Also including sound this time, of course. 🙂
In parallel, we’ll keep on working on the de-facto successor to VBDE, VUEngine Studio, a Visual Studio Code extension for Nintendo Virtual Boy game development using VUEngine. Next on the TODO list will be to extend the toolchain to fully support the new sound code and allow for on-the-fly music conversion.
To stay updated, keep an eye on our Twitter, where we plan to (or hope to find the time to) more regularly post some in-development updates about our various projects, or catch us on Discord.
1. Do you have a ROM with the music for me to test in an emulator?
2. Does the engine allow all 8 waveforms on the noise channel?
By the way, awesome work so far! This could potentially hold us off from waiting for VB Music Tracker to come out.
1) The ROM is available for everybody at the end of the Patreon post:
2) Yes, it is possible to use any of the 8 tap locations for noises. Although there is no support to change the tap location per “note” yet. That means that for the time being, each a track that uses the noise channel must set the tap location ahead of being played and cannot change it during playback. Making it so isn’t hard, but I don’t know enough about music to figure out by myself if that is even useful.
The tap locations 4…7 have a very short sequence length, which means they’re great for melodic uses. One such use is playing notes below D#2 (as anything below that note on the first 5 channels will be capped to ~76.294Hz).
Now, lets look at the SN76489, the PSG chip that was responsible for the Sega Master System’s sound. This chip has 3 square channels that can go as low as A-2, and a noise channel.
As SN7 enthusiasts knew better, they realized that the noise channel can play low-frequency pulse bass notes, well, not at the same time as percussion. So they quickly alternate between a frame or two of drum noise, and then the pulse-bass note they desired to play. The same thing can be said with the VSU’s noise channel by quickly changing the tap location.
EDIT: Here’s a Lua script I made that generates the eight waveforms:
As per your suggestion, support has been added to change the tap location on a per note basis when a track uses the noise channel. 🙂
This guy has made a few SN76489 covers that rely heavily on the trick I’m talking about:
Those sound really good!
If you have a MIDI file that applies that trick, I may try to include it in the sound test.
Or you can try it yourself by writing the track by hand, the sound test’s source code is public:
How can I get the thing to play back MIDIs and stuff? All I see is a .VB program. Is there a tool somewhere? I’m confused.
Hi, our SoundManager is not a standalone program intended to just play sounds. It is one of the VUEngine’s classes and its purpose is to enable sound playback in games built with the engine.
With the above in mind, if you want to test it, you will need to download the latest versions of both the VUEngine core library (https://bitbucket.org/vuengine/vuengine-core/src/master/) and of the sound test project (https://bitbucket.org/vuengine/vuengine-sound-test/src/master/) and replace with these the corresponding sources included with VBDE.
To play PCM sounds, an 8bit WAV file must be converted to a special format using Frostgiant’s WAV converter (vbwav, included with VUEngine: https://bitbucket.org/vuengine/vuengine-core/src/master/lib/utilities/).
To play MIDI sounds, a .mid file must be converted to the corresponding special format using our modified version of thunderstruck’s MIDI converter (https://bitbucket.org/vuengine/vuengine-core/src/master/lib/utilities/MIDI-Converter.zip).
Then, the .c files that those programs produce must be used to built a Spec (the engine’s name for *specification) that can be read by the SoundManager (example: https://bitbucket.org/vuengine/vuengine-sound-test/src/master/assets/sounds/SoundTracks/MIDI/ZeldaLinksAwakeningTitle/Spec/ZeldaLinksAwakeningTitleSpec.c).
Then, the new sound’s reference must be add to the _userSounds array to be accesible through the sound test debug tool.
For the moment, it is a relatively involved process, but it was done this way to avoid constantly having to manage the sound registers, waveforms, etc. We are working on a custom editor for the release of our VS Code extension that will automate most of the above.
Finally, if what you need is a way to have sound playback in a game / program for the VB that is not built with the VUEngine, this won’t work for you. You won’t be able to compile our source code without using all our tool chain since it is not plain C anymore and there are lots of dependencies since we use inheritance in our engine.
PS: It is possible to reproduce raw .mid files, but that requires real time decoding. DanB’s MIDI player can be used for that (https://www.planetvb.com/modules/games/?h046d). We tried to include it to facilitate things, but we couldn’t make it work correctly within our engine and it is too heavy to decode MIDI’s format in real time.