Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Calin Leafshade on Sun 11/10/2009 22:59:21

Title: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Sun 11/10/2009 22:59:21
I use a simple PlaySound() command when changing from certain rooms (the sound of a door opening)

And it seems that on my laptop the sound stutters and plays twice. Im fairly sure it didnt do it on my desktop but i have a sound blaster audigy in that.. Is this a problem for cards with smaller buffers? I.e onboard stuff.. and if so how can i fix it?
Title: Re: Sound Buffer/Sound Stuttering
Post by: Gilbert on Mon 12/10/2009 02:23:06
Hmmm. Did you play the sound and change the room immediately afterwards?
It may be because of the loading of the new room that causes the stuttering in slower systems.
Try to Wait() for a few frames after playing the sound and see if that fixes anything in the laptop.
Title: Re: Sound Buffer/Sound Stuttering
Post by: GarageGothic on Mon 12/10/2009 03:15:04
What format are your sounds effects saved in? OGG files seem to produce less stuttering than MP3 files in my experience. Also, you can try to increase the amount of memory available for the game under Advanced Settings in winsetup.exe.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Mon 12/10/2009 03:53:15
Yes the sound file is played immediately before room change.
Using Wait() does help but only if i wait for the entire sound file to be played.. and since its about a second and a half i'd rather not delay the player to that extent.

My files are all in OGG format since i favour an open format if possible and i think the memory allowance is only for the sprite cache isnt it? so it shouldnt really help but i'll give it a go.

From a processor perspective there is no reason why it shouldnt handle it. Its a 2.4ghz core 2 duo laptop which is actually the same as the desktop. The only thing that i think may cause problems is the onboard sound chip.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Gilbert on Mon 12/10/2009 04:25:57
Actually apart from sound card latency, there're several things that may (i.e. I'm not sure of it) affect the performance, like access speed of the harddrive and the graphic card (right, since during room changes the whole screen is redrawn and we all know that laptops often come with limited onboard chips; you may also try setting up your game for DX5 if it's currently using D3D9 or vice versa and see if that makes a difference).
Title: Re: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Mon 12/10/2009 05:33:40
Graphics card is an Nvidia 6800. I very much doubt thats the cause.. and the game is already running in Dx5 due to the snow/rain plugin.

Harddrive access time is a possibility. Is there any way to cache sound files in advanced? Since this sound file is use very often it would be a good candidate for caching.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Pumaman on Wed 14/10/2009 21:54:22
This is most likely due to the room not loading quickly enough to update the sound card buffer, what resolution are your rooms?
Title: Re: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Wed 14/10/2009 22:09:38
320x200
Title: Re: Sound Buffer/Sound Stuttering
Post by: Pumaman on Wed 14/10/2009 22:13:01
Hmm, that shouldn't cause a problem. Which screen transition are you using?
Title: Re: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Wed 14/10/2009 22:15:19
FadeOutFadeIn
Title: Re: Sound Buffer/Sound Stuttering
Post by: Pumaman on Wed 14/10/2009 22:17:11
Ok thanks, I'll see if I can reproduce any problems with this.
Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Thu 01/04/2010 10:11:00
Sorry for bringing up this old thread, but I'm getting sound stutters at 640x400 with the same problem.  And this on a quad core q8200 with a gtx 275 :(
Title: Re: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Thu 01/04/2010 10:55:20
It's still a problem as far as I'm aware.

I'm convinced its an issue with the way AGS deals with sound card buffers since performance of the computer seems to be irrelevant but the sound card is vital.

for example, mccarthy stutters on my 2.4ghz dual core laptop with a nvidia 6800 graphics card but doesnt stutter on a 2ghz desktop with onboard graphics with a sound blaster audigy.

The laptop out performs the desktop on everything except the sound card.
Title: Re: Sound Buffer/Sound Stuttering
Post by: AGD2 on Thu 01/04/2010 11:11:42
This happens to me also during room changes, but only with the DX5 driver. The Direct3D one works fine.  I have an Nvidia GTX 295 video card and an Intel Core i7 920 CPU.

Seems like it could have something to do with DX5 being slower to draw graphics to the screen, while simultaneously being compounded by the process of the room loading.
Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Thu 01/04/2010 12:13:59
Actually my game runs in DX9 by default, but I resolved the issue.  I use the hardware mixer and it completely removes the problem.  Interesting hey :)
Title: Re: Sound Buffer/Sound Stuttering
Post by: Pumaman on Fri 02/04/2010 16:27:27
Interesting. You shouldn't be getting problems like this, but if we can find a game that reliably reproduces the problem on several computers, I can investigate it and try to find a solution.
Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Mon 05/04/2010 07:58:22
Hey CJ, do you want me to PM you a url of the game I'm working on so you can see the stutters?
Title: Re: Sound Buffer/Sound Stuttering
Post by: Pumaman on Mon 05/04/2010 22:19:33
If the stutters are reliably reproducable, that would be useful yes please.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Mon 05/04/2010 22:23:17
McCarthy also regularly stutters (i.e every room change) on my laptop or any PC with a cheapo sound card if thats helpful

Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Mon 05/04/2010 22:43:33
I'd have to agree with Calin on that one also, McCarthy stutters for me during room changes, where my game stutters in a room occasionally.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Ryan Timothy B on Tue 06/04/2010 01:13:14
Me as well.  McCarthy stutters during each room change on my 1.6GHz Quad Core laptop with what I imagine has onboard sound.
Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Tue 06/04/2010 01:27:39
Hi CJ, I sent you a PM with the url but I accidently sent it as (no subject).  Just thought I'd let you know.
Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Fri 09/04/2010 07:20:31
Hi Chris just wondering if you got PM okay to test it out.  I did some interesting testing actually, under the latest development version of Wine for Linux I loaded the game up and there no stutters at all.  Is it something to do with DirectSound at all?  

As I had to choose WaveOut for the sound to play correctly on Linux due to Wine's incompatibility.  I might actually try WaveOut when I get home on my Windows machine.

EDIT: Back at home I figured out that the lower the resolution the less stuttering.  For example in McCarthy if you run it at 320x200 there is no stuttering at all.  Also Quest For Glory II Remake from AGD also stutters constantly.  Is this a Windows 7 thing I wonder.

2ND EDIT:  Well I tried my personal game on my girlfriends computer which is an AMD64 3800+/Win 7/Onboard Sound and it works fine.  My PC is a Q8200 with an Auzentech Prelude X-Fi.  My theory is that it could well and be how the game interacts with the drivers.  I know that the X-Fi drivers aren't the best which is a damn shame.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Pumaman on Sun 11/04/2010 19:33:35
Yes I got your PM, thanks -- I haven't had a chance to test it out yet.
It must be sound driver-related if this problem only happens on some PC's, I'll see if I can reproduce it.
Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Mon 12/04/2010 05:16:26
Cheers, tell me if you need help testing it.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Mehrdad on Mon 12/04/2010 15:32:38
I had  this problem too for "The Marionette "game(640*480- true color(dont remember good)).I have laptop 1.60 pentium IV -256 ram-64 memory graphic card.
Title: Re: Sound Buffer/Sound Stuttering
Post by: uswin on Thu 15/04/2010 08:05:06
Hi guys, i've faced the same problem before,
but it is solved now after i use .WAV sound files instead of reguler mp3 or ogg.

i don't know why .wav files worked and other format stutter.
Title: Re: Sound Buffer/Sound Stuttering
Post by: Calin Leafshade on Thu 15/04/2010 22:24:26
the other files require decoding before they can be played.

PCM wavs are essentially the raw sample data so it doesnt need decoding in any real sense.

I shouldve made the door sound in mccarthy a wav... nevermind..
Title: Re: Sound Buffer/Sound Stuttering
Post by: xenogia on Fri 16/04/2010 00:15:09
Realistically you could only use WAVS for small sound effects otherwise the game would be ridiculous in size.