Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JavaSound error when playing exported WAV file from  (Read 4880 times)
0 Members and 1 Guest are viewing this topic.
Offline 20thCenturyBoy

Senior Devvie

Medals: 3

So much to learn, so little time.

« Posted 2011-05-22 14:17:52 » lets you generate sound effects and then save them as a Wav file.
However, I keep getting a Java exception "UnsupportedAudioFileException" when trying to play them as clips. Audacity can play them ok. I can play other Wav files fine in JavaSound, just not the ones from bfxr.

Is it because Wav is actually just a container and the actual audio data is something JavaSound doesn't understand? How could I find out what it is?

"I have never done unit testing and I don’t find it a very useful concept" - Jonathan Blow
Offline biro

Junior Devvie

Medals: 1
Projects: 1

« Reply #1 - Posted 2011-05-22 14:42:17 »


What I would do, is try to convert the sound file twice the first time to, as example, mp3 and the second time back to wav. I think that could solve the problem.

Offline Riven

« JGO Overlord »

Medals: 1339
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #2 - Posted 2011-05-22 15:05:22 »

A bit of a long shot, but maybe your WAV files are generated with big-endian byte order. JavaSound doesn't support that. You might want to look in bfxr for little-endian WAV generation.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline philfrei
« Reply #3 - Posted 2011-05-22 19:54:45 »

I think Riven is probably right. There are lots of .wav variants, including things like 16-bit vs 32-bit, as well as the little vs big endian issue.

I just ran a program through the Eclipse debugger, based upon the info in the tutorial, inspecting the supported formats of a LineInfo object, and see 8 variants:

BigEndian = false, PCM_UNSIGNED, channels = 1, bits = 8
BigEndian = false, PCM_SIGNED, channels = 1, bits = 8
BigEndian = false, PCM_SIGNED, channels = 1, bits = 16
BigEndian = true, PCM_SIGNED, channels = 1, bits = 16
BigEndian = false, PCM_UNSIGNED, channels = 2, bits = 8
BigEndian = false, PCM_SIGNED, channels = 2, bits = 8
BigEndian = false, PCM_SIGNED, channels = 2, bits = 16
BigEndian = true, PCM_SIGNED, channels = 2, bits = 16

I haven't run this through all my AudioSystem "Mixers" though, but I'm guessing this list is standard for what is supported.

Perhaps the following will help to inspect the format of the wav file you are trying to play?
         InputStream inStream = 
         AudioInputStream aiStream =
         AudioFormat audioFmt = aiStream.getFormat();
         DataLine.Info info = new DataLine.Info(SourceDataLine.class,

music and music apps:
Offline arielsan
« Reply #4 - Posted 2011-05-22 20:06:57 »


I have a similar problem, can't reproduce exported WAVs from bfxr using libGDX.

As a workaround, I am opening them with Audacity and exporting them in OGG format to be used in my games.

Offline philfrei
« Reply #5 - Posted 2011-05-23 21:15:29 »

I just checked out bfxr and generated a wav.

If you right click on the wav you save, and inspect the properties, (assuming Windows, I'm not sure how this is done on a Mac or Linux), the "Summary" tab of properties displays: "Bit rate" "Channels" "Audio sample size" "Audio sample rate".

On my wav, the "Audio sample size" is 32-bits. I think Java only supports a max of 16-bits. (See the posting I have a couple before this one.) So, that would account for an "Unsupported format" error.

I haven't fully explored the file & format converters in this tutorial: (see the section "Converting Audio between Different Data Formats") so the "easy" way they have of doing the conversion may or may not be supported. I don't know.

But, I know it is possible to iterate through the data and convert it yourself. For example, I think it should be possible to convert the four bytes to a long, and then make the long a short int and convert that back to bytes. Or maybe the four bytes need to become a float between 0.0 and 1.0 and then converted back to 16 bit resolution. I think I can help with the coding of this if you run into any snags.

But it might be simpler to load the sound into a utility (I would import to my Sonar audio tool) and then export it as a 16-bit wav. Some of the other previous suggestions might accomplish this.

music and music apps:
Pages: [1]
  ignore  |  Print  

DesertCoockie (20 views)
2018-05-13 18:23:11

nelsongames (68 views)
2018-04-24 18:15:36

nelsongames (65 views)
2018-04-24 18:14:32

ivj94 (748 views)
2018-03-24 14:47:39

ivj94 (79 views)
2018-03-24 14:46:31

ivj94 (595 views)
2018-03-24 14:43:53

Solater (95 views)
2018-03-17 05:04:08

nelsongames (168 views)
2018-03-05 17:56:34

Gornova (378 views)
2018-03-02 22:15:33

buddyBro (1038 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!