• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
 Sound Effects and Audio
 

Sound Effects and Audio

on

  • 1,398 views

Programing game in XNA

Programing game in XNA

Statistics

Views

Total Views
1,398
Views on SlideShare
1,398
Embed Views
0

Actions

Likes
0
Downloads
25
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Control the objects on the screen and give your application some user interaction. Mouse input is never available on the Xbox360,andThe Zune only supports its emulated controls—you won’t be plugginga mouse, a keyboard, or any other input devices into a Zune anytime soon.
  • What would your favorite game be like without sound?
  • You don’t need to include the .wav files as content in the project, because the final wave bank will contain all sound files included in the audio project when you compile your game.
  • Tại sao không dùng XACT3? Sinh viên tự tìm hiểu
  • Save the project as MySounds.xap. You’re ready to use the sounds in your program!
  • Ô bên trái góc dưới màn hình để thiết lập các tùy biến cho âm thanh
  • You need to create the following three objects to manage the file contentsAudioEngine: This object is the program reference to the audio services in the computer, and is used mainly to adjust a few general settings and as a parameter to create the wave and sound banks. When creating an AudioEngine object in your program, you need to use the name of the global settings file for the XACT content as a parameter. This settings file name is generated when the XAP file is compiled, and as a default has the same name as the XAP file, with an .xgs extension.WaveBank: This is a collection of wave files. To create this bank in your code, you need to pass as parameters the AudioEngine object (which must be previously created) and the compiled wave bank file, which is generated when you compile your project with the default name Wave Bank.xwb. Although the wave bank is not explicitly used in your program, you need to create this object, because the sound cues in the sound bank depend on the wave files in this bank.SoundBank: This is a collection of sound cues. You can define cues as references to the wave files stored in the wave bank, along with properties that establish details on how to play these wave files and methods that let you manage their playback.
  • You need to create the following three objects to manage the file contentsAudioEngine: This object is the program reference to the audio services in the computer, and is used mainly to adjust a few general settings and as a parameter to create the wave and sound banks. When creating an AudioEngine object in your program, you need to use the name of the global settings file for the XACT content as a parameter. This settings file name is generated when the XAP file is compiled, and as a default has the same name as the XAP file, with an .xgs extension.WaveBank: This is a collection of wave files. To create this bank in your code, you need to pass as parameters the AudioEngine object (which must be previously created) and the compiled wave bank file, which is generated when you compile your project with the default name Wave Bank.xwb. Although the wave bank is not explicitly used in your program, you need to create this object, because the sound cues in the sound bank depend on the wave files in this bank.SoundBank: This is a collection of sound cues. You can define cues as references to the wave files stored in the wave bank, along with properties that establish details on how to play these wave files and methods that let you manage their playback.
  • You can play a sound in two ways: with a simple playback or in a playback loop. Once you initialize the audio objects, doing a playback is a matter of calling a simple method: PlayCue. You can improve on the previous example by playing a sound cue every time the sprites collide.
  • You can play a sound in two ways: with a simple playback or in a playback loop. Once you initialize the audio objects, doing a playback is a matter of calling a simple method: PlayCue. You can improve on the previous example by playing a sound cue every time the sprites collide.

 Sound Effects and Audio Sound Effects and Audio Presentation Transcript

  • Sound Effects and Audio
    Tran Minh Triet – Nguyen KhacHuy
    Faculty of Information Technology
    University of Science, VNU-HCM
  • XNA and Sound
    XNA 3.0+ allows us to access sounds in two ways
    Direct access
    Microsoft Cross-Platform Audio Creation Tool (XACT)
    Before 3.0, you could only use XACT
  • Direct Access
    Place mp3 or wav files into your content folder.
    Access wav with SoundEffect
    Access mp3 with Song
  • Direct Access - Example
    Start a new “XNA Windows Game” project
    Add two member variables
    SoundEffect soundEffect;
    Song song
    Looking for start.wav, Kalimba.mp3 media in SimpleSounds Demo project
    Adding the media to Content
  • Direct Access - Example
  • Direct Access - Example
    In LoadContent add the following lines
    //Load the sound
    soundEffect = Content.Load<SoundEffect>(@"Audiostart");
    song = Content.Load<Song>(@"AudioKalimba");
    //Play the sound
    MediaPlayer.Play(song);
  • Direct Access - Example
    In Update add the following lines
    // TODO: Add your update logic here
    if (Keyboard.GetState().IsKeyDown(Keys.Space))
    soundEffect.Play();
    Build and compile the project
    Trying to listen the sounds which are played in the same time
  • XACT
    Use this to bundle raw wave files together
    Add effects to sound
    Generated by the Microsoft Cross-Platform Audio Creation Tool, known as XACT
    Not a sound editor, just used to bundle files together or change effects.
  • XACT - How to do
    Making Sounds with XNA Game Studio and XACT
    Step 1: Get A Wave File
    Step 2: Create an XACT Project with Wave Files
    Step 3: Load an XACT Project Through the Content Pipeline
    Step 4: Play Sounds Using the Audio API
  • Step 1: Get a wave file
    Audio in XNA Game Studio is, at heart, wave-based
    Repairing the media by resusing start.wav file
    Don’t need to include the start.wav file as content in the project
    Go to the next step
  • Step 2: Create an XACT Project
    Start XACT by choosing Start ➤ Programs ➤ Microsoft XNA Game Studio 3.0 ➤ Tools ➤ Cross-Platform Audio Creation Tool 2 (XACT2)
    In the XACT main window, choose File ➤ New Project, and save it as mysound.
    On the left side of the window, right-click Wave Bank and select New Wave Bank
  • Step 2: Create an XACT Project
    From the new wave bank, right click and choose Insert Wave File(s)
    Also need to create a New Sound Bank
    Drag the ‘start’ wave bank to the Sound Bank panel
    Looking at the panel on the left bottom corner, configure settings as you want
    Save the project as MySounds.xap
  • Step 2: Create an XACT Project
  • Step 3: Load XACT
    There are three objects to manage the file contents
    AudioEngine
    Reference to the audio services
    Adjust settings to create the wave and sound banks
    Generating the .xgs file when XAP file is compiled
  • Step 3: Load XACT
    WaveBank
    A collection of wave files
    Pass as parameters the AudioEngine object
    Generating the .xwb file
    It’s not explicitly used, but needing to create
    SoundBank
    A collection of sound cues
  • Step 3: Load XACT
    Adding the mysound.xap file to Content
    Create audio objects
    // Audio objects
    AudioEngine audioEngine;
    WaveBank waveBank;
    SoundBank soundBank;
  • Step 3: Load XACT
    Initialize the audio components
    audioEngine = new AudioEngine(@"ContentMySound.xgs");
    // Assume the default names for the wave and sound banks.
    // To change these names, change properties in XACT.
    waveBank = new WaveBank(audioEngine, @"ContentWave Bank.xwb");
    soundBank = new SoundBank(audioEngine, @"ContentSound Bank.xsb");
  • Step 4: Using Audio in Games
    Calling a simple method PlayCue to play
    soundBank.PlayCue(“start");
  • Step 4: Using Audio in Games
    Calling a simple method PlayCue to play
    soundBank.PlayCue(“start");
    Or
    Cue mySound;
    mySound = soundBank.GetCue(" start");
    mySound.Play();
  • Q&A
    ?
  • References
    XNA framework input
    http://msdn.microsoft.com/en-us/library/bb203895(XNAGameStudio.30).aspx
    Ebook
    Learning XNA 3.0 – Aaron Reed
    Beginning XNA 2.0 Game Programming