1
\$\begingroup\$

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.

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

1 Answer 1

3
\$\begingroup\$

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

\$\endgroup\$
8
  • \$\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\$
    – House
    Commented Jun 23, 2013 at 15:19
  • \$\begingroup\$ According to the OP, and others XNA doesn't seem to support loading 24 bit audio at all. \$\endgroup\$
    – bobobobo
    Commented Jun 23, 2013 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\$
    – House
    Commented Jun 23, 2013 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\$ Commented Jun 23, 2013 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
    Commented Jun 23, 2013 at 23:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .