Loop a sound from the middle
Tools you need
To play a loop from the middle of the sound, this time we'll use the following two tools:
Download and install Wavosaur
Wavosaur is a tool for editing waveform data in audio files. You can download Wavosaur from:
When you open the page, download the file from the red border link in the picture. There are 32-bit and 64-bit versions, so use the one that was in your running environment.
Wavosaur can be run by EXE alone, so there is no need to install it. Expand to any folder.
Download and install XACT
XACT is a tool that allows you to fine-tune and play game sounds on Windows and Xbox.
XACT is not distributed on its own and comes with XNA Game Studio and the DirectX SDK. This time we'll use the one that came with XNA Game Studio. You can download XNA Game Studio from the following links:
Once downloaded, run the installer to install it. XNA Game Studio is only officially supported up to Windows 7, but we've confirmed that it will be installed in Windows 10 environments as well.
Create a WAVE file with loop points in Wavosaur
Prepare the sound file that you want to loop through in advance. The basic editing is in a WAVE file, but the underlying audio data can also be imported from MP3 files, etc. (The audio file used in this sample is"H/MIX GALLERY"from the site of "Pokkuru No land (k15.mp3)" file)
Run Wavosaur to start it.
The screen is displayed.
Drag and drop the provided audio file onto Wavosaur. The waveform data is displayed.
You can select a range by dragging the waveform data with the mouse. Select the range you want to loop.
From the menu, select Tools >Loop>Create loop points. The same is true when you press the "L" button in the toolbar.
"loop start" and "loop end" are displayed on both sides of the selection. This is the range to be looped.
Choose File > Save from the menu to save the audio data.
The file is basically a wave file. Save it to a folder of yours. If you want to edit it again, you can edit it from the middle by dropping this WAVE file into Wavosaur.
The file is saved. XACT uses this WAVE file. If you edited based on an MP3 file, you no longer want to use the MP3 file.
Create the files you need to play monoGame sound in XACT
From the Start menu, select Microsoft XNA Game Studio 4.0 Refresh > Microsoft Cross-Platform Audio Creation Tool 3 (XACT3). If you installed from the DirectX SDK, etc., please start from there.
It becomes the screen immediately after starting. This time XACT does only the easiest work, so if you want to know how to use it, please check it out on the Web. XACT does not require any special action, even if you use a WAVE file with loop playback settings in the middle.
The first step is to create a project. Click the Button for Creates a new project on the toolbar.
Specifies the location where the project is saved.
After you create the project, right-click Wave Backs and select New Wave Bank.
When you're sure wave bank has been created, right-click Sound Banks and select New Sound Bank.
The screen looks like a diagram.
Drag and drop the wave file you just created into the Wave Bank window.
Then drag and drop the data added to the Wave Bank into the upper-left area of the Sound Bank.
Then drag and drop the data added to the Sound area into the Cue area at the bottom left.
Select the Sound file and verify that Looping in the lower left property is checked for Infinite.
When you're done, click the Build button in the toolbar to build it.
The window appears, but just press the "Finish" button to complete it.
Verify that the Win folder is created in the folder where you saved the project, and that three files are created in it.
Create a game project
All that's left is to register the file and create a program in the MonoGame project. This time I'm creating it in Windows Project. We've confirmed that it works with Windows Store apps and Windows Mobile.
After you create the project, register the three files you just created in XACT in the Content folder. It doesn't have to be a special Content folder.
Open the properties with the three files you added selected.
Change from Copy to Output Directory to Copy If New.
Windows Universal App Project (UAP) is not available with the above settings. Instead, change build action to "Content".
The rest is only the program. It's essentially the same program as sound playback using XACT.
Add Microsoft.Xna.Framework.Audio to the namespace you want to use.
Add the following three lines to the field: AudioEngine, SoundBank, and WaveBank.
You create instances of AudioEngine, SoundBank, and WaveBank in the LoadContent method. Each of them corresponds to the three files added to the Content folder, so please specify it relative to the project root folder.
Here we're playing Cue right away, but in a real game you'll play where you want it.
protected override void LoadContent()
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
// TODO: use this.Content to load your game content here
audioEngine = new AudioEngine(@"Content/LoopSample.xgs");
soundBank = new SoundBank(audioEngine, "Content/Sound Bank.xsb");
waveBank = new WaveBank(audioEngine, "Content/Wave Bank.xwb");
Run in this state and make sure it is looping in the middle. The actual loop control is completed in the WAVE file or XACT phase, so you don't need to make any special configuration in your program.
About compressing audio files
XACT provides the ability to compress audio files to reduce file size. XNA Game Studio was able to play compressed files, but MonoGame does not support them, so there may be exceptions or unintended audio when playing. Only uncompressed wave files can be used in real terms. As you can see, the file size is quite large.
If you really want to reduce the file size, you need to adjust the sampling rate of the WAVE file, and so on.
How iPhone, Android, Linux, and OUYA are available
XACT is a windows and Xbox tool, so it's not sure it will work on other platforms. If necessary, try it out and decide if you want to hire it.