<Sound Dev> Great work on the Java Sound API for Linux!

View: New views
4 Messages — Rating Filter:   Alert me  

<Sound Dev> Great work on the Java Sound API for Linux!

by Nerius Landys :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Well, the OpenJDK really improves the audio situation for me on Debian
Linux.  I can now finally mix multiple audios together in the Java
program using Clip, and I can run the Java program while other audio
apps are running.

However, just wanted to point out that on my system the call
"AudioSystem.getClip()" does not work.  It's not stopping me from my
programming, but I thought perhaps it should work.

OpenJDK  Runtime Environment (build 1.6.0_0-b11)
OpenJDK 64-Bit Server VM (build 1.6.0_0-b11, mixed mode)

=============================
import java.io.*;
import javax.sound.sampled.*;

public class PlayAudios {

  public static void main(String[] args)
    throws Exception {
    // This call fails on my 64 bit Debian
    // Lenny 5.0 system, HP Z400 workstation:
    //AudioSystem.getClip();
    // It throws an IllegalArgumentException.

    for (String filename : args) {
      AudioInputStream auIn =
        AudioSystem.getAudioInputStream
        (new File(filename));
      AudioFormat format = auIn.getFormat();
      DataLine.Info info = new DataLine.Info
        (Clip.class, format);
      Clip clip = (Clip) AudioSystem.getLine(info);
      clip.open(auIn);
      clip.start();
    }
    Thread.sleep(3000);
  }

}

Re: <Sound Dev> Great work on the Java Sound API for Linux!

by Bugzilla from cy6erGn0m@gmail.com :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Do you mean that you can play sound with another non-Java applications in the same time? With Sun's JDK 1.6.0u16 i can't do it:
Exception in thread "main" javax.sound.sampled.LineUnavailableException: Audio Device Unavailable
        at com.sun.media.sound.HeadspaceMixer.nResume(Native Method)
        at com.sun.media.sound.HeadspaceMixer.implOpen(HeadspaceMixer.java:346)
        at com.sun.media.sound.AbstractMixer.open(AbstractMixer.java:286)
        at com.sun.media.sound.AbstractMixer.open(AbstractMixer.java:323)
        at com.sun.media.sound.MixerClip.open(MixerClip.java:162)
        at com.sun.media.sound.MixerClip.open(MixerClip.java:256)
        at soundtests.Main.main(Main.java:33)

What is a difference? Is Java Sound has been rewritten for Linux?

2009/11/7 Nerius Landys <nlandys@...>
Well, the OpenJDK really improves the audio situation for me on Debian
Linux.  I can now finally mix multiple audios together in the Java
program using Clip, and I can run the Java program while other audio
apps are running.

However, just wanted to point out that on my system the call
"AudioSystem.getClip()" does not work.  It's not stopping me from my
programming, but I thought perhaps it should work.

OpenJDK  Runtime Environment (build 1.6.0_0-b11)
OpenJDK 64-Bit Server VM (build 1.6.0_0-b11, mixed mode)

=============================
import java.io.*;
import javax.sound.sampled.*;

public class PlayAudios {

 public static void main(String[] args)
   throws Exception {
   // This call fails on my 64 bit Debian
   // Lenny 5.0 system, HP Z400 workstation:
   //AudioSystem.getClip();
   // It throws an IllegalArgumentException.

   for (String filename : args) {
     AudioInputStream auIn =
       AudioSystem.getAudioInputStream
       (new File(filename));
     AudioFormat format = auIn.getFormat();
     DataLine.Info info = new DataLine.Info
       (Clip.class, format);
     Clip clip = (Clip) AudioSystem.getLine(info);
     clip.open(auIn);
     clip.start();
   }
   Thread.sleep(3000);
 }

}



--
-----------------------------------------------------------------
Всего наилучшего

                         <y6erGn0m.

Re: <Sound Dev> Great work on the Java Sound API for Linux!

by Nerius Landys :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Do you mean that you can play sound with another non-Java applications in
> the same time? With Sun's JDK 1.6.0u16 i can't do it:
> What is a difference? Is Java Sound has been rewritten for Linux?

Yes, when using the OpenJDK 1.6, I can play sound from my Java app at
the same time that other audio apps are running, such as video games,
speech-dispatcher, Mumble, etc.  Furthermore, in OpenJDK, I can play 2
Clip objects simultaneously and it will mix them for me (presumably
using ALSA mix program).

On the other hand Sun's JDK does not do all of the above for me.

Thank you, OpenJDK.

Re: <Sound Dev> Great work on the Java Sound API for Linux!

by Damjan Jovanovic-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Sun, Nov 8, 2009 at 12:37 AM, Nerius Landys <nlandys@...> wrote:

>> Do you mean that you can play sound with another non-Java applications in
>> the same time? With Sun's JDK 1.6.0u16 i can't do it:
>> What is a difference? Is Java Sound has been rewritten for Linux?
>
> Yes, when using the OpenJDK 1.6, I can play sound from my Java app at
> the same time that other audio apps are running, such as video games,
> speech-dispatcher, Mumble, etc.  Furthermore, in OpenJDK, I can play 2
> Clip objects simultaneously and it will mix them for me (presumably
> using ALSA mix program).
>
> On the other hand Sun's JDK does not do all of the above for me.
>
> Thank you, OpenJDK.
>

How did you install your OpenJDK? If you're using the Debian package,
I think it comes with Pulseaudio support.

Please check the jre/lib/ext directory and your /usr/share/java
directory for pulse-java.jar.

Regards
Damjan