3D Sound Engine

EDIT -

I am having some problems implementing this. I can’t seem to find any documentation on the problem I’m having, so hopefully someone can help.

Here’s my stack trace-

Starting up SoundSystem…
Initializing No Sound
(Silent Mode)

SoundSystem shutting down…
Caught InterruptedException while attempting to open the default MIDI sequencer. Trying again.
Error in class ‘MidiChannel’
Unable to load Midi file in method ‘setSequence’.
Error in class ‘MidiChannel’
Exception in method ‘play’
ERROR MESSAGE:
sequence not set
STACK TRACE:
com.sun.media.sound.RealTimeSequencer.start(Unknown Source)
paulscode.sound.MidiChannel.play(MidiChannel.java:650)
paulscode.sound.Library.play(Library.java:665)
paulscode.sound.SoundSystem.CommandPlay(SoundSystem.java:2076)
paulscode.sound.SoundSystem.CommandQueue(SoundSystem.java:2599)
paulscode.sound.CommandThread.run(CommandThread.java:121)
Author: Paul Lamb, www.paulscode.com

Here’s my sound class:

package com.natekramber.main;

import paulscode.sound.SoundSystem;

public class Sound extends SoundSystem {
	
	Main main;
	
	public Sound(Main main)
	{
		this.main = main;
		
		backgroundMusic("m", "snd/song.mid", true);
		cleanup();
	}
}

Seems fairly simple enough. I don’t know what could be causing it to do this.

Also, this happens no matter what I set the filepath to. I could set it to “oldcorn.poop” and the error doesn’t change.

p.s. Sometimes I don’t get an error, it just initialized then shuts down like this-

Starting up SoundSystem…
Initializing No Sound
(Silent Mode)

SoundSystem shutting down…
Author: Paul Lamb, www.paulscode.com

Thanks,
-Nathan

Look at the javadocs, i don’t think you should be calling “cleanup” after you start the music? :wink:

Ah you are correct. However, I still get that InterruptedException when I try to load it (see stack trace in previous post).

(Sorry if this is a simple error; this is my first foray into using sound :P)

-Nathan

Hi

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.

Hi

I should use loadSound() to load each sound once for all and quickPlay() because bullets are at different locations, I should not use the same source, that was my fault. Best regards.

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?

@msiggy:

How long are your sounds? A standard decompression is 44100 samples per second, and 4 bytes per sample. At that rate, RAM gets consumed pretty quickly.

That’s…let’s see…176,400 bytes per second…
10,584,000 bytes per minute…

So, are you trying to put about 9 to 10 minutes worth of sound and music into memory? If so, 100MB sounds about right.

Of course, if you leave the sound in Ogg format, it consumes a LOT more cpu to play the sounds back at game time.

My quickie rule of thumb is that each minute of SFX requires roughly 10MB of memory as PCM (16-bit encoding, stereo).

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.

That short? wav’s are fine? Hmmm.

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).

So, yes, more info.

Hey Paul,
I switched my computer and now I’m having a problem in which the sound plays only once. It won’t play more than the first time.

My old system was Windows XP, with Java 6. It worked fine.

New one is a Windows 7 with Java 7 and it’s where the problem occurs.

This is how I load a sound effect:


        mySoundSystem.newSource(true, fname, "sounds/"+fname,  false, 0, 0, 0, SoundSystemConfig.ATTENUATION_ROLLOFF,
            SoundSystemConfig.getDefaultRolloff());

and then, each time I play it:

 
        mySoundSystem.setPosition(fname, 0, 0, 0);
        mySoundSystem.play(fname); 

I tried the applet bug testing you posted on your forums, but nothing happened when I pressed 1-3 keys (although it worked perfectly on my old laptop).

Any clues ?

Teletubo, I assume you use JavaSound with this library. I don’t have this problem with the plugin based on JOAL 1.1.3. Maybe someone can suggest a solution allowing to keep the JavaSound plugin. Have you tried to create a new source each time or to change the position a very little bit each time you play your sound sample?

Hey, teletubo, sorry I have been busy with other projects lately and haven’t been on the forum here for some time. I tend to start too many projects to keep up with, and some end up taking a back burner for a while.

Anyway, this problem is caused by the fact that Oracle decided to remove the built-in Java Sound software mixer. At some point when I have time to finish my own mixer I started a while back, I’ll be able to fix the problem. If someone has already completed a similar project let me know, and I’ll look into creating a new plug-in to use it.

Okay, thanks paul. I think I’ll go for gouessej’s suggestion and use an OpenAL Plugin to be sure that it will always work.

I’m back with the same problem I was having before.

I have an .ogg file which is about 3k in size and 3 minutes in length. When I load this file with ‘soundSystem.loadSound(filename)’ It takes up a huge amount of memory ( 800mb) in my application. Whats weird is that if I don’t load it and just play it with soundSystem.backgroundMusic(), it takes up a normal amount of memory. This activity only seems to happen with certain .ogg files, some other ones I have work fine. It seems like there is something weird in the loadSound() method. Or perhaps my file has some funny attribute that isn’t playing nice. Let me know if you want a copy of the .ogg file and I will send it to you. I cant put a link here because the sound is proprietary.

Thanks Paul,
Mike

I don’t know if anyone can help me with this but I’m getting this output when I run an exported JAR, sound works when I run through Eclipse but not when I run through the JAR