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.