Create a file to play a sound in XNA
summary
Use the Microsoft Cross-Platform Audio Creation Tool (XACT) to create a file for playing sound in XNA.
Operating environment
Prerequisites
Supported XNA Versions |
|
Supported Platforms |
|
Windows Required Vertex Shader Version | 1.1 |
Windows Required Pixel Shader Version | 1.1 |
Operating environment
platform |
substance
Note: These tips are based on XNA Game Studio 2.0.
Before you can play a sound in XNA, you must convert the wave file to an XNA sound file using the Microsoft Cross-Platform Audio Creation Tool (XACT).
First of all, the audio file you want to play in advance. wav. In this case, we will use a file called "Sample.wav".
Launch it by selecting "Microsoft XNA Game Studio - Tools - Microsoft Cross-Platform Audio Creation Tool (XACT)" from the Start menu.
The Microsoft Cross-Platform Audio Creation Tool (XACT) v2.0 starts. (Henceforth referred to as "XACT")
Click the "Creates a new project" button from the tool button.
When the save dialog is displayed, select the folder and project name where you want to save the project, and then click the "Save" button.
In the sample, it is created under the name "Audio".
You will be returned to the previous screen and the project will be created. Various items are also available for editing.
Once you've created your project, the first step is to create a Wave Bank. Right-click Wave Banks from the tree and select New Wave Bank. It can also be created from the toolbar button.
Then, "Wave Bank" will be added under "Wave Banks" in the tree, and a window will appear in the right area.
Then right-click Sound Banks in the tree and select New Sound Bank to create a Sound Bank.
Like a wave bank, a Sound Bank is created and a window is displayed.
After you create a wave bank and a sound bank, add the wave file you want to play to the Wave Bank. You can add it by dragging and dropping from Windows Explorer, etc.
Projects are managed by wave files "relative paths", so it's a good idea to put them in the same folder as the project when registering a wave.
Then, a wave file (PCM sound source) will be added as shown in the figure on the right.
Next, drag and drop the data added to the wave bank to the upper left area of the sound bank.
It will be added as sound data as shown in the figure on the right.
In the same way, add sound data to the cue by dragging and dropping. The name of the cue is used to play the sound data.
You can change the names of wave banks and sound banks in the tree. This name is used when loading programmatically.
Once you have set up your wave and sound banks, click the Builds the current project button from the toolbar. The Build... menu in the File menu and the F7 key do the same thing.
A dialog like the one on the right will be displayed, but for the time being, click the "Finish" button as it is.
When the build is complete, you can save and exit XACT.
If you look at the folder where you created the project, you will see that the files and folders like the one on the right have been created.
When you open the Win folder, you will see a file similar to the one on the right. The program reads these files and plays the sound.