Cant use sounds in XNA

Started by
5 comments, last by Deyja 14 years, 5 months ago
Hi there Ive just started using XNA, using the book "Beginning XNA 3.0 Game Programming From Novice to Professional", as a guide. I have created my own version of the game pong, and now i want to add sounds to the game, but i keep getting this error: Error 1 Wave file "C:\Users\Nysom\Programmering\XNA\PingPong\PingPong\Content\..\..\..\..\..\Windows\Media\chord.wav" not found. C:\Users\Nysom\Programmering\XNA\PingPong\PingPong\Content\MySounds.xap PingPong I been doing exactly what the books tells me to: -create a new project using XACT3 -add the files chord.wav and notify.wav to the waves bank -drag them to the sound bank and save project -include the project file as content in my game -plus added the following code to my project: // Audio objects AudioEngine audioEngine; WaveBank waveBank; SoundBank soundBank; protected override void Initialize() { audioEngine = new AudioEngine(@"Content\MySounds.xgs"); // Assume the default names for the wave and sound banks. // To change these names, change properties in XACT. waveBank = new WaveBank(audioEngine, @"Content\Wave Bank.xwb"); soundBank = new SoundBank(audioEngine, @"Content\Sound Bank.xsb"); base.Initialize(); } When i double click the error message it opens the MySounds.xgs file. I dont know what is wrong here, since the book doesnt tell me anymore than what ive done.. Has anyone else experienced the same or know what might be causing this? Anders Nysom
Advertisement
im pretty sure in XNA stuff in the Content, when referencing it in your code, you will leave off the extension (ie the .wav)
well i actually get the error wether i reference the content in the code or not.. just adding the .xap file to the project is enough to get the error... so perhaps the problem lies in the xap file.
Have you built the XACT project?

As of XNA 3.1 you can get away without using the XACT engine, XACT can be a bit confusing to start with.

To play a sound without using XACT follow this guide

http://msdn.microsoft.com/en-us/library/bb195053.aspx

Don't get me wrong I use XACT all the time, and quite like it but for what you are after the SoundEffect thing is easier, there are good example in the doc file.

PS I never bother adding my XACT files to the content dir's just I the files to the directory after I've built them, not the best practice but it works.
Okay thank you very much :)
OK, this is an old post now but thought I would put my 2 pennies in.

When you include the XACT project in XNA it will get compiled by VS, it looks to me that the references you have in the XACT project are wrong...

When using Wave/SoundBank and the AudioEngine you have to specify the extension.

3.1 does make it easier with the SoundEffect assets, but I think you can only get 3D sound with XACT... I might be wrong, it's been a while since I played with XACT, though, I often am :P
Remember that the sounds referenced by the XACT project are relative that project file. So if you copy the .xap to your content directory, you need to copy all the sounds too (Even though they don't get added to the project in visual stuido).

Quote:3.1 does make it easier with the SoundEffect assets, but I think you can only get 3D sound with XACT... I might be wrong, it's been a while since I played with XACT, though, I often am :P

The SoundEffect class can do stereo sound, at least.

This topic is closed to new replies.

Advertisement