Sound very choppy in Windows Vista

Got a problem with OpenTTD? Find some help here.

Moderator: OpenTTD Developers

maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Post by maartena »

I can also confirm it works!! Sound is playing perfectly.

My aero interface is still taking about 25% CPU when playing openttd, but since I now have a dual core thats only a problem on slower machines I suppose. Not an issue here :)

Only thing is, that I can't play multiplayer with this version, because its different then the regular RC4. But single player works fine, and I can only hope this gets in the RC5 release.

On a side note, yes my server is down. Harddrive crash. Reinstalling now on a 120 Gb I stilll had.
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
edwardvdv
Engineer
Engineer
Posts: 6
Joined: 30 Dec 2006 09:04

Post by edwardvdv »

After playing the whole weekend, I can confirm what I suspected Friday: it works perfectly.

Thanks for the quick fix :) Now let's hope the patch'll be integrated in the final release.

(I updated the Flyspray entry @ http://bugs.openttd.org/task/489)
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Post by maartena »

I played a few single player games with it (got bored, no proper competition), and the sound works fine!

And on another side note, harddrive issue fixed, server back up.
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
Quark
Transport Coordinator
Transport Coordinator
Posts: 325
Joined: 20 Sep 2006 11:36
Location: Russia, Moscow

Post by Quark »

maartena wrote:My aero interface is still taking about 25% CPU when playing openttd, but since I now have a dual core thats only a problem on slower machines I suppose. Not an issue here :)
Maybe try SDL video driver?
Image
RvL
Engineer
Engineer
Posts: 5
Joined: 05 Feb 2007 23:28

Post by RvL »

Great work! Will there be DirectSound support in the coming 0.5 version?
Quinnyowns
Engineer
Engineer
Posts: 44
Joined: 25 Aug 2005 00:42
Location: Bedfordshire, England.
Contact:

Post by Quinnyowns »

Thank's greatly buddy :D

So far I've found the new Windows Vista experience beyond terrible :( This lightens my day a little :)
lols internets.
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3054
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

<< Just got back.

Interesting to read the DirectSound driver is working correctly. I have only been able to test the driver in a virtual windowsXP installation and it did consume more CPU power (for me) than the old waveout driver.

I will have a bit closer look at the driver to check for possible improvements and fixes. Cannot promise anything for 0.5.0 final.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3054
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Had some more work on the DirectSound driver, but still far from happy with it. As I have implemented it at the moment:
Set up n (in this case 8) (secondary) buffers and events. When a sound is played it is put into the buffer (pretty big buffers) and a notify event is set for the end of the sound (DirectSound has no concept of sound-ending, etc. just buffersize). When the event is fired I "free" the buffer for more sounds.
The events are checked every 300ms to see if they have finished.

Now the problem is that I don't like this approach. The buffers are way too big (each sound, as they aren't streamed) must fit and I'm continually checking events to see if a buffer was freed.

I don't like throwing out the buffers after the sound has played (memory fragmentation), but can't keep all sounds in memory either (80/90 samples?).

We could go the current way that OpenTTD itself mixes the sounds and streams them to the buffer. I've also tried this but didn't really work out (either very choppy sound and high CPU usage due to high buffer-streaming (small buffer-size) or lagging sounds (due to bigger buffer-size (1-2 second(s)).

If anyone has ideas or written DirectSound for games I'd like to hear.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
dannys9
Engineer
Engineer
Posts: 29
Joined: 23 Nov 2004 17:16
Location: Dassendorf, Germany

Post by dannys9 »

:idea:
Just found an easy fix! Start the game as follows:

openttd -s win32:bufsize=2048

This doubles the sound buffer size compared to the hard coded one. Works perfectly for me. :D
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3054
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

dannys9 wrote::idea:
Just found an easy fix! Start the game as follows:

openttd -s win32:bufsize=2048

This doubles the sound buffer size compared to the hard coded one. Works perfectly for me. :D
It's hardly hardcoded if you can change it through the command line ;). But nice find, might even be useful for vista people if this is confirmed.

A bigger bufsize does mean more lagged sounds, so don't increase this size too much.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
dannys9
Engineer
Engineer
Posts: 29
Joined: 23 Nov 2004 17:16
Location: Dassendorf, Germany

Post by dannys9 »

Darkvater wrote:It's hardly hardcoded if you can change it through the command line ;).
Well, it truly is, as a fallback in win32_s.cpp, line 61:

Code: Select all

_bufsize = GetDriverParamInt(parm, "bufsize", 1024);
                                              ----
The problem is, that passing options on the command line only seems to work with nightlies and svn versions. With 0.5.0-RC5 you can pass the parameters, but there will be no sound (at least, here). Maybe a wanted behaviour of debug and release versions?

I would increase the hardcoded fallback and submit a patch, but I can't get my MinGW to run properly :?
henrik
Engineer
Engineer
Posts: 19
Joined: 05 Mar 2005 12:53

Post by henrik »

I've done sound streaming with DSound before, without consuming any massive amounts of CPU or anything.

Here's my (very old) code:

http://www.dtek.chalmers.se/~tronic/dsound.rar

The coding style is a little bit messy but it has worked very well for me in the past, and exhibits no problems on Vista.

For a smooth CPU usage profile, DSound_Update() should be called once every frame or so.
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Post by maartena »

dannys9 wrote::idea:
Just found an easy fix! Start the game as follows:

openttd -s win32:bufsize=2048

This doubles the sound buffer size compared to the hard coded one. Works perfectly for me. :D
Wow.

This works :)

I haven't started playing yet, but I have started OpenTTD on Vista/Aero, and I hear no sound distortion.

I'm gonna play me a game now on RC5 :)
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Post by maartena »

Darkvater wrote:
dannys9 wrote::idea:
Just found an easy fix! Start the game as follows:

openttd -s win32:bufsize=2048

This doubles the sound buffer size compared to the hard coded one. Works perfectly for me. :D
It's hardly hardcoded if you can change it through the command line ;). But nice find, might even be useful for vista people if this is confirmed.

A bigger bufsize does mean more lagged sounds, so don't increase this size too much.
It does indeed slightly lag the sound. But still a nice find :)
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3054
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

henrik wrote:I've done sound streaming with DSound before, without consuming any massive amounts of CPU or anything.

Here's my (very old) code:

http://www.dtek.chalmers.se/~tronic/dsound.rar

For a smooth CPU usage profile, DSound_Update() should be called once every frame or so.
Thanks henrik. I've finished the dsound-driver though so will compare it with yours :)

About the hardcoded-guy: it is *NOT* hardcoded. It is a default if no value is passed. Every settings needs to have a default, that is not hardcoding. The setting won't work in 0.5-RC5 because the driver only has space for 16 chars, and '-s win32:bufsize=2048' is longer, so it'll be trunc'd :). (Will be) fixed for final release.

@henrik: I had a look at the code and it only uses a single buffer without support for multiple channels so we would have to use the OpenTTD mixer. I was curious about drivers using multiple buffers and sounds (streaming or static). Anyways I'll clean up my driver and post it here to see how you guys like it (if someone has programming experience). I am not even sure the code actually works as there is for example no primary buffer created, which is really a must.

I guess the high-priority is kinda off now that increasing the bufsize helps.
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
maartena
Route Supervisor
Route Supervisor
Posts: 470
Joined: 11 Jul 2003 04:53
Location: California, U.S.A.

Post by maartena »

Darkvater wrote:The setting won't work in 0.5-RC5 because the driver only has space for 16 chars, and '-s win32:bufsize=2048' is longer, so it'll be trunc'd :). (Will be) fixed for final release.
You are wrong. When I use that setting in 0.5-RC5, I have working sound in Vista, without it I do not.

So it does work :)
Guess what! I got a fever! And the only prescription...... is MORE COWBELL!
RvL
Engineer
Engineer
Posts: 5
Joined: 05 Feb 2007 23:28

Post by RvL »

I can confirm that the workaround works, though it sometimes gets choppy when there is a lot of sound (e.g. big stations)
User avatar
CMircea
Chairman
Chairman
Posts: 884
Joined: 29 Dec 2006 14:05

Post by CMircea »

So it does in XP for me, when there are a lot of sounds p laying at the same time.
User avatar
Darkvater
Tycoon
Tycoon
Posts: 3054
Joined: 24 Feb 2003 18:45
Location: Hong Kong

Post by Darkvater »

Current directsound driver diff, comments are welcome if someone has them :)
Attachments
dsound_v3.diff
(18.36 KiB) Downloaded 245 times
TrueLight: "Did you bother to read any of the replies, or you just pressed 'Reply' and started typing?"
<@[R-Dk]FoRbiDDeN> "HELP, this litte arrow thing keeps following my mouse, and I can't make it go away."
User avatar
flake
Engineer
Engineer
Posts: 64
Joined: 28 Apr 2004 10:07
Location: Salzburg
Contact:

Post by flake »

I use 0.5-RC5 under vista 64bit and "-s win32:bufsize=2048" works just fine, all the stuttering is gone.
Post Reply

Return to “OpenTTD Problems”

Who is online

Users browsing this forum: No registered users and 6 guests