Do you have any experience with converting stereo to mono, I've read that it gives you two half-volume tracks. I guess this is just a natural side effect of how the wav was initially designed.

I actually got everything to work just fine. Is a No-attenuation (ambient) sample required to have a stereo track? I tried playing my death sound as an ambient sound at position 0,0,0 attenuation_none, but it would still be position-based for some reason. When I made the track stereo, it worked.

I believe for OpenAL that ambient sounds should be stereo (I'd have to verify that). Alternately you can position them wherever the listener is at (which can be problematic if the listener moves). I'll have to look at the code for LibraryJavaSound (I thought I was checking for ATTENUATION_NONE, and not panning in that case, but it's been a while since I looked at that part of the code)

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

Question though. I like how I can name my BGM source, and then fade it out. My question though. I have a bunch of Scene objects that are the different "states" the game can be in (main menu, map editor, game), and we want them to have different background music. Scenes have an "entered" and a "exited" method, and currently it looks like this (example shown is gamescene)

This results in a clipping though when we start the new Game.sound.background music in the main menu (using a different source name. The disadvantage though is that if we were to use Game.sound.fadeOutIn() in sceneExited, we'd have to know the scene we are switching to (probably a useful feature we'll eventually have anyway). But for now, is there a way you know of that we'd be able to fade IN the background music source, short of some weird hack?

One option, with your current setup, could be to start up a temporary thread from new scene's sceneEntered() method, which checks if the music source is still playing (from a while loop, with say 30ms sleep in each iteration in order not to peg the CPU). When you leave the previous scene in sceneExited(), do a fadeOut like you have now. Once the source is finished playing, the thread can do a fadeIn with the new music file, and then kill itself.

A more efficient way that might work if it can fit into your infrastructure, would be to do a fadeOutIn from the new scene's sceneEntered() method, rather than doing the fadeOut from the previous scene's sceneExited() method.

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

Something I noticed you haven't taken into consideration is OpenAL's AL_SOURCE_RELATIVE feature. A RELATIVE (as opposed to ABSOLUTE) source will always be positioned relative to the listener's position. So if your mono file is at <0,0,0> and you move your listener, as long as the source position is RELATIVE instead of ABSOLUTE, the sound will be played as if it were an ambient sound (i.e. with no 3D effects, since it's being played at the same spot as the listener). e.g. With default listener orientation, a relative source at <5,0,0> will always pan to the right speaker, even if the listener moves about.

In my own extension of your library I've done a little something like this for SourceLWJGLOpenAL:

To add the same functionality to SourceJavaSound, I adjusted the values used when calculating pan/pitch/gain based on whether isRelative() returns true.

I also extended your sound system with other features such as seeking and acquiring the length of a non-streamed sound, playing multiple sources simultaneously, etc. Soon I hope to include effects (reverb, lowpass, etc) and other goodies.

For ambient sources, most folks just use Stereo files and set attenuation to ATTENUATION_NONE. Your way works too though. When you finish, if you post your source code, I'll incorporate some of your work into the official library if you find it works well and has equivalents that work in both OpenAL and JavaSound.

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

I seem to be experiencing a bug with the SoundSystem.libraryCompatible() method.

If I call 'SoundSystem.libraryCompatible( LibraryJavaSound.class );' it always returns false. But 'sound = new SoundSystem( LibraryJavaSound.class );' instantiates without errors, and sound will play just fine.

Could you post the console output after calling 'SoundSystem.libraryCompatible( LibraryJavaSound.class );' to see what it says is wrong?

Also, could you run the following after doing it the other way 'sound = new SoundSystem( LibraryJavaSound.class );'

--EDIT-- Never mind, I figured out what the problem is. I never updated the libraryCompatible() method after I added the mixer profiling code. So it is still checking for the "Java Sound Audio Engine", which has been removed from recent versions of Java, so the method will always return false. I'll fix this at some point (in the mean time, just do it the way you are doing it)

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

The problem are not the ogg files, if I reverse the loop, the sounds that are the end of the list (that is, the first ones to be loaded) fail, and the rest (including the ones which failed before) load successfully.

Just a thought. Could this be a concurrency problem? For example: when there's a lot going on in a Constructor, and the code which makes the resource call executes before the Constructor is guaranteed to have completed.

What is the class referred to in the .getClass() part? Is it possible it hasn't finished instantiation?

/** * Constructor: Saves handles to the url and identifier. The identifier should * look like a filename, and it must have the correct extension so SoundSystem * knows what format to use for the file referenced by the URL instance. * @param url URL interface to a file. * @param identifier Identifier (filename) for the file. */publicFilenameURL( URLurl, Stringidentifier ) {// grab a handle to the message logger:logger = SoundSystemConfig.getLogger();

filename = identifier;this.url = url; }

/** * Constructor: Saves a handle to the filename (used later to generate a URL * instance). The file may either be located within the * JAR or at an online location. If the file is online, filename must begin * with "http://", since that is how SoundSystem recognizes URL names. * @param filename Name of the file. */publicFilenameURL( Stringfilename ) {// grab a handle to the message logger:logger = SoundSystemConfig.getLogger();

this.filename = filename;url = null; }

And then the getURL() method, where the resource is accessed, can only be called after it is instantiated, because both the instantiation and the call to getURL() are done in sequence on a single thread (I could post the relevant code trace to demonstrate, but it would get a bit long).

I'll try and recreate the problem so I can track down the cause. Teletubo, do you have a simple test-case that I could use? (does this happen any time you create lots of new sources in a loop? If so, how many?)

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

I have a small problem. I use an in-memory sound, I get its source name, I can play it only if it is not yet already played. This is problematic because it is a gun shot, the second bullet should start making some noise before the first one ends doing so. I don't want to create several sources for a single sound sample. How can I make it work? The only workaround I know consists in shortening sound samples to avoid overlaps but it is annoying and crappy, it won't be fine when an opponent shoots me while I shoot him. I use JOAL 1.1.3 and the codec for Ogg Vorbis. The sound sample is in mono, 48 Khz.

Thank you for your good library. Best regards.

Edit.: When I play different sounds at the same time, it works like a charm. The problem only occurs when I try to play the same sample.

I pre cache all the sounds in my game using SoundSystem.loadSound(String). I find that when loading .ogg files it takes several seconds to load each file, and the memory usage is huge (something like 100mb for each file). Is this some kindof bug in the JOrbis codec? Or can it be attributed to something else?

My .ogg sounds are only a few second long each. When i load comparable .wav files they load instantly and take up a small amount of memory. I'm not really a sound guy so i may be oblivious to something obvious. Tomorrow i'm going to take a closer look at my situation and try to provide more details.

I don't think the problem you are describing comes from JOrbis itself, as many people use it and rely on it. The one time I used it, it pretty much worked as advertised (didn't cause the problem you describe).

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