Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
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  
  Sound "Lag"  (Read 1444 times)
0 Members and 1 Guest are viewing this topic.
Offline MisterBob

Senior Newbie




Developing: 2D Space Shooter & RPG


« Posted 2003-09-27 18:23:39 »

If I attempt to play 2 of the same sound around the same time (For example, if mario jumps through a large group of coins in a game), it causes some serious lag.

If you need an example of this, check out my platformer in the games section...

Is there any way to fix this? Or is it beyound the capabilities of JavaSound?

Offline Preston

Senior Member


Medals: 2



« Reply #1 - Posted 2003-09-29 09:30:05 »

I've got a similar effect, however just until one sound is played for the very first time. When it plays the first time there's a lag. Whenever the same sample is being played again no lag is noticeable.
So far I can live with this "very first time" lag. :-)

Memento mori.
Offline mdicosimo

JGO Visitor



Java games rock!


« Reply #2 - Posted 2003-11-10 12:03:20 »

Hi everybody,
I'm beginning my experience with Java and I'm stuck with the same problem in repetition of sounds.

Have found any solution since?

I tried the following but I had no success:

1) I created two versions of the same clip  bang.wav (bang1.wav and bang2.wav) and loaded them in clipBang1 and clipBang2 via two different lines

2) Every time a bullet is fired, I stop() the last played clip, set its frame position to 0 and start() the other clip.

Max
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline z.e.r.o

Junior Member




Java games rock!


« Reply #3 - Posted 2004-05-01 08:09:25 »

Well, if you're using Clip you're already using different lines for every Clip (and it's a very bad implementation for sounds in a game).

A better method is to cache sounds in a byte array and use it to play them, instead of using streaming directly from disk.

Precaching sound is better becaure the other way you will always have lag, since your HD will have to fetch the file and play it. Usually sound FX (even if WAV) are really small (a bunch of KB), so you can have even hundreds of them in memory without reaching even a MB of RAM spent...

Matteo Anelli
.brain - http://www.dot-brain.com
Offline oNyx

JGO Coder


Medals: 1


pixels! :x


« Reply #4 - Posted 2004-05-01 08:24:26 »

Well, there are two Clips. The usual one and the crappy ones from Applet. The usual ones are ok and play instantly (they are stored in ram as pcm), but you can get a slight delay at the first time you play one of them. As far as I can tell, it's because there isn't a mixer around and java needs to create a default mixer first.

弾幕 ☆ @mahonnaiseblog
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (88 views)
2013-05-17 21:29:12

alaslipknot (96 views)
2013-05-16 21:24:48

gouessej (128 views)
2013-05-16 00:53:38

gouessej (123 views)
2013-05-16 00:17:58

theagentd (131 views)
2013-05-15 15:01:13

theagentd (119 views)
2013-05-15 15:00:54

StreetDoggy (161 views)
2013-05-14 15:56:26

kutucuk (184 views)
2013-05-12 17:10:36

kutucuk (185 views)
2013-05-12 15:36:09

UnluckyDevil (191 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
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!
Page created in 0.088 seconds with 20 queries.