Sound quality (Primary buffer?)

General area for talk about ZSNES. The best place to ask for related questions as well as troubleshooting.

Moderator: ZSNES Mods

Post Reply
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Sound quality (Primary buffer?)

Post by Baldho »

Hi!

I use the latest Windows WIP of ZSnes on my system.

I can hear a "shhhhhhh" noise in games when it plays sounds and musique. The noise goes away when i check "Use primary buffer" but then there is a big lag between the game and the sound. I know Primary Buffer allows a big buffer, and this causes the lag.

I got that noise with 3 different ISA sound cards:

SoundBlaster 16
SoundBlaster 16 Value
AOpen Crystal AW35/37

I would have to double check but I think I don't have this noise in the DOS version.

Here are my System specs:
Celeron 300
128 Mb SDRAM
Windows 98
DirectX 8.1
Latest drivers for the sound card
Some kind of Intel Mother Board i think

Thank you!
The pouiller the better
Truth Unknown
Regular
Posts: 271
Joined: Tue Jun 14, 2005 8:35 pm

Post by Truth Unknown »

What are all the settings you have in the Sound Menu?
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

Exactly why are you using an ISA sound card?
grinvader
ZSNES Shake Shake Prinny
Posts: 5632
Joined: Wed Jul 28, 2004 4:15 pm
Location: PAL50, dood !

Post by grinvader »

If you don't have any interpolation, enable gaussian.
Before a game is loaded.
皆黙って俺について来い!!

Code: Select all

<jmr> bsnes has the most accurate wiki page but it takes forever to load (or something)
Pantheon: Gideon Zhi | CaitSith2 | Nach | kode54
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

Sound Config:
Sound enable, stereo, 32000, gaussian. I read the docs and used what's closer to the real snes. But I tried various configs but the only option that changes something is "Primary buffer"

Why ISA:
Because the only PCI Sound Card I have is already used ;)
And they are easier to get working under pure DOS (if needed)

Interpolation:
Using interpolation, whichever, doesn't help.
The pouiller the better
Agozer
16-bit Corpse | Nyoron~
Posts: 3534
Joined: Sun Aug 01, 2004 7:14 pm
Location: Nokia Land

Post by Agozer »

Do you have this problem in earlier builds?
whicker: franpa is grammatically correct, and he still gets ripped on?
sweener2001: Grammatically correct this one time? sure. every other time? no. does that give him a right? not really.
Image
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Have you tried enabling "Sound Buffering" (both with and w/o the Primary Buffer option checked)?

One thing.. have you made sure the line-in and the microphone volume are muted?

Sometimes hissing sounds come when line-in/microphone is not muted.
Aerdan
Winter Knight
Posts: 467
Joined: Mon Aug 16, 2004 10:16 pm
Contact:

Post by Aerdan »

Best solution evar:

Buy a PCI sound card.

They are cheap.

Very cheap.

Go buy one.

Now.
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

I'll try different versions when i have some time, thanks!

Tried with both sound buffering on and off. And the hissing is not steady. It gets louder as the game sounds get louder. As if it was of poor quality, like, 8 bits or something.

Haha, and if it doesn't work i'll buy a new PC, and a new life too cause life sucks with poor sound in ZSnes :P :) Seriously, if everything else fails, i'll try with my SB128.

Oh, and could it be a setting in the BIOS?
The pouiller the better
MonkeyforaHead
Rookie
Posts: 16
Joined: Thu Sep 09, 2004 11:46 pm
Location: location, location
Contact:

Post by MonkeyforaHead »

Strange. I had this problem when first trying Zsnes in XP, though it had worked perfectly in 98SE previously. Increasing the sample rate seemed to make it worse, too. I think what fixed it for me was setting the lowpass to hi quality.

But then, I also have a PCI sound card, so...
For great justice.
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

I tried with the oldest ZSnes version on the official site (1.20) and I got the same hissing sound, even with large sound buffer and interpolation settings.

I tried with Snes9X. I don't have the hissing sound in it.
The pouiller the better
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

When creating a primary buffer, applications must set the dwBufferBytes member to zero. DirectSound will determine the best buffer size for the particular sound device in use. To determine the size of a created primary buffer, call IDirectSoundBuffer8::GetCaps.
If i looked far enough in the sources, I see that ZSnes just uses the buffer size that DirectSound establishes.

Code: Select all

lpPrimaryBuffer->GetCaps(&dsbcaps);
SoundBufferSize=dsbcaps.dwBufferBytes;
While it sets it when using a SecondaryBuffer:

Code: Select all

dsbd.dwBufferBytes = UsePrimaryBuffer ? 0 : SoundBufferSize;
Is it possible to actually set the buffer size when using a primary buffer?

EDIT:
You cannot specify the size of the primary buffer, and you must accept the returned size after the buffer is created. A primary buffer is typically very small, so if your application writes directly to this kind of buffer, it must write blocks of data at short intervals to prevent the previously written data from being replayed.
Duh... Found the answer somewhere else on the same site. Hail MSDN.

I think I understand... It's not the DirectSoundBuffer size, but zsnes's that is big so there's no gap in the sound.

If i'm right, It would be nice to be able to set the size of the "big buffer" in the GUI or in the config file, so we could fine tune it.

And talking about gaps, "to prevent the previously written data from being replayed." When there is silence in the game, the last written data keeps on playing in loop. :)

EDIT:
The looping sound when there's silence in a game happens when not using primary buffer. So there are 2 annoyance at the same time...
Last edited by Baldho on Fri Oct 28, 2005 4:36 am, edited 1 time in total.
The pouiller the better
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

I think we're getting away from the problem here.

The size of your DirectSound buffer should have little to do with the problem you described.

The size of the direct sound buffer simply dictates how often you need to write to(and how much data you can write to it) it to fill it up and prevent repeat.

I would recommend NOT using the primary DirectSound buffer. This seems to be a programming recommendation by many sources including MS. I can't remember which part of the documentation it's in though. The 'normal' way of doing things is to use secondary buffers and let DirectSound and your Sound card drivers control the primary buffer.

Assuming you use a large enough buffer and keep perfect track of things, you can seamlessly fill the buffer while it is playing while keeping sync and not adding any static or noise.
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

Nah, the size of the buffer doesn't fix the problem but using the primary buffer does...

The problem with primary buffer in ZSnes is that the sound lags to the game. I may be way wrong here, but i think it's zsnes' way to handle the primary buffer's small size. I haven't scatered the whole sources to figure that out yet.
The pouiller the better
Nightcrawler
Romhacking God
Posts: 922
Joined: Wed Jul 28, 2004 11:27 pm
Contact:

Post by Nightcrawler »

Why is this options present to begin with? It shouldn't be necessary as far as I know. Yes, I know it fixes the problem... but WHY? I don't have the time to take a good look at the code to see the differences.

Something is obviously not quite right. Can we at least assume that the actual ZSNES software sound bufer which is fed to DirectSound is always correct regardless of primary or secondary buffer use?

It would be helpful if we could determine where the problem occurs.
[url=http://transcorp.romhacking.net]TransCorp[/url] - Home of the Dual Orb 2, Cho Mahou Tairyku Wozz, and Emerald Dragon SFC/SNES translations.
[url=http://www.romhacking.net]ROMhacking.net[/url] - The central hub of the ROM hacking community.
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

Something is obviously not quite right. Can we at least assume that the actual ZSNES software sound bufer which is fed to DirectSound is always correct regardless of primary or secondary buffer use?
How can we tell... Nonetheless, I agree my own particular problem does not reside there and SecondaryBuffer should always be used.

I'm confused about if the problem is ZSnes related or not, because the hissing sound does not happen when using Snes9X.

It does not happen on my other computer running XP and a SB128, DX9. (The sound crackles on this one but it's another story...)

So in a nutshell:
Problem: Hissing noise, as if the sound was 8 Bit quality, and looping.
When: When not using primary buffer, regardless of the options used.

There's a version (DOS i think) that allows to set the sound to 8 Bit sample. I'll do some tests with it and compare.
The pouiller the better
Bahamut_ZERO_Clue

Post by Bahamut_ZERO_Clue »

Not to smack on your Sound card as it not only is a good one and will work properly but it might be a driver issue and not related to ZSnes in any way.

I own a PCI512/Live 4.1 card. It requires I use the PCI 512 drivers by default and by all accounts it should but thankfully I was able to use Audigy2 drivers to run it. I will tell you the PCI512 drivers that were last released were crap and the current Audigy2 drivers are far better in quality of audio.

By all accounts those sound card are no longer officially supported by Creative and minimal function drivers are provided by Microsoft for newer NT based opeerating systems like 2k/XP/2k3. My solution for you would be to do one of the following so listen carefully:

A) If you have Windows 98 Second Edition, you have WDM driver capabiltity. Go out and find yourself a cheep SB Live/Audigy or other newer sound card for the PCI slots.

B) Go to Creative's website and search under the Windows 2000 drivers, yes I know you have 98 but these are WDM drivers and if you have 98SE you can use them though it's not totally recommended and your DOS audio may no longer operate.

C) Think about investing in newer hardware even to ay a new PC altogether, and using an updated OS like 2k or XP. Good PC configurations for even a Pentium 3 and Athlon now run dirt cheep and you can easily nowadays build a good system of 1GHZ or better for way under 1000 dollars that is way better supported not only by Microsoft but the hardware manufacturers.
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

Like I said I tried with three different sound cards: 2 from creative and one from uhm... AOpen Crystal.

I'll try to find out a WDM driver for one of those three.

I'll try to keep things as cheap as possible as we are talking about a dedicated nes/snes machine plugged on my TV :)
The pouiller the better
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

Creative's website...
http://www.creative.com

Most of the time.. the default drivers that come with Windows has basic acceleration (that's what your SB16 falls into).. you definately want to download the drivers from Creative to get the most you can get.
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

I get the same "shhhhhhhh" noise under the DOS version, and no difference wether the "force 8 bit sound" is on or not.

Oh and it doesn't happend when playing a WAV file in windows (neither in Snes9X like I said earlier).

Edit:
Just one question... Can we assume, considering the noise happens even in Pure DOS, that it's not a Windows driver issue?
The pouiller the better
Baldho
Rookie
Posts: 43
Joined: Sat Feb 19, 2005 7:25 pm
Contact:

Post by Baldho »

Changed some settings in the BIOS and nothing changed.

I did some tests with my SB128 PCI. I took no chance and I downloaded the latest driver from creative's website.

No more hissing noise! But, I can hear some slight crackling, whatever the sound config.

I first thought it could just be that way. But I put my AW37 back in, enabled Primary buffer and the sound was flawless.

I also get that crackling sound with that sound card on my Athlon 1.3 GHz WinXP.

So, I get the best sound quality, and I would even say perfect, using my ISA soundcards and enabling Primary Buffer.
The pouiller the better
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

I thought about this further..

http://support.microsoft.com/?kbid=242937

I've had this problem before.. where I got static from ZSNES when I installed WDM based audio drivers on Windows 98SE (WDM drivers don't use .vxd(s))... I'm thinking that it is related to this:
M$ Article wrote:Calling the Multimedia API Programs that use PCI Audio Wave devices in full-duplex mode may elicit a system memory leak of 64 bytes each time an audio stream is created, or its properties are programmatically examined.
This leak seemed to cause static when I had a PCI sound card...

Try it and see if the situation changes...
Just one question... Can we assume, considering the noise happens even in Pure DOS, that it's not a Windows driver issue?
It probably isn't a Windows issue if you hear it in pure DOS.. but it does sound like something is enabled in the background (possibly controllable from DOS sound card driver controls)
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
franpa
Gecko snack
Posts: 2374
Joined: Sun Aug 21, 2005 11:06 am
Location: Australia, QLD
Contact:

Post by franpa »

when i had wdm drivers for windows 98se my pc's performance droped by approx 50% - 70% (so i stuck with vxd drivers) but now i have a new pc with winxp and wdm works fine

the crackling you speak of might be to do with not having cd audio muted or the microphone muted (or both)

my old pc was a p2 400mhz geforce 4 mx 4000 128mb (yes i know that vc sucks but amazingly the lates winxp drivers fixed most major issues with it (i think it flashed my vc) the sound card was a sb128 4channel and boy did it kick butt to some other cards i tested.

i tryed a soundblaster live value soundcard but it crippld my pc by 85% - 98% (because it only had wdm drivers and i think my pci slots were the wrong revision because looking at the manual i think it stated revision 2.3 pci slot reccomended but will run on pci 2.1 this requirement was not listed on the box itself)
Post Reply