# Direct X10 wont play every type of .wav file

This topic is 2605 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi

I've just learnt that Direct X10 refuses to play every type of wav even though, the secondary buffer was initialized to accept them. Why is this?

http://dl.dropbox.com/u/42518274/DirectXwavesound_tutorial.rar

if you take this section:

 // Load a wave audio file onto a secondary buffer. result = LoadWaveFile("../Engine/data/sound01.wav", &m_secondaryBuffer1); if(!result) { return false; }

and change it to "kanyewestpower.wav" (which is in the data folder), it gives the error that direct X sound couldn't be initialized.
why is this?
The little theory I've got so far is that a reason might be because the kanye west file isn't a 16bit sound file.
But apart from this I'm not sure how much code I have to change before I can get it to work.

 // Load a wave audio file onto a secondary buffer. result = LoadWaveFile("../Engine/data/kanyewestpower.wav", &m_secondaryBuffer1); if(!result) { return false; }

##### Share on other sites

Second, give some more specifics about the problem. Yes, you said that DirecX Sound couldn't be initialized, but what exactly does LoadWaveFile return? An error code? What's the exact value of the error code? What exactly is LoadWaveFile doing? Yeah, I could download the project, browse through it, try to build it (assuming I have all the dependencies installed on my machine), debug it, etc. but I'd much, much rather just have you post the relevant code and have me look at it and try and just use my brain to decipher what's wrong, rather than going through a million steps to see what's wrong.

Post the code for LoadWaveFile and the definition and any uses of [font="CourierNew, monospace"]m_secondaryBuffer1[/font].

##### Share on other sites
just want to make sure, are you saying that using [color=#008800][font=CourierNew, monospace][size=2]"../Engine/data/sound01.wav"[/font] works, but using [color=#008800][font=CourierNew, monospace][size=2]"../Engine/data/kanyewestpower.wav"[/font] doesn't?

Are these two different files? If they are, one thing to check (i know this is quite obvious, but doesn't hurt to ask), is to make sure that the kanyewest file is exactly the correct name, and exactly in that data folder. Just a suggestion

##### Share on other sites
Quoting http://rastertek.com/dx10tut14.html:

I also do a couple other checks to ensure it is a 44.1KHz stereo 16bit audio file. If it is mono, 22.1 KHZ, 8bit, or anything else then it will fail ensuring we are only loading the exact format we want[/quote]

Put a breakpoint on that LoadWaveFile, step through all the checks. I bet the format isn't right.

Also: Be careful to provide full downloads of possibly IP protected stuff. This is bannable offense around here.

##### Share on other sites
DirectSound hasn't been updated since version 8 so we can rule out anything DX10-specific for starters.

It's definitely capable of loading 8-bit WAVs; I have code running right now that loads and plays 8-bit WAVs, using the IDirectSoundBuffer8 interface. Even bloody Quake used it for 8-bit source data back in 1996. No problems there; format ruled out as a potential cause.

DirectSound is not a general purpose WAV loader and player. I'm betting that you're blasting right through a limitation. Like the others said, set some breakpoints and check your HRESULTS.

##### Share on other sites
Your problem is probably related to the file format, but I want to give this tip anyway.

Whenever hard-coding a file name into your code, always go to the file in Explorer, click the file, hit F2 (and on Windows Vista and up also hit Ctrl-A) and then Ctrl-C to copy the file name exactly as it is.
I told a coworker about this a few years ago but he didn’t make it law until the 5 times he had incorrect names in his code. One was because there was a space after the extension (who knows?).
It was that one that broke his back of resistance and he has never had a problem getting exactly the correct file names into his code since.

Anyway it just leaves one less possible error for you to consider when examining these types of issues.

L. Spiro

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633708
• Total Posts
3013468
×