[LAD] need help with Java audio problem

Pedro Lopez-Cabanillas pedro.lopez.cabanillas at gmail.com
Fri Aug 15 21:12:59 UTC 2008


Dave Phillips wrote:
> I'm writing an article about Java sound applications, and I've run into
> a problem.
>
> HighC, FScape, and jein all demonstrate the problem: They appear to be
> working as they should, but there's no audio output. According to
> HighC's author, he uses only the recommended class for audio output. I
> quote from our correspondence :
>
> "All I do is call javax.sound.sampled.AudioSystem.getLine() with the
> default settings. It should work as is, that's what the Java spec says.
> Perhaps the Java configuration files allow setting the default audio
> device on Linux?"
>
> So, what is the default audio device for Java 1.6 on Linux ? Is it
> configurable ? If so, where do I find it and how do I set it ? (Btw, I
> have the Sun SDK).

The implementation has changed some times. IIRC it was /dev/dsp long time ago, 
but since then it switched to native ALSA devices. 

Sometime after v1.5.0, it is possible to use "hw:X" and "plughw:X" (dmix) 
devices, but by default I think it uses the "default" ALSA device now, 
whatever is configured with that name. 

> I also have HighC installed under Wine, along with the JRE 1.6 for
> Windows. HighC works as expected there. I could not test jein under
> Wine, it requires javac, which is not included in the JRE.

The compiler is included in the JDK (JSDK), which can be downloaded gratis 
from Sun.

I don't know those programs. Are there sources available?

BTW, maybe you like to know that Gervill, the java free synthesizer has  
released the magic 1.0 number. GPLv2 licensed:

https://gervill.dev.java.net/

This project is proposed as the Audio Synthesis Engine that would be used in  
the GPL java runtime, replacing the old proprietary one. It is a wave table 
synthesizer supporting the standards: DLS2, SoundFont2 and also audio files 
as sound banks. It is worth to try. A MIDI file player is included. A few 
quick tips:

$ unzip gervill-1.0.zip
$ cd gervill/bin
$ java -Xmx256M simplemidiplayer.SimpleMidiPlayer 

(the -Xmx256M argument gives 256 Mb to the player, enough to load a big, good 
soundfont like General User 1.4 by Chris Collins.)

> Any and all suggestions are most welcome, I'm totally clueless when it
> comes to debugging Java.

You can find here some basic FAQ documents:
http://www.jsresources.org/index.html

Maybe you can start trying some basic program, like the SimpleAudioPlayer 
http://www.jsresources.org/examples/SimpleAudioPlayer.html

copy the source code to a file named "SimpleAudioPlayer.java", or download the 
examples from SF, http://sourceforge.net/project/showfiles.php?group_id=11738

compile it with the command:
$ javac SimpleAudioPlayer.java
Run the class with:
$ java SimpleAudioPlayer yourfile.wav

If it works, your java sound is working. If not, maybe there is some error 
message giving a clue.

Regards,
Pedro



More information about the Linux-audio-dev mailing list