Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
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 2528 times)
0 Members and 1 Guest are viewing this topic.
Offline 20thCenturyBoy

Senior Member


Medals: 3


So much to learn, so little time.


« Posted 2011-05-22 14: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 14: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: 801
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?
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 20: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 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: 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.

 

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

The first screenshot will be displayed as a thumbnail.

Pippogeek (37 views)
2014-09-24 18:13:29

Pippogeek (29 views)
2014-09-24 18:12:22

Pippogeek (18 views)
2014-09-24 18:12:06

Grunnt (42 views)
2014-09-23 16:38:19

radar3301 (24 views)
2014-09-22 01:33:17

BurntPizza (61 views)
2014-09-21 04:42:18

BurntPizza (30 views)
2014-09-21 03:30:30

moogie (36 views)
2014-09-21 02:26:15

UprightPath (49 views)
2014-09-20 22:14:06

BurntPizza (52 views)
2014-09-19 05:14:18
List of Learning Resources
by Longor1996
2014-08-16 12:40:00

List of Learning Resources
by SilverTiger
2014-08-05 21:33:27

Resources for WIP games
by CogWheelz
2014-08-01 18:20:17

Resources for WIP games
by CogWheelz
2014-08-01 18:19:50

List of Learning Resources
by SilverTiger
2014-07-31 18:29:50

List of Learning Resources
by SilverTiger
2014-07-31 18:26:06

List of Learning Resources
by SilverTiger
2014-07-31 13:54:12

HotSpot Options
by dleskov
2014-07-08 03:59:08
java-gaming.org 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‑gaming.org
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!