Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
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) not enough sound channels  (Read 1281 times)
0 Members and 1 Guest are viewing this topic.
Offline DrewLols

Senior Devvie

Medals: 3
Projects: 1

Noob going through metamorphosis...

« Posted 2012-08-21 23:59:40 »

Apparently, Slick2D's sound class dynamically allocated sounds to channels.  When a channel is not available, the sound is not played.  The problem is, in a few cases, when I play one sound and then quickly try to play another sound, the second sound occasionally doesn't play.  I'm guessing that for whatever reason, there wasn't a channel to allocate the second sound to.  Is there any way to guarantee that sounds will play when using the Slick2D library?

Did you know that 90% of statistics are wrong?
Offline davedes
« Reply #1 - Posted 2012-08-22 00:19:17 »

How many sound sources is Slick initialized with on your system? It should print in the log. Slick tries to initialize 64 by default (which should be enough -- that many sounds simultaneously will probably sound like garbage, anyways).

I wonder if there is a bug in your code or in Slick's audio classes that is causing them to stop. It's unlikely that all your sources are playing at the exact same time, unless your system severely limits the max number of sources.

If you really do find that your game/application demands more simultaneous sounds, you pretty much have three options:

1. Request more sources -- you can set the max sources in Slick and re-init. This is likely the worst solution, since most computers max out at 64 or 32 sources, and you can't really expect your average user's sound card to do any better than that.

2. Mix all sources in software -- you are limited only by how much data you can mix without latency. This requires a fair amount of knowledge, although maybe TinySound (which is a software mixer) will be a good starting point.

3. Manage your sources based on priority, distance, and other attributes. For example, a speech dialog will not be interrupted by a subtle bird chirping in the distance (and the user won't notice if a gunshot interrupts a subtle bird chirp).

A while back (when I was first learning OpenAL) I wrote a simple extension for Slick which does just this. You specify what "layer" a sound would be (for e.g. SPEECH_LAYER, AMBIENT_LAYER, EFFECTS_LAYER) so that less important sounds will never cut off more important sounds. There is also some other controls (e.g. distance from player) that can affect a sound's priority. It was never really completed, and pretty messy compared to how I would do things these days.
Soundly - Sound Manager for Slick

Personally (if you actually need this feature) I'd recommend rolling your own audio manager -- it will teach you a lot about OpenAL and start getting you more comfortable with audio programming. Only, I wouldn't use Slick or its decoders as a base... Tongue

Offline DrewLols

Senior Devvie

Medals: 3
Projects: 1

Noob going through metamorphosis...

« Reply #2 - Posted 2012-08-22 00:45:10 »

Yeah, have exactly zero experience with openal.  Anyway, I found where the problem is.  I set it up so a particular sound won't play unless it is not already playing.  For instance, I would write:


Problem is, whenever ANY sound plays, smashSound.playing() returns true...  Go figure...  Eh, I guess I can figure out a way to fix this without checking to see if a sound is playing.  It's just a little inconvenient.  I'll just work around it.  Thanks a bunch, though!

Did you know that 90% of statistics are wrong?
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Coldstream24 (19 views)
2015-09-03 00:41:28

Andrew_3ds (31 views)
2015-09-01 19:08:10

afikri (20 views)
2015-08-31 09:30:22

afikri (27 views)
2015-08-31 09:30:07

afikri (15 views)
2015-08-31 09:27:24

afikri (17 views)
2015-08-31 09:26:40

Roquen (32 views)
2015-08-29 11:30:54

GamerC4 (41 views)
2015-08-22 20:38:50

GamerC4 (37 views)
2015-08-22 20:37:18

GamerC4 (43 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30 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‑
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!