Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (565)
Games in Android Showcase (151)
games submitted by our members
Games in WIP (606)
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 2715 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
« League of Dukes »

« JGO Overlord »

Medals: 950
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,

"We all secretly believe we are right about everything and, by extension, we are all wrong." W. Storr, The Unpersuadables
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.

"We all secretly believe we are right about everything and, by extension, we are all wrong." W. Storr, The Unpersuadables
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

ags1 (11 views)
2015-03-31 10:55:12

theagentd (13 views)
2015-03-27 23:08:20

wxwsk8er (54 views)
2015-03-20 15:39:46

Fairy Tailz (47 views)
2015-03-15 21:52:20

Olo (29 views)
2015-03-13 17:51:59

Olo (32 views)
2015-03-13 17:50:51

Olo (39 views)
2015-03-13 17:50:16

Olo (44 views)
2015-03-13 17:47:07

ClaasJG (58 views)
2015-03-10 11:36:42

ClaasJG (42 views)
2015-03-10 11:33:01
How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27 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!