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.

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

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

| improve this answer | |
  • \$\begingroup\$ 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? \$\endgroup\$ – MichaelHouse Jun 23 '13 at 15:19
  • \$\begingroup\$ According to the OP, and others XNA doesn't seem to support loading 24 bit audio at all. \$\endgroup\$ – bobobobo Jun 23 '13 at 15:23
  • \$\begingroup\$ 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. \$\endgroup\$ – MichaelHouse Jun 23 '13 at 15:31
  • 1
    \$\begingroup\$ 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. \$\endgroup\$ – Patrick Hughes Jun 23 '13 at 17:56
  • 1
    \$\begingroup\$ I know, but now I have to make the obligatory XBox 180 reference to Microsoft being open to completely reversing their stance on things. \$\endgroup\$ – bobobobo Jun 23 '13 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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