Sound crackling using vsync and DirectSound on Snes9x v1.52

If you're having problems with Snes9x, or think you've found a bug, this is the place to be.
Post Reply
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Sound crackling using vsync and DirectSound on Snes9x v1.52

Post by twipley »

Hello. Windows XP SP3, here. Using dedicated sound card. NVIDIA. I am suffering from the same problem as the following (unfound!) thread:

http://webcache.googleusercontent.com/s ... dba5077495

The problem is using both vsync and DirectSound under any fullscreen mode, the sound suffers from intermittent crackles (think Rice Krispies), which happen about once every 5 to 10 secconds.

Is anyone else suffering from the same issue on the latest revision (fix4)?

EDIT: fine-tuned the Google-cache link as esthetically necessary.
Last edited by twipley on Tue Mar 01, 2011 2:28 pm, edited 1 time in total.
User avatar
OV2
Official Win32 Porter/Dev
Posts: 679
Joined: Thu Aug 30, 2007 10:15 pm

Post by OV2 »

Did you try adjusting the input rate slider?
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Post by twipley »

The problem pretty much in my case goes away lowering from the default 31900 to a custom value of 31800.

But, as mentioned in the linked-to thread, such a workaround seems to affect the pitch, albeit not that much.

Do you think there would be any other workarounds that users like me suffering of that problem could try? The refresh rate here is pretty standard -- 60 Hz -- so it makes me wonder what the causes might be.

Also, am I right (or naive) to believe that enabling triple buffering under Snes9x (contrary to ZSNES) does nothing if vsync is not enabled in the first place?

And if ever the only workaround not featuring a necessity to fiddle with the default input rate would be to wait for a fix, I could very ably await until the problem gets fixed in a potential later version of the software. But first, the cause of the problem should be found. At least, I know I am not alone suffering from that issue. Picks my own curiosity up, at the very least!

If there is any info I could have mentioned concerning the problem but did not do so, just tell me and it will be a pleasure for me to contribute some related input.
User avatar
OV2
Official Win32 Porter/Dev
Posts: 679
Joined: Thu Aug 30, 2007 10:15 pm

Post by OV2 »

You could try Ver Greeneye's frequency test program, it should tell you an accurate input rate number for your monitor. Also disable triple buffering, it's not really useful with the new sound code.

Did you enabled sound sync? Any particular reason why you aren't using XAudio2?
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Post by twipley »

Hello. The program reported:

-refresh rate: 59.77 Hz;
-sample rate: 48 kHz;
-input frequency: over 31,850 Hz.

"Triple buffering [...] is not really useful with the new sound code" -- how so? I thought that affected the display only... oh, maybe because of the sync you are referring to...

Yes, sound sync is enabled. Default options are used, except, vsync, fullscreen, and the sound driver. The reason why Directsound is selected is it is my wish to distribute the configuration file I am using so that various people can benefit from it -- knowing that many people do not have the latest DirectX distribution installed -- but, alas, I have stumbled on this strange sound-choppiness issue.

For now it's either choppy audio, or choppy video (through vsync disabling).

Do you think it would be advisable to switch to one of the three FMOD Ex sound drivers? If so, which one? It seems the sound issue which is the subject of this thread evaporates using those ones. Note that it is my wish to simulate as close as possible the behavior of a real SNES.

Thank you.

EDIT: it seems the problem is still present using FMOD Ex instead of DirectSound as the sound driver.
Last edited by twipley on Mon Feb 28, 2011 4:00 am, edited 1 time in total.
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

FMOD modes tend to have more bugs than XAudio2 or DirectSound and doesn't sound nearly as clean IMHO. Change the sampling frequency to 31850Hz instead of 32000, as you will notice a reduction in crackling (it doesn't reduce the quality of the sound as it's impossible to tell a difference of 150Hz). Update the sound drivers for Windows XP and make sure there aren't any resource hogging programs running in the background.
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Post by twipley »

I have discovered that unticking "emulate fullscreen" helps a little bit (does not solve the problem, though).
the_randomizer wrote:FMOD modes tend to have more bugs than XAudio2 or DirectSound and doesn't sound nearly as clean IMHO.
Good to know.
the_randomizer wrote:Update the sound drivers for Windows XP and make sure there aren't any resource hogging programs running in the background.
Already done. The machine I am using is a quite powerful one too, with the exception of the graphics card, i.e., a GeForce 7300 LE (note that the other-thread original poster had listed a similar card to mine).
the_randomizer wrote:Change the sampling frequency to 31850Hz instead of 32000, as you will notice a reduction in crackling (it doesn't reduce the quality of the sound as it's impossible to tell a difference of 150Hz).
Well, that too is sure good to know.

However, the central problem lies in the fact that my motivation is greatly residing in the quest of building a universal configuration file, that could be sent to friends of mine, and which could be used to launch Snes9x with adequate settings.

If 31,800 Hz makes it out for me, will it do so for everybody? I am feeling somewhat as if on sloppy grounds, here.
the_randomizer
Snes9x Orange Belt
Posts: 222
Joined: Sat Oct 17, 2009 4:18 am

Post by the_randomizer »

Also make sure that the buffer length is somewhere between 128ms to 160ms or so.
Lisa: "I hope you all know you're sponsoring a murderous pirate!"
Sponsor: "A pirate!!? Well, that's hardly the image we need for Long John Silvers!"
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Post by twipley »

Changing the buffer length unfortunately does not seem to help.

At worse, I'll see what I can do with bsnes later on today.

EDIT: absolute same thing happens with bsnes. To prevent video choppiness, I enable "video sync," but in any case it makes the audio become choppy. Input-frequency modification helps there, as in Snes9x, but that just makes the audio sound not like it is supposed to sound.
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Post by twipley »

Sorry for the bump.

Some might be interested in the reason why I am leaving ZSNES. That's because some games I like to promote seem incompatible with it.

For example: http://board.zsnes.com/phpBB3/viewtopic.php?f=3&t=14273

(ZSNES is the only emulator I've found that allowed me to enable vsync (or video sync) without introducing serious flaws in the audio.)

EDIT: even the latest stable ZSNES SVN suffers from the Little Magic issue, sadly. v1.51 quick hack fix, anyone?
Last edited by twipley on Mon Feb 28, 2011 8:36 pm, edited 1 time in total.
SparroHawc
Official Android Porter
Posts: 303
Joined: Mon Feb 07, 2011 9:20 pm
Location: All up in your business

Post by SparroHawc »

If you're just looking to put together an adequate config, I'd suggest turning vsync off. That'll eliminate issues with different monitors' refresh rates throwing the sound off, although there will be the possibility of some screen tearing.

Would it be possible to tweak the program so that it threads out the screen drawing, and have -that- thread be vsynced while the emulator just fills the back-buffer? It seems like that would be the best solution all-around. I know trying to fork on different OSes can be a pain, but ... it might be worth looking at.
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Post by twipley »

XAudio2 here produces the same issue than DirectSound, it turns out.
SparroHawc wrote:If you're just looking to put together an adequate config, I'd suggest turning vsync off. That'll eliminate issues with different monitors' refresh rates throwing the sound off, although there will be the possibility of some screen tearing.
That's the way the default config does it. Although the tearing can barely be stood. Great sound, though -- even on DirectSound.
SparroHawc wrote:Would it be possible to tweak the program so that it threads out the screen drawing, and have -that- thread be vsynced while the emulator just fills the back-buffer?
User avatar
OV2
Official Win32 Porter/Dev
Posts: 679
Joined: Thu Aug 30, 2007 10:15 pm

Post by OV2 »

If you enable vsync then you will always have to adjust the input rate to compensate the fact that no monitor exactly achieves the SNES' refresh rate. You'll never get one setting that works for all users (if there were then it would be the default and you would not even see the input rate slider).

Your monitor runs at 57.77 Hz, which is why you need a rather low input frequency. Mine runs at 60.02 Hz, so I can actually run at 32000 if I run it in FS with vsync enabled.
twipley
Snes9x White Belt
Posts: 10
Joined: Sun Feb 27, 2011 4:53 pm

Post by twipley »

Okay, I think I am getting it.

You have summed it up nicely.

In short, short of having (inaccurate) workarounds such as is the case in ZSNES, one would have to follow byuu's advice:
byuu wrote:Please take a few minutes to adequately configure the emulation so as for it to be made compatible with the visual display unit device that is being used:

when audio is crackling periodically, try moving the value to the left;
when video is lagging, jumping or tearing, try moving the value to the right.
Thanks for the clarifications.
kjalshdfg
Snes9x White Belt
Posts: 1
Joined: Tue Mar 10, 2015 1:02 am

Re: Sound crackling using vsync and DirectSound on Snes9x v1

Post by kjalshdfg »

Hey guys, just came here to say thank you, turning off vsync in menu>Video>DisplayConfiguration but unchecking the box "VSync",

SOLVED IT for me.

I got the stuttering when pushing to full screen, or when minimizing at times. Disabling the vsync solved it for me.
Post Reply