Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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 3207 times)
0 Members and 1 Guest are viewing this topic.
Offline MisterBob

Senior Newbie

Developing: 2D Space Shooter & RPG

« Posted 2003-09-27 16: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 Devvie

Medals: 4

« Reply #1 - Posted 2003-09-29 07: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. :-)
Offline mdicosimo

Innocent Bystander

Java games rock!

« Reply #2 - Posted 2003-11-10 11: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.

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

Junior Devvie

Java games rock!

« Reply #3 - Posted 2004-05-01 06: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 -
Offline oNyx

JGO Coder

Medals: 2

pixels! :x

« Reply #4 - Posted 2004-05-01 06: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  

DesertCoockie (22 views)
2018-05-13 18:23:11

nelsongames (73 views)
2018-04-24 18:15:36

nelsongames (68 views)
2018-04-24 18:14:32

ivj94 (751 views)
2018-03-24 14:47:39

ivj94 (81 views)
2018-03-24 14:46:31

ivj94 (605 views)
2018-03-24 14:43:53

Solater (97 views)
2018-03-17 05:04:08

nelsongames (170 views)
2018-03-05 17:56:34

Gornova (388 views)
2018-03-02 22:15:33

buddyBro (1048 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!