This is the mail archive of the
java@gcc.gnu.org
mailing list for the Java project.
javax.sound. - application
- From: "Ewald Peiszer" <ewald dot peiszer at gmx dot at>
- To: java at gcc dot gnu dot org
- Date: Wed, 13 Sep 2006 21:56:52 +0200
- Subject: javax.sound. - application
Hi,
I wrote a little sound app using javax.sound.-classes.
I finally succeeded in compiling it to native code using gcj 4.1. However, when I invoke the binary (which is basically an audio player that plays two files at the same time) there is the following exception trace:
Exception in thread "main" javax.sound.sampled.UnsupportedAudioFileException: file type not recognized
at javax.sound.sampled.AudioSystem.getAudioInputStream(libgcj.so.7)
at untitled1.PlaySoundStream.streamSampledAudio(PlaySoundStream)
at untitled1.PlaySoundStream.main(PlaySoundStream)
This happens if I use mp3-files as well as if I use ordinary .wav-files.
I also tried to compile it to a .class file (both with suns java 1.5 jdk and gcj 4.1, see makefile below). Then I ran it using
Sun's java 1.5: works
gij 4.1: doesn't work (Exception in thread "main" java.lang.IllegalArgumentException: format not supported for stream
at javax.sound.sampled.AudioSystem.getAudioInputStream(libgcj.so.7)
at untitled1.PlaySoundStream.streamSampledAudio(PlaySoundStream.java:61)
at untitled1.PlaySoundStream.main(PlaySoundStream.java:24))
kaffe (Engine: Just-in-time v3 Version: 1.1.7 Java Version: 1.4): doesn't work (similar error)
It seems to me that I have to have Java 1.5 somehow to run the stuff, but if I compile it natively gcj probably can't use it (gcj 4.1 =~ Java 1.4 regarding javax.sound ? )
I also find it striking that there are different errors ("file type not recognized" vs "format not supported").
Do you think it is still possible to compile to native code (I would like that for performance reasons, later on it should be possible to decode appr 30 mp3 files at the same time.) Or do you think it actually doesn't matter?
Thanks for your help,
regards
Ewald
Makefile:
--------------------------
JARS=/mnt/d/Uni/11_Ws200607/Praktikum/jar/
IFLAGS=-I$(JARS)jl1.0.jar -I$(JARS)tritonus_share-0.3.6.jar -I$(JARS)tritonus_remaining-0.3.6.jar -I$(JARS)tritonus_mp3-0.3.6.jar
javac:
javac -cp . untitled1/PlaySoundStream.java
native:
gcj $(IFLAGS) untitled1/PlaySoundStream.class --main=untitled1.PlaySoundStream -o PlaySoundStream
class-gcj:
gcj $(IFLAGS) untitled1/PlaySoundStream.java -C
----------------------------
Relevant part of source code:
-------------------------------
import javax.sound.sampled.*;
(......)
// Get an audio input stream from the URL
ain1=AudioSystem.getAudioInputStream(url1);
ain2=AudioSystem.getAudioInputStream(url2);
// Get information about the format of the stream
AudioFormat sourceformat = ain1.getFormat( );
// Audioformat festlegen fuer zu ladende Audiodateien
// (signed, mono)
AudioFormat targetformat = new AudioFormat(44100, 16, 1, true, false);
// stereo
AudioFormat datalineformat = new AudioFormat(44100, 16, 2, true, false);
// convert audio input streams to target format
// first: to pcm-stereo, then to pcm-mono
ain1 = AudioSystem.getAudioInputStream(datalineformat, ain1); // -- this is line 61
ain1 = AudioSystem.getAudioInputStream(targetformat, ain1);
ain2 = AudioSystem.getAudioInputStream(datalineformat, ain2);
ain2 = AudioSystem.getAudioInputStream(targetformat, ain2);
DataLine.Info info=new DataLine.Info(SourceDataLine.class,datalineformat);
// Open the line through which we'll play the streaming audio.
line = (SourceDataLine) AudioSystem.getLine(info);
line.open(datalineformat);
(.......)
-------------------------------------
--
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail