Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Slick2d SOUND problem.  (Read 3835 times)
0 Members and 1 Guest are viewing this topic.
Offline SkyAphid
« Posted 2012-04-03 01:08:23 »

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 Smiley

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Offline Cero
« Reply #1 - Posted 2012-04-03 01:33:33 »

try mono sound files

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

Offline SkyAphid
« Reply #2 - Posted 2012-04-03 01:51:33 »

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.

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Longarmx
« Reply #3 - Posted 2012-04-03 05:12:30 »

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.

Offline SkyAphid
« Reply #4 - Posted 2012-04-03 05:38:22 »

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

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Offline davedes
« Reply #5 - Posted 2012-04-03 05:57:21 »

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.
Huh? If volume adjustment isn't working at all for you, how do you plan to add a volume slider to your game? Huh

Try the following test class out with your own sound files.
Press 1, 2 and 3 to play back at different volumes.
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  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
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
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.

Offline SkyAphid
« Reply #6 - Posted 2012-04-03 06:34:46 »

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.

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Offline davedes
« Reply #7 - Posted 2012-04-03 06:46:45 »

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

Offline Cero
« Reply #8 - Posted 2012-04-03 19:05:42 »

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.

.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

Offline SkyAphid
« Reply #9 - Posted 2012-04-04 01:04:11 »

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

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.

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davedes
« Reply #10 - Posted 2012-04-04 01:40:13 »

Quote
Yes, but how do you know it's the singleton that's broken? The volume one worked anyway.
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.  Huh

Offline SkyAphid
« Reply #11 - Posted 2012-04-04 03:06:09 »

Quote
Yes, but how do you know it's the singleton that's broken? The volume one worked anyway.
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.  Huh

The singleton is referenced in the method...something in the method may not be triggering it. :I

“Life is pretty simple: You do some stuff. Most fails. Some works. You do more of what works. If it works big, others quickly copy it. Then you do something else. The trick is the doing something else.” ~Leonardo da Vinci
Pages: [1]
  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.

rwatson462 (30 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (42 views)
2014-12-09 22:41:13

BurntPizza (76 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (51 views)
2014-12-03 16:27:13

CopyableCougar4 (49 views)
2014-11-29 21:32:03

toopeicgaming1999 (115 views)
2014-11-26 15:22:04

toopeicgaming1999 (105 views)
2014-11-26 15:20:36

toopeicgaming1999 (31 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
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!