NOTE: This tutorial's patch file is outdated. I have created a new one, downloadable in this thread
The MSU-1 is an SNES expansion chip that allows for 4 gigabytes of extra data and CD-quality audio.
In this tutorial I will explain how to set up mapping, how to create .pcm files and play them in your SMW hack.
You will need basic-intermediate knowlegde of ASM.
(Note: I recommend you read the entire tutorial through once before following it!)
First off, you will need to download a few programs.
For converting wav files into .pcm files.
For editing sound files and exporting to .wav files.
For easier editing and creation of .bml files.
Chapter 1: Creating .pcm files
The MSU-1's music files are supplied in the .pcm format. A .pcm is basically a .wav, but with a few identification bytes added at the start. In this chapter I'm going to explain how to create and loop .pcm files using the wav2msu tool.
Open your audio file (the starting format should not matter, since Audacity can convert it!) in Audacity and edit it until you are satisfied with the result. If you don't know how to use Audacity, you can find an overview of basic functions here
Make sure the "Project Rate (HZ) is set to 44100", there are atleast 2 channels (or 1 stereo channel) and the byte order is little endian (If you're exporting from Audacity, this should be fine by default).
The next few lines only apply if you are making a pcm that needs to be looped.
Next, find the start point of your loop. The easiest way to get this done perfectly is by making a selection from roughly where you want your loop point to be to the very end of the song. After this, click the last number in the "Selection Start" box, at the bottom of Audacity.
When you've found the perfect loop point, click the arrow in the "Selection Start" box and set it to "Samples". Write down the number of samples, this will be the start of your loop.
Next, export your song by pressing CTRL+SHIFT+E as "WAV signed 16-bit pcm". Get wav2msu, your newly-created .wav file and cmd.exe in the same folder. Write the following in command prompt:
wav2msu YourWavFileName.wav -l 1234567
Where YourWavFileName is, well, your wav file name, followed by hyphen L (lowercase), followed by the sample number you got from audacity.
Note: If you aren't going to loop your song, or it doesn't need a start of loop point to loop perfectly, you don't have to mark the start in audacity and you can simply do "wav2msu YourWavFileName.wav" .
If everything goes well, wav2msu should output a .pcm file! If it reports an error, you can find more detailed information on what is wrong here
. A possible solution for the Sample Data isn't where it was expected error is removing the metadata by copying the entire song into a new Audacity window, and then exporting.
Name your file track-1.pcm, track-2.pcm and so on.
Chapter 2: Auxiliary files
A bml is no longer neccesary thanks to higan v96.
Instead, you need to name your files in the following way:
ROM: program.rom (must be headerless!)
MSU1 Data: msu1.rom
PCM tracks: track-<number(decimal)>.pcm
Put this in a folder named <hackname>.sfc, and put the folder in your higan library. If you don't know where this is, open icarus.exe and click settings.
(Old chapter 2 (if you need it) can be found Here
Chapter 3: Patch
To make using the MSU-1 easily accessible, I have created a patch that works together with AddmusicK to automatically play all SMW Music with the MSU-1 instead, while retaining SPC functionality to fall back on, if the MSU-1 is not found, or if you want to play music on the SPC and something else on the MSU-1.
You can download it HERE
disclaimer: Although I claim no responsibilities for crashed roms, broken hacks, etc. because of this patch, if you find a bug or issue with it, report it to me and I will try to fix it! Always back up your rom before applying.
Replace AddmusicK/asm/main.asm with the main.asm in the zip file, and AddmusicK/asm/SNES/patch.asm with the patch.asm file. (Note that you might want to back up your AddmusicK folder first, in case you have a rom where you don't want to use this patch)
(I recommend also editing tweaks.asm and setting !JumpSFXOn1DFC = !true to !false)
Next, open newMSUPatch.asm and configure it however you want. Edit the loop table to include your custom songs. If they should be looped, change 00 in the same number you inserted the track to in AMK's list file to 01 for an unlooped song (play only once) or 03 for a looped song.
Note that you will NEED to create a .pcm for the following songs: Death, Game Over, Boss Clear, Stage Clear, Starman, PSwitch, Keyhole, IrisOut, BonusEnd. If you don't do this, the music will go silent when these songs are supposed to play. By default, they are tracks 1 to 9. Make sure they are about as long as SMW's original jingles, and that the Starman and P-Switch tracks are properly looped. If they are too long, they will get cut off by the next track that plays. Mandew has converted the original SMW's tracks into PCM, you can download them Here
. You can use these in your ROM, or use them as a guideline for how long the tracks should be.
Make sure you have expanded and saved your rom using Lunar Magic. Use AddmusicK on your rom, and then apply newMSUPatch.asm to your rom using Asar. From now on, if the MSU-1 is detected, the track that will play every level is the value stored to $1DFB. This means that you can simply set the music in Lunar Magic and it will work. If the MSU-1 is not working, because the player is using an incompatible emulator, it will automatically use the song you inserted in that slot with AddmusicK. (note that you will need to edit the music in level C5 to change the welcome jingle)
Make sure your .bml file is in the same folder as your .msu file, your ROM and your .pcm files.
In order to test if everything works, or to play a MSU-1 ROM, open ZMZ and change the core to a bsnes core, via misc->libretro, then open the BML file, NOT the ROM file.
In the folder is also the file "CheckMSU.asm". This is a modified version of Alcaro's ZSNES check patch that checks if the MSU-1 is working. Feel free to apply it to your ROM if you want to.
Appendix 1: Hack Distribution
Because the filesize of MSU-1 songs can really add up, and there's a 10 MiB filesize limit in the hacks section, I recommend that you distribute your hack without the .pcm and .msu files, and host those yourself for people to download separately.
Appendix 2: Pause Feature
Higan v96 added support for a pause feature. To pause your song, use STZ $2007. To later resume it, use LDA #$05 : STA $2007.
End of tutorial.
Special thanks to Alcaro, Lui37, and Torchkas for helping me.
If there's any issues, questions, bugs or other stuff, don't be afraid to post or query me on IRC and I will try to help you out!