Create a file to play a sound in XNA

Page update date :
Page creation date :

summary

Use the Microsoft Cross-Platform Audio Creation Tool (XACT) to create a file for playing sound in XNA.

XNAでサウンドを再生するためのファイルを作る

Operating environment

Prerequisites

Supported XNA Versions
  • 2.0
  • 3.0
Supported Platforms
  • Windows (XP SP2 or later, Vista)
  • Xbox 360
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).

Sample.wav

First of all, the audio file you want to play in advance. wav. In this case, we will use a file called "Sample.wav".

Microsoft Cross-Platform Audio Creation Tool (XACT)

Launch it by selecting "Microsoft XNA Game Studio - Tools - Microsoft Cross-Platform Audio Creation Tool (XACT)" from the Start menu.

Microsoft Cross-Platform Audio Creation Tool (XACT)

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.

Wave Bank

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.

作成された Wave Bank

Then, "Wave Bank" will be added under "Wave Banks" in the tree, and a window will appear in the right area.

Sound Bank

Then right-click Sound Banks in the tree and select New Sound Bank to create a Sound Bank.

作成された Sound Bank

Like a wave bank, a Sound Bank is created and a window is displayed.

Wave ファイルを追加

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.

追加された Wave ファイル

Then, a wave file (PCM sound source) will be added as shown in the figure on the right.

Sound Bank への追加

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.

Report

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.

Win フォルダ内

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.