Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  No sound under Linux + JRE 1.6 update 16  (Read 10108 times)
0 Members and 1 Guest are viewing this topic.
Offline gouessej
« Posted 2010-07-19 21:24:01 »

Hi

I don't know why I have no sound with any applet or Java Web Start application. I get this when I launch TUER :
Quote
[java] Starting up SoundSystem...
     [java] Initializing Java Sound
     [java]     (The Java Sound API.  For more information, see http://java.sun.com/products/java-media/sound/)
     [java] JavaSound initialized.
     [java] Error in class 'ChannelJava Sound'
     [java]     Unable to attach buffer to clip in method 'attachBuffer'
     [java]     ERROR MESSAGE:
     [java]         Audio Device Unavailable
     [java]     STACK TRACE:
     [java]         com.sun.media.sound.HeadspaceMixer.nResume(Native Method)
     [java]         com.sun.media.sound.HeadspaceMixer.implOpen(HeadspaceMixer.java:346)
     [java]         com.sun.media.sound.AbstractMixer.open(AbstractMixer.java:286)
     [java]         com.sun.media.sound.AbstractMixer.open(AbstractMixer.java:323)
     [java]         com.sun.media.sound.MixerClip.open(MixerClip.java:162)
     [java]         paulscode.sound.libraries.ChannelJavaSound.attachBuffer(ChannelJavaSound.java:276)
     [java]         paulscode.sound.libraries.SourceJavaSound.play(SourceJavaSound.java:298)
     [java]         paulscode.sound.Library.play(Library.java:587)
     [java]         paulscode.sound.Library.play(Library.java:556)
     [java]         paulscode.sound.SoundSystem.CommandPlay(SoundSystem.java:1892)
     [java]         paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2388)
     [java]         paulscode.sound.CommandThread.run(CommandThread.java:121)

The audio device is unavailable even though I use directly the Java Sound library. Do you have an idea?

The only Java game that works fine with sound on my machine is "Breaking the tower". TUER and Tesseract don't work anymore Sad

Edit.: this bug is reproducible only when my webcam is connected

Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #1 - Posted 2010-07-19 22:50:57 »

I would guess that JavaSound is trying to pick the webcam as the default audio device, rather than the soundcard.  I am able to produce a similar bug with MIDI, where if I connect my MIDI keyboard, JavaSound will try to play out of it rather than through the soundcard.  When I get a chance, I'll write a test applet that prints out some diagnostic messages to see if this is the same bug you are experiencing here.  If it is, a possible workaround is to choose the Mixer associated with your soundcard manually rather than going with the default Mixer (since JavaSound seems to be making a dumb choice by default).

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #2 - Posted 2010-07-19 23:36:15 »

BTW, I looked at the source code for "Breaking the tower", and the reason why it works while the others don't is because the author didn't use a Mixer to play sound effects.  He not only generates the sound effects programatically, but he also does the mixing programatically.  Everything is placed into a single data stream played through a single SourceDataLine instance acquired with the following line of code:
1  
AudioSystem.getSourceDataLine(audioFormat);

It seems that JavaSound picks the correct device by default when using the getSourceDataLine(...) method, but not when using the getMixer(...) method on the default device named "Java Sound Mixer"Huh  weird..

I actually considered using the single SourceDataLine method in my SoundSystem, but eventually gave up on the idea as it requires a single audio format for the output, which would require me to convert all data loaded or streamed into that format and then passed to a mixing algorithm.  This seemed way to complicated at the time, but I may have to revisit it as a possibility.  I'd probably write a separate Library plug-in rather than changing the one I wrote already.  It would fix another issue where there is no "Java Sound Mixer" available on some Java versions, such as the OpenJDK..

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline gouessej
« Reply #3 - Posted 2010-07-20 10:36:36 »

Do you consider it is a bug of Java? Choosing manually the mixer can cause some regressions on some machines, can't it?

Offline h3ckboy

JGO Coder


Medals: 5



« Reply #4 - Posted 2010-07-20 10:42:17 »

Do you consider it is a bug of Java? Choosing manually the mixer can cause some regressions on some machines, can't it?
you can use the other method he described.
Offline gouessej
« Reply #5 - Posted 2010-07-20 11:00:27 »

you can use the other method he described.
I can't because I don't use several audio files with the same format.

On my view, maybe it is possible to detect the "bad" mixer that matches with my webcam by looking into Mixer.Info instances returned by getMixerInfo or in the Mixer instance itself in order to get a good mixer when calling getMixer(Mixer.info info).

Offline nsigma
« Reply #6 - Posted 2010-07-20 11:45:22 »

On my view, maybe it is possible to detect the "bad" mixer that matches with my webcam by looking into Mixer.Info instances returned by getMixerInfo or in the Mixer instance itself in order to get a good mixer when calling getMixer(Mixer.info info).

I had this problem a couple of years back and ended up blacklisting the audio device for the camera in ALSA.  Only seemed to be a problem if the camera was plugged in at boot for me.

The other logical solution (though I haven't tried it) would be to iterate through the available mixers using getMaxLines() or getSourceLineInfo() to find one that's actually capable of output.  I would have thought the webcam only reports inputs?

I actually considered using the single SourceDataLine method in my SoundSystem, but eventually gave up on the idea as it requires a single audio format for the output, which would require me to convert all data loaded or streamed into that format and then passed to a mixing algorithm.  This seemed way to complicated at the time, but I may have to revisit it as a possibility.  I'd probably write a separate Library plug-in rather than changing the one I wrote already.  It would fix another issue where there is no "Java Sound Mixer" available on some Java versions, such as the OpenJDK..

Having done a variety of audio programming in Java, I'd recommend this approach for lowest latency.  It also gets around the issue that the direct mixers aren't guaranteed to support mixing!  This is why on Linux Pulpcore can only play one sound at a time, for instance.

If it's of interest, I've got some code up at http://code.google.com/p/java-audio-utils/ under the Audio Servers section which uses this approach and a couple of other tricks to give stable low latency audio with JavaSound.  On my Linux box I'm getting sub-20ms easily.  The code's GPL at the moment, but once I've finished the next release of Praxis (which I'm using it for), the intention is for this to be GPL w/CPE.

Best wishes,

Neil

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline gouessej
« Reply #7 - Posted 2010-07-20 13:13:33 »

I had this problem a couple of years back and ended up blacklisting the audio device for the camera in ALSA. 
How do you blacklist the audio device?

Only seemed to be a problem if the camera was plugged in at boot for me.
It is exactly the same for me.

The other logical solution (though I haven't tried it) would be to iterate through the available mixers using getMaxLines() or getSourceLineInfo() to find one that's actually capable of output.  I would have thought the webcam only reports inputs?
It works. I do such things in the alpha version of TUER, not in the pre-beta version. I used some criteria to find the best mixer for my purposes. Maybe Paul could plan to add a mechanism (some methods in the API or a constructor in paulscode.sound.SoundSystem that would have a parameter) to choose a mixer related on some criteria :
1  
2  
3  
4  
5  
6  
7  
8  
9  
enum SoundUsage {IN,OUT,BOTH,NONE};

public SoundSystem(java.lang.Class libraryClass,SoundUsage usage){
...
switch(usage){
...
//find the mixer that fits the purposes
}
}


Having done a variety of audio programming in Java, I'd recommend this approach for lowest latency.  It also gets around the issue that the direct mixers aren't guaranteed to support mixing!  This is why on Linux Pulpcore can only play one sound at a time, for instance.

If it's of interest, I've got some code up at http://code.google.com/p/java-audio-utils/ under the Audio Servers section which uses this approach and a couple of other tricks to give stable low latency audio with JavaSound.  On my Linux box I'm getting sub-20ms easily.  The code's GPL at the moment, but once I've finished the next release of Praxis (which I'm using it for), the intention is for this to be GPL w/CPE.

Best wishes,

Neil
Do you think it would be difficult to mix it with what Paul has done in his library?

Offline nsigma
« Reply #8 - Posted 2010-07-20 13:32:39 »

How do you blacklist the audio device?

I think it's a bit distribution dependent.  On Mint (and therefore Ubuntu I presume) it's under /etc/modprobe.d  There's a blacklist file where you can just add the sound module for the webcam.  Or, there's also the possibility of controlling the index that ALSA gives it in the main alsa-base.conf file.  This stops it getting index=0, so it won't be the first one picked up by JS.

Do you think it would be difficult to mix it with what Paul has done in his library?

No idea.  Not looked at Paul's code.  I've tried to design my code to be as simple as possible to work with - you just implement an AudioClient interface that takes FloatBuffers.  Or, just hack the code in JavasoundAudioServer to give you the byte buffers directly.  My code gives you floats because they're much easier to work with for software mixing and effects, and also because other sound implementations (there's a Jack server too) give you floats to start with.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #9 - Posted 2010-07-20 14:18:55 »

On my view, maybe it is possible to detect the "bad" mixer that matches with my webcam by looking into Mixer.Info instances returned by getMixerInfo or in the Mixer instance itself in order to get a good mixer when calling getMixer(Mixer.info info).
The one that it uses now is whatever Mixer is labeled "Java Sound Mixer".  In my opinion, this should always be the sound card by default, but apparently Sun/Oracle disagrees.  I would personally consider this a bug..

Maybe Paul could plan to add a mechanism (some methods in the API or a constructor in paulscode.sound.SoundSystem that would have a parameter) to choose a mixer related on some criteria :
1  
2  
3  
4  
5  
6  
7  
8  
9  
enum SoundUsage {IN,OUT,BOTH,NONE};

public SoundSystem(java.lang.Class libraryClass,SoundUsage usage){
...
switch(usage){
...
//find the mixer that fits the purposes
}
}
I'm not sure about this particular setup, but testing to see if I have both input and output on the default Mixer (whatever is labeled "Java Sound Mixer" by the Java Sound API) is a good idea.  If not, then I can iterate through all other available Mixer's to find one that does (which would most likely be the sound card, right?  Or can you think of a situation where it wouldn't be?)  I'll give this a shot to see if it works as a quick-fix.  I still want to do a diagnostic applet first to make sure what we're talking about is the actual problem, although I'm pretty sure it is.  I'll add in some more messages to show the input and output capabilities of each mixer as well (the more information the better).  I may have time this evening to do a little programming (my schedule has really been crazy and doesn't seem to be settling down any time soon).

Do you think it would be difficult to mix it with what Paul has done in his library?
I do not intend to use this particular code (I seriously despise the GPL and avoid it whenever possible), but it might be worthwhile to look at it and others just to see how other programmers have solved the problem.  I'll write my own code for format conversion and mixing, though, if I eventually go this route.

I can't because I don't use several audio files with the same format.
That's the main thing holding me back at the moment.  I'd need to take whatever format (sample rate, sample size, etc) the user hands to the SoundSystem and write a method for converting it into a single output format for mixing.  I'm sure others have done this, so I just need to do some more research.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline nsigma
« Reply #10 - Posted 2010-07-20 15:08:20 »

The one that it uses now is whatever Mixer is labeled "Java Sound Mixer".  In my opinion, this should always be the sound card by default, but apparently Sun/Oracle disagrees.  I would personally consider this a bug..
This isn't the mixer to pick if you want low latency, btw, and I'm not sure it's the default on Windows.  It is the only one that's meant to guarantee software mixing outputs, though.  If it's got no outputs then that definitely sounds like a bug.  Are you sure your code is definitely not picking mixer[0] by mistake?  In my case with a webcam it would show up as the first mixer, but not as the JavaSound Mixer.

I do not intend to use this particular code (I seriously despise the GPL and avoid it whenever possible), but it might be worthwhile to look at it and others just to see how other programmers have solved the problem.  I'll write my own code for format conversion and mixing, though, if I eventually go this route.
That's the main thing holding me back at the moment.  I'd need to take whatever format (sample rate, sample size, etc) the user hands to the SoundSystem and write a method for converting it into a single output format for mixing.  I'm sure others have done this, so I just need to do some more research.

Well, the GPL suits my needs well, so Praxis as a whole is staying GPL, but my intention is to open up any useful libraries that come out of it a bit more liberally.  The AudioServers stuff should be GPL with Classpath Exception - I'm using some format conversion stuff from OpenJDK, and as the licence fitted I didn't see the point in rewriting.

If CPE is still not open enough, then it should be easy enough to reuse the principles - pretty simple stuff.  The actual low-latency stuff in the Javasound AudioServer is a mix and match inspired by various approaches from various blog posts and mailing lists.  Don't have the links to hand atm, but Google should be your friend!  Wink  Particularly try looking around projects such as Frinika, Toot and RasmusDSP.

Hope that's a help.

Praxis LIVE - open-source intermedia toolkit and live interactive visual editor
Digital Prisoners - interactive spaces and projections
Offline princec

JGO Kernel


Medals: 342
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #11 - Posted 2010-07-20 15:34:32 »

(Does OpenAL work as expected?)

Cas Smiley

Offline gouessej
« Reply #12 - Posted 2010-07-20 15:54:17 »

(Does OpenAL work as expected?)

Cas Smiley
Software OpenAL support works better but JOAL is almost no more maintained and I don't want to use LWJGL, sorry. Using Paul's library is quite simple, it is an excellent library and it allows me to concentrate on other aspects than audio... Paul seems to know better than me the bugs and limitations of Java Sound.

Paul, are you sure the first mixer called Java Sound Mixer has something to do with the webcam? I thought you pick the first mixer that matches with the first Mixer.Info returned by getMixerInfo(), I should have a look at your source code anew.

I suggested mixing nsigma source code with yours in order to avoid duplicating the efforts. A source code using GPL with Classpath exception can be legally mixed with your source code using your license, can't it?

Personally, I use GPL v2 for political and legal reasons but I understand that people here have their own constraints and then use other licenses.

Offline princec

JGO Kernel


Medals: 342
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #13 - Posted 2010-07-20 17:10:58 »

Hm, still pathologically resisting something that works?

Cas Smiley

Offline gouessej
« Reply #14 - Posted 2010-07-20 19:53:01 »

Hm, still pathologically resisting something that works?

Cas Smiley
No. I only try to minimize the use of third party libraries that rely on native code.

Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #15 - Posted 2010-07-21 01:30:38 »

Paul, are you sure the first mixer called Java Sound Mixer has something to do with the webcam?
I checked the code to make sure.  It is possible to define your own Mixer, but by default I am definitely searching for it by name (actually the name is "Java Sound Audio Engine" not "Java Sound Mixer".. typo on my part).  The relevant code can be found in the LibraryJavaSound.init() method:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
        // Check if there is a mixer set yet:
        if( myMixer == null )
        {
            // No real "loading" for the JavaSound library, just grab the Mixer:
            for( Mixer.Info mixerInfo : AudioSystem.getMixerInfo() )
            {
                if( mixerInfo.getName().equals( "Java Sound Audio Engine" ) )
                {
                    // found it!
                    myMixer = AudioSystem.getMixer( mixerInfo );
                    break;
                }
            }
        }

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 74
Projects: 15


★★★★★


« Reply #16 - Posted 2010-07-21 10:32:26 »

(Does OpenAL work as expected?)

Cas Smiley

OpenAL-Soft (especially the new version bundled with LWJGL 2.5) has probably the best sound support you can get on Linux.

It supports multiple backends ALSA, OSS, DirectSound, Solaris, PortAudio, PulseAudio, and a .wav writer.

Java Sounds is currently very poor compared to the above.

I don't want to use LWJGL, sorry.

You can continue using JOGL and just use the OpenAL part of LWJGL if you like (it should work, not tried it).

No. I only try to minimize the use of third party libraries that rely on native code.
Well if your already using JOGL an extra native for sound shouldn't really be a problem.
Offline gouessej
« Reply #17 - Posted 2010-07-21 11:22:14 »

OpenAL-Soft (especially the new version bundled with LWJGL 2.5) has probably the best sound support you can get on Linux.

It supports multiple backends ALSA, OSS, DirectSound, Solaris, PortAudio, PulseAudio, and a .wav writer.

Java Sounds is currently very poor compared to the above.

You can continue using JOGL and just use the OpenAL part of LWJGL if you like (it should work, not tried it).
Well if your already using JOGL an extra native for sound shouldn't really be a problem.
What do I have to change in a JNLP file to load OpenAL-Soft?

I will try to address the issue with Java Sound as OpenAL-Soft is not available on Mac.

Is it possible that several instances of Mixer are called "Java Sound Audio Engine"? I will perform a test tonight.

Edit.: Paul was right, Java Sound Audio Engine tries to use the camera. This seems to work around the bug but may cause some regressions depending on the audio format:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
try{soundSystem=new SoundSystem(LibraryJavaSound.class);
            //if a f**king camera is used as an audio device
           if(LibraryJavaSound.getMixer().getTargetLineInfo().length==0)
                {for(Mixer.Info info:infos)
                     if(!info.getName().contains("Camera"))
                         {Mixer mixer=AudioSystem.getMixer(info);
                         if(mixer.getTargetLineInfo().length>0)
                             {LibraryJavaSound.setMixer(mixer);
                             break;
                             }
                         }
                }
            SoundSystemConfig.setCodec("ogg",CodecJOrbis.class);
           }
        catch(SoundSystemException sse)
        {System.out.println("The initialization of the sound manager failed: "+sse);}

Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #18 - Posted 2010-07-21 23:37:51 »

Sweet, thanks for solving this for me.  I'll put this fix in and have my beta testers try it out to make sure it doesn't break any legacy code (although looking at it, it shouldn't - it should only be different if the default Mixer doesn't have output lines, in which case the previous method wouldn't work anyway).  It'll be included in the upcoming release, which I'm hoping to post in a week or two after some beta testing (there are quite a few significant changes, such as playback events, a new position-check interface, and methods for Doppler effect).

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #19 - Posted 2010-07-22 00:28:34 »

Sweet, thanks for solving this for me.  I'll put this fix in and have my beta testers try it out to make sure it doesn't break any legacy code (although looking at it, it shouldn't - it should only be different if the default Mixer doesn't have output lines, in which case the previous method wouldn't work anyway).  It'll be included in the upcoming release, which I'm hoping to post in a week or two after some beta testing (there are quite a few significant changes, such as playback events, a new position-check interface, and methods for Doppler effect).
On my view, my fix is a bad fix. A good fix would consist in modifying the mixer providers so that your own is called at first and the second part of the fix should force the Java Sound Audio Engine to work with the sound card rather than the webcam. We should write a bug report or a request for enhancement because this behavior is not acceptable. Keep in mind that many people use a webcam nowadays.

Moreover, a better fix should compute and associate a "score" to each mixer and pick the best one rather than taking one valid mixer almost randomly.

Maybe the best fix would consist in blacklisting the camera(s) temporarily and very early at runtime but I'm not sure it is possible and if it is, it will be a privileged action.

Would it be really problematic to use several mixers in LibraryJavaSound instead of a single one?

Offline ruben01

Senior Member


Medals: 4
Projects: 3



« Reply #20 - Posted 2010-07-22 05:36:34 »

Hi Paul just a quick question, what happened with the changes to indirect buffers in lwjgl 2.3?

2.3

    * new: Removed support for indirect buffers as arguments to AL/GL functions

does the new version works with the newer versions of lwjgl?

rubén

Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #21 - Posted 2010-07-22 06:27:50 »

On my view, my fix is a bad fix. A good fix would consist in modifying the mixer providers so that your own is called at first and the second part of the fix should force the Java Sound Audio Engine to work with the sound card rather than the webcam.
My thought was to use what you have as a second step to check after locating the Java Sound Audio Engine mixer if it turned out to have no target lines.  This would almost never happen (you are the first to report this problem in fact), so for everyone else the code would still select the Java Sound Audio Engine as before.

Moreover, a better fix should compute and associate a "score" to each mixer and pick the best one rather than taking one valid mixer almost randomly.
That's a good idea -- after trying Java Sound Audio Engine first, it would be nice to chose the second option with some degree of intelligence.  What parameters should go into determining such a score, though?  Certainly the ability to use target lines first.  I'll check if there are other things to test for like compatibility with pitch/pan/gain controls, etc.

Would it be really problematic to use several mixers in LibraryJavaSound instead of a single one?
What would be the purpose of more than one mixer at a time?  Or do you mean something else?

does the new version works with the newer versions of lwjgl?
Yes it does.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #22 - Posted 2010-07-22 13:18:34 »

My thought was to use what you have as a second step to check after locating the Java Sound Audio Engine mixer if it turned out to have no target lines.  This would almost never happen (you are the first to report this problem in fact), so for everyone else the code would still select the Java Sound Audio Engine as before.
As far as I know, it is reproducible only with Linux if the webcam is plugged before booting. It would be fine if you could confirm that "my" fix is useless with Windows and a webcam.

That's a good idea -- after trying Java Sound Audio Engine first, it would be nice to chose the second option with some degree of intelligence.  What parameters should go into determining such a score, though?  Certainly the ability to use target lines first.  I'll check if there are other things to test for like compatibility with pitch/pan/gain controls, etc.
Maybe a cleaner solution would consist in calling getTargetLineInfo, checking if any Line.Info is an instance of Port.Info and then checking if there is at least one valid target port. I will check it at home later.

What would be the purpose of more than one mixer at a time?  Or do you mean something else?
It would be fine for the programmer not to have to choose manually the mixer when an audio format is not supported by Java Sound Audio Engine but it is supported by any direct audio device. Moreover, it is easier to associate a "score" to a mixer when you know which audio format you have to support.

Do you know JASS?
http://www.cs.ubc.ca/~kvdoel/jass/

Personally I will investigate a bit more and it is highly probable that I will write a bug report.

Edit.: my "fix" is not correct because the Java Sound Audio Engine has no target line info even though it works fine. I have to find something else.

Offline gouessej
« Reply #23 - Posted 2010-07-26 14:36:05 »

Maybe we should give a look at this :
http://quentinc.net/java/soundapi.php

Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #24 - Posted 2010-07-27 02:01:26 »

Maybe we should give a look at this :
http://quentinc.net/java/soundapi.php
Looks like basically the same thing I've done with SoundSystem + LibraryJavaSound plug-in + various Codec plug-ins.  Obviously I'm not the only programmer out there who has written a pure-java alternative for 3D sound..  Feel free to give it a shot and let me know how well it works.  I don't think I would use it personally, just because it is licensed by LGPL (better than GPL but still designed by total control freaks IMHO).

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #25 - Posted 2010-07-27 13:18:38 »

Looks like basically the same thing I've done with SoundSystem + LibraryJavaSound plug-in + various Codec plug-ins.  Obviously I'm not the only programmer out there who has written a pure-java alternative for 3D sound..  Feel free to give it a shot and let me know how well it works.  I don't think I would use it personally, just because it is licensed by LGPL (better than GPL but still designed by total control freaks IMHO).
You're right, I'm a bit disappointed, it does less than your APIs, it has nothing to do with the license. Someone advised me to give it a try, I did.

I have to write another fix for my problem and a bug report concerning JSAE using the microphone instead of my sound card.

Offline gouessej
« Reply #26 - Posted 2010-07-28 22:02:21 »

The fix is there:
http://www.java-gaming.org/topics/tuer-truly-unusual-experience-of-revolution-fps-using-jogl/16094/msg/187961/view.html#msg187961

Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #27 - Posted 2010-07-29 00:52:12 »

Hi!

I have to fix an annoying bug in the sound system, then I will end the implementation of the optimization and maybe start using Netbeans RCP in JFPSM.

If someone knows where I can find a nice model of animated cop, let me know.

Edit.: the bug fix is below:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
try{soundSystem=new SoundSystem(LibraryJavaSound.class);
           /**
            * workaround for a known bug: when the first available mixer is
            * the direct audio device of the embedded microphone of a camera
            * on Linux, Java Sound Audio Engine tries to use it instead of using
            * the sound card. The bug fix consists in avoiding the use of JSAE in
            * this case.
            * */

           if(System.getProperty("os.name").contains("linux")||System.getProperty("os.name").contains("Linux"))
               {Mixer.Info[] infos=AudioSystem.getMixerInfo();
                if(infos.length>0 && infos[0].getName().contains("Camera"))
                    {Mixer mixer;
                    for(int i=1;i<infos.length;i++)
                        {mixer=AudioSystem.getMixer(infos[i]);
                        if(!infos[i].getName().contains("Camera")&&!infos[i].getName().equals("Java Sound Audio Engine"))
                            {LibraryJavaSound.setMixer(mixer);
                            break;
                            }
                        }
                     }
               }
            SoundSystemConfig.setCodec("ogg",CodecJOrbis.class);
           }
        catch(SoundSystemException sse)
        {System.out.println("The initialization of the sound manager failed: "+sse);}

http://tuer.svn.sourceforge.net/viewvc/tuer/pre_beta/engine/SoundManager.java?r1=224&r2=242

This looks to be based on a major logic error to me.  The first bit of logic seems correct - if the webcam is the first Mixer.Info in the list, it is probably also the device referred to by "Java Sound Audio Engine" (seems to be the case based on the Java Sound bug).  However, it seems to me that your fix would arbitrarily chose the first Mixer that doesn't have the words "Camera" or "Java Sound Audio Engine" in the name.  While this may work for your test machines, I suspect there are system configurations out there on which this fix would not work.  Consider the following hypothetical device list:

1  
2  
3  
4  
Cool Web Camera
Java Sound Audio Engine
USB Microphone
Intel ICHx AC97 Soundcard


Wouldn't it be better to chose the first device for which mixer.getTargetLineInfo().length>0?  Like so:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
    if( infos.length>0 && infos[0].getName().contains( "Camera" ) )
    {
        Mixer mixer;
        for( int i=1; i<infos.length; i++ )
        {
            mixer=AudioSystem.getMixer( infos[i] );
            if( !infos[i].getName().contains( "Camera" ) && !infos[i].getName().equals( "Java Sound Audio Engine" )
                && mixer.getTargetLineInfo().length>0 )
            {
                LibraryJavaSound.setMixer(mixer);
                break;
             }
         }
    }
...


For that matter, couldn't the if statement get rid of the name checks and use only the TargetLineInfo length check?  Or was there a reason you changed to this method?

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Offline gouessej
« Reply #28 - Posted 2010-07-29 12:50:40 »

This looks to be based on a major logic error to me.  The first bit of logic seems correct - if the webcam is the first Mixer.Info in the list, it is probably also the device referred to by "Java Sound Audio Engine" (seems to be the case based on the Java Sound bug).  However, it seems to me that your fix would arbitrarily chose the first Mixer that doesn't have the words "Camera" or "Java Sound Audio Engine" in the name.  While this may work for your test machines, I suspect there are system configurations out there on which this fix would not work.  Consider the following hypothetical device list:

1  
2  
3  
4  
Cool Web Camera
Java Sound Audio Engine
USB Microphone
Intel ICHx AC97 Soundcard


Wouldn't it be better to chose the first device for which mixer.getTargetLineInfo().length>0?  Like so:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
    if( infos.length>0 && infos[0].getName().contains( "Camera" ) )
    {
        Mixer mixer;
        for( int i=1; i<infos.length; i++ )
        {
            mixer=AudioSystem.getMixer( infos[i] );
            if( !infos[i].getName().contains( "Camera" ) && !infos[i].getName().equals( "Java Sound Audio Engine" )
                && mixer.getTargetLineInfo().length>0 )
            {
                LibraryJavaSound.setMixer(mixer);
                break;
             }
         }
    }
...


For that matter, couldn't the if statement get rid of the name checks and use only the TargetLineInfo length check?  Or was there a reason you changed to this method?
mixer.getTargetLineInfo() returns 0 even though Java Sound Audio Engine is able to work correctly. The second version of the fix uses JSAE when possible and uses another mixer only when JSAE would not work correctly whereas the first version of the fix always skips JSAE even in cases we could rely on it. You're right, I might implement a stronger test to choose a better mixer.

Offline paulscode

Senior Member


Medals: 11


Staff Sergeant


« Reply #29 - Posted 2010-07-29 13:12:51 »

mixer.getTargetLineInfo() returns 0 even though Java Sound Audio Engine is able to work correctly. The second version of the fix uses JSAE when possible and uses another mixer only when JSAE would not work correctly whereas the first version of the fix always skips JSAE even in cases we could rely on it.
Ah, I see.

You're right, I might implement a stronger test to choose a better mixer.
I'm thinking the best solution will be to try and create a SourceDataLine for each chosen Mixer, and check for compatibility based on static parameters that the user can change to fit their needs (things like range of sample-rates, required controls, etc).  If none of the available Mixers are able to meet those parameters, the thrown SoundSystemException should indicate what the specific problem was.  I'll start working on this concept when I get home this evening, and when its implemented, maybe I can have you beta-test it for me to make sure it works in your particular case.

We love death.  The US loves life.  That is the difference between us.  -Osama bin Laden, mass murderer
Pages: [1] 2
  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.

pw (26 views)
2014-07-24 01:59:36

Riven (25 views)
2014-07-23 21:16:32

Riven (19 views)
2014-07-23 21:07:15

Riven (22 views)
2014-07-23 20:56:16

ctomni231 (51 views)
2014-07-18 06:55:21

Zero Volt (46 views)
2014-07-17 23:47:54

danieldean (37 views)
2014-07-17 23:41:23

MustardPeter (40 views)
2014-07-16 23:30:00

Cero (56 views)
2014-07-16 00:42:17

Riven (55 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!