Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

When I try to load .wav file I get an error:

Audio file *.wav contains 24-bit audio. Only 8-bit and 16-bit audio data is supported.

Here is my code:

SoundEffect menuSelectionChange = content.Load<SoundEffect>("Sound/Menu Selection Click");
SoundEffectInstance menuSelectionChangeInstance = menuSelectionChange.CreateInstance();

Even if I delete this code I'm still getting this error.

share|improve this question
1  
Is the error coming from the content pipeline? (You could just convert your audio file in, for example, Audacity.) –  Andrew Russell Jun 23 '13 at 12:15
    
@AndrewRussell Yes, he very obviously has to downsample it to 16 bits per sample. –  bobobobo Jun 23 '13 at 13:00
add comment

1 Answer

You need to downsample your source audio file.

Digital audio is stored as a series of "samples" ("samples" of what a microphone "hears"). There are 2 aspects to sampling: sample rate, and _bits used per sample_. High quality audio is captured at something like 44100 samples per second.

Each sample is just a number though, so that's where "bits per sample" comes in. You can use 8 bits, (usually as type unsigned char), 16 bits (shorts) or even 24 bits per sample to store the audio data.

XNA doesn't seem to like 24 bits per sample. So you need to open the file and re-save it as 16 bits per sample.

Goldwave does this nicely

enter image description here

share|improve this answer
    
This answer doesn't really touch on the possibility of loading 24 bit sounds (as the question asks). Can you maybe explain why it's not possible or how it might be possible but downsampling is the prefered alternative? –  Byte56 Jun 23 '13 at 15:19
    
According to the OP, and others XNA doesn't seem to support loading 24 bit audio at all. –  bobobobo Jun 23 '13 at 15:23
    
My suggestion was just to complete your answer with that information since it's the title question. Someone looking to load 24bit audio may come here and only see an answer about downsampling, then move on. Might as well explain in your answer how it's not possible in XNA. –  Byte56 Jun 23 '13 at 15:31
1  
When you get an error from your framework's content pipeline that states "Only 8-bit and 16-bit audio data is supported" you just have to suck it up and feed it 16 or 8 bit audio. If you want to know why then my best guess is that 16/8 is the least common denominator on hardware supported by XNA and 24 just isn't worth their time because not every platform supports it. –  Patrick Hughes Jun 23 '13 at 17:56
1  
I know, but now I have to make the obligatory XBox 180 reference to Microsoft being open to completely reversing their stance on things. –  bobobobo Jun 23 '13 at 23:17
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.