Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (406)
games submitted by our members
Games in WIP (293)
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 http://www.bfxr.net/  (Read 1754 times)
0 Members and 1 Guest are viewing this topic.
Offline 20thCenturyBoy

Junior Member


Medals: 1


So much to learn, so little time.


« Posted 2011-05-22 16:17:52 »

http://www.bfxr.net/ 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 Member


Medals: 1
Projects: 1



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

Hello,

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.

biro
Offline Riven
« League of Dukes »

JGO Overlord


Medals: 438
Projects: 4


Hand over your head.


« Reply #2 - Posted 2011-05-22 17: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
Projects: Revenge of the Titans, Titan Attacks, Droid Assault, and Ultratron
Games published by our own members! Check 'em out!
Try the Free Demo of Droid Assault
Offline philfrei
« Reply #3 - Posted 2011-05-22 21: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?
1  
2  
3  
4  
5  
6  
7  
8  
         InputStream inStream = 
            PlayASourceDataLine.class.getResourceAsStream("MySound.wav");
         AudioInputStream aiStream =
            AudioSystem.getAudioInputStream(inStream);
         AudioFormat audioFmt = aiStream.getFormat();
         DataLine.Info info = new DataLine.Info(SourceDataLine.class,
               audioFmt);
         System.out.println(info);




"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Offline arielsan
« Reply #4 - Posted 2011-05-22 22:06:57 »

@20thCenturyBoy

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 23: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: http://download.oracle.com/javase/tutorial/sound/converters.html (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.

"Greetings my friends! We are all interested in the future, for that is where you and I are going to spend the rest of our lives!" -- The Amazing Criswell
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (76 views)
2013-05-17 21:29:12

alaslipknot (89 views)
2013-05-16 21:24:48

gouessej (119 views)
2013-05-16 00:53:38

gouessej (113 views)
2013-05-16 00:17:58

theagentd (125 views)
2013-05-15 15:01:13

theagentd (112 views)
2013-05-15 15:00:54

StreetDoggy (156 views)
2013-05-14 15:56:26

kutucuk (178 views)
2013-05-12 17:10:36

kutucuk (178 views)
2013-05-12 15:36:09

UnluckyDevil (186 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.107 seconds with 20 queries.