Slick2d SOUND problem.

So, I’ve had problems with things in Slick simply not working before, so this wouldn’t be the first time. I hope I’m just not doing it right though.

Anyway, I’m trying to change the volume of a sound that’s playing, but nothing I do affects the sound, I’ve only had the pitch mess up.

I’ve tried
sound.play(1.0f, 0.5f) to lower the volume, nothing.

then,

sound.play(1, 50), still absolutely nothing. Not even an error.

Neither worked or affected anything. The bottom one lower the pitch dramatically though.

Please, someone enlighten me. I need to lower the volume, as the sound for selecting things is ear-piercing otherwise :slight_smile:

try mono sound files

at least for the 3D sound features, the sounds have to be mono

My sounds are in .wav, it should be working right. I don’t need them to be in 3D either.

Have you tried to use sound.playAsSoundEffect(pitch, volume gain per loop, loop Boolean);?
But I guess this wouldn’t affect you if you weren’t playing this more than once.

I may just put a bandaid on it by adding a volume pane on the configuration menu…nothing else is working.

Values for the ‘volume’ parameter should be between 0.0 (silent) and 1.0 (full volume, i.e. no change).
(This also applies to the game container & sound store setSoundVolume and setMusicVolume methods)

[quote]I may just put a bandaid on it by adding a volume pane on the configuration menu…nothing else is working.
[/quote]
Huh? If volume adjustment isn’t working at all for you, how do you plan to add a volume slider to your game? ???

Try the following test class out with your own sound files.
Press 1, 2 and 3 to play back at different volumes.

import org.newdawn.slick.AppGameContainer;
import org.newdawn.slick.BasicGame;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Input;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Sound;

public class SoundTest2 extends BasicGame {
	public static void main(String[] args) throws SlickException {
		new AppGameContainer(new SoundTest2(), 800, 600, false).start();
	}
	
	public SoundTest2() { 
		super("TestClass");
	}
	
	Sound sound;
	
	public void init(GameContainer c) throws SlickException {
		sound = new Sound("res/speech.ogg");
	}
	
	public void render(GameContainer c, Graphics g) throws SlickException {
		
	}
	
	public void update(GameContainer c, int delta) throws SlickException {
		if (c.getInput().isKeyPressed(Input.KEY_1)) {
			sound.stop();
			sound.play(1f, 1f);
		} else if (c.getInput().isKeyPressed(Input.KEY_2)) {
			sound.stop();
			sound.play(1f, 0.5f);
		} else if (c.getInput().isKeyPressed(Input.KEY_3)) {
			sound.stop();
			sound.play(1f, 0.1f);
		}
	}
}

[quote]I’m trying to change the volume of a sound that’s playing
[/quote]
Slick doesn’t support changing the volume of a Sound as it is playing (although that should be easy to implement). But by your original post it doesn’t seem like that’s what you’re trying to do.

For one, I’ve done all of that for debugging, it didn’t change or I wouldn’t be on here asking about it. Thanks anyway though.

Secondly, that one method isn’t working, it by no means suggests the rest of the methods related to volume is broken.

Thirdly, I’m not changing the sound as it is playing, but before it’s played.

Thank you anyway for your time, though.

[quote]For one, I’ve done all of that for debugging, it didn’t change or I wouldn’t be on here asking about it.
[/quote]
Did you actually run my test?

If the test did not produce different playback volumes then it seems possible the problem lies in your OpenAL drivers or a bug with LWJGL.

[quote]Secondly, that one method isn’t working, it by no means suggests the rest of the methods related to volume is broken.
[/quote]
Like I asked earlier – how are you planning to add the volume panel? Does this mean you are having success with a particular method?

All Sound.play methods point to a central method in the SoundStore singleton. i.e. If that method doesn’t work, then the rest won’t either.

.wav can be stereo or mono
when using 3D position infos on sounds which are stereo, they will not do anything
might be the same here. just double check if they are mono and not stereo

then we can look at it again

Did you actually run my test?

If the test did not produce different playback volumes then it seems possible the problem lies in your OpenAL drivers or a bug with LWJGL.

[quote]Secondly, that one method isn’t working, it by no means suggests the rest of the methods related to volume is broken.
[/quote]
Like I asked earlier – how are you planning to add the volume panel? Does this mean you are having success with a particular method?

All Sound.play methods point to a central method in the SoundStore singleton. i.e. If that method doesn’t work, then the rest won’t either.
[/quote]
Yes, but how do you know it’s the singleton that’s broken? The volume one worked anyway.

Anyway, Cero, I’ll look into that, thank you. I’ll edit this post when I figure it out, or post a new one depending on if anyone else has advice.

[quote]Yes, but how do you know it’s the singleton that’s broken? The volume one worked anyway.
[/quote]
The singleton is the only place that changes the volume of a Sound source. Now you are saying that volume works?

I’m not really sure what your problem is anymore, since you’re being pretty vague about it. ???

The singleton is the only place that changes the volume of a Sound source. Now you are saying that volume works?

I’m not really sure what your problem is anymore, since you’re being pretty vague about it. ???
[/quote]
The singleton is referenced in the method…something in the method may not be triggering it. :I