Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
06199 Sound Minor Always May 3, 2016, 21:55 Oct 16, 2018, 23:24
Tester denzilla View Status Public Platform MAME (Official Binary)
Assigned To Calamity Resolution Fixed OS Windows Vista/7/8 (64-bit)
Status [?] Resolved Driver
Version 0.173 Fixed in Version 0.177 Build 64-bit
Fixed in Git Commit Github Pull Request #
Summary 06199: mspacman: Enabling -refreshspeed causes audio distortion (using xaudio2)
Description Audio is distorted with -refreshspeed enabled using xaudio2 which appears default to Windows 10
Steps To Reproduce mame mspacman -refreshspeed -sound xaudio2
enable refreshspeed and start up Ms.Pacman. Hear the audio distortion. Also happens with Gradius and I suspect any game with a refresh rate above 60Hz. Disabling refreshspeed resolves problem.
Additional Information
Github Commit
Flags
Regression Version 0.172
Affected Sets / Systems mspacman
Attached Files
wav file icon Gradius.wav (1,968,818 bytes) May 5, 2016, 03:04 Uploaded by denzilla
wav file icon mspacman.wav (1,424,050 bytes) May 5, 2016, 03:04 Uploaded by denzilla
wav file icon mspacman.out.wav (4,097,700 bytes) May 5, 2016, 20:41 Uploaded by anikom15
Sample recorded directly from PCM out.
Relationships
There are no relationship linked to this issue.
Notes
28
User avatar
No.12593
Tafoid
Administrator
May 4, 2016, 23:32
I tried current GIT and release 0.173 with -refreshspeed only on mspacman and gradius. Both game reported "0/10 skip 97%" which is expected because the emulation has to slow down from 100% of machine's refresh rate to fit within (below) the 60hz confines safely. As far as audio, I didn't hear any distortion. The pitch is ever so slightly lower than normal but that is expected due to the artificial slowdown needed to bring things again under the 60hz.

Have you tried in a fresh install with only sending "mame mspacman -refreshspeed" ?
User avatar
No.12598
denzilla
Tester
May 5, 2016, 01:54
edited on: May 5, 2016, 03:07
Yes. Made a new config and only enabled resfreshspeed option. You hear the distortion with Ms.Pacman's stage into tune. With Gradius, the distortion is heard during the "warming up" countdown. Disable refreshspeed and no more distortion. Everything is fine in MAME 172.

AMD Phenom II x4 CPU
Realtek Audio
AMD R7 240 gfx card
Windows 10 Pro

I uploaded recordings I made using my phone. When using MAME to record the output directly, the audio plays fine with no distortion. The distortion is evident in-game, but the distortion isn't present in the playback. Weird....
User avatar
No.12609
Robbbert
Senior Tester
May 5, 2016, 09:47
Unable to confirm. You didn't say what video renderer you used.

Due to a problem with my pc i have to rdp to it, so things run much slower than usual.

Tried d3d, 100% no problem.
BGFX only runs at 77% so there was lots of echo, but no distortion.
GDI showed 100% but frame skipping was evident. Sound was perfect though.
opengl didn't work.
User avatar
No.12610
denzilla
Tester
May 5, 2016, 11:03
edited on: May 5, 2016, 11:05
No renderer. MAME default. No bgfx, hlsl, no nuff'n.

Puzzling you can't reproduce. Happens on every pc I try it on. Go back to 172, no problems. You guys using gsync/freesync? I'm not.
User avatar
No.12611
Robbbert
Senior Tester
May 5, 2016, 14:05
You guys using gsync/freesync?

I don't know what that is.

If you're on Windows then the default is d3d renderer.
User avatar
No.12612
Tafoid
Administrator
May 5, 2016, 15:07
Intel i5 4570 - 3.,2ghz
RealTek High Definition Audio
NVIDIA GeForce 9800 GT
Windows 7 Home 64-bit

Not quite sure what the problem is. Perhaps some others on Windows 10 can give it a whirl.
User avatar
No.12613
denzilla
Tester
May 5, 2016, 15:10
Gsync (NVIDIA) and Freesync (AMD) are features that allow variable refresh rate on supported hardware.

Yes, I'm using the default d3d renderer.
User avatar
No.12614
B2K24
Senior Tester
May 5, 2016, 15:43
I'm running Windows 10 Pro and have a G-Sync capable display (Acer Predator XB271HU)

mspacman and gradius sound identical running with -refreshspeed and running without inserting it.

Unable to confirm this report.
User avatar
No.12615
anikom15
Tester
May 5, 2016, 20:39
Can confirm here. ThinkPad T450s with Windows 10 Pro. 60 Hz monitor. 98.5% speed. Attached audio sample.
User avatar
No.12616
Ziggy
Tester
May 5, 2016, 22:31
edited on: May 5, 2016, 22:43
I also have the audio distorion starting with 0.173 with refreshspeed. Tried several games such as Donkey Kong, Xevious, and Ms. Pac-Man. Confirmed that it works fine with 0.172. Confirmed have a default mame.ini and only enabled refreshspeed. Using MAME 64 bit on Windows 10 64 bit, processor is Intel Core
i7-4790K (4 GHz), 16 gig mem, NVidia 780ti Video card with latest drivers with a Samsung LED 1080p monitor at 60 Hz.

Not sure if it helps, but see the following link where Aaron Giles previously fixed a similar problem:
http://mametesters.org/view.php?id=2622

Is the pattern perhaps with Windows 10 and 60 Hz monitor (without G-Sync)?
User avatar
No.12617
denzilla
Tester
May 5, 2016, 23:04
My monitor is a 60Hz LG 1080p
User avatar
No.12619
Tafoid
Administrator
May 5, 2016, 23:31
The current belief is that it is tied directly to use of "xaudio2" as the default, where available. Windows 7 doesn't seem to have xaudio2 unless you install a DirectX redist.
Those having issues please try with -sound dsound to see if your problem is only with xaudio2.
User avatar
No.12620
Ziggy
Tester
May 6, 2016, 00:02
edited on: May 6, 2016, 00:18
Setting sound to "dsound" in my mame.ini fixed the audio distortion!!!

Wonder what changed between 0.172 and 0.173 that would have caused this. I've been using Windows 10 successfully with sound set to "auto" with refreshspeed since early December.
User avatar
No.12621
Tafoid
Administrator
May 6, 2016, 00:25
There was a change to make xaudio2 the default if available, so that would explain it.
https://github.com/mamedev/mame/commit/42bc565cfb5a6c1b46c4769d056894691489db1e

It would be helpful for someone who has the issue to back check 0.172 and earlier with -sound xaudio2 to we can narrow down the issue. I'm guessing it happens as long as the xaudio2 has been an option.

I'll wait for OP to confirm it on his machine and then confirm the bug officially.
User avatar
No.12622
denzilla
Tester
May 6, 2016, 02:33
172 - Changed to xaudio2 and had sound distortion.

173 - Changed from xaudio2 to dsound and audio played fine.
User avatar
No.12631
R. Belmont
Developer
May 6, 2016, 14:31
edited on: May 6, 2016, 14:32
Audio distortion with -refreshspeed is, honestly, expected. It means MAME will deliberately not be supplying samples to the sound card at the correct rate; you are sacrificing correct audio for visual smoothness. If it worked with dsound, it means dsound is broken. GSync/FreeSync are a far, far, far, far, far, far, far better solution.
User avatar
No.12636
anikom15
Tester
May 7, 2016, 05:27
What should and shouldn't be expected? Real hardware will not run at a slower speed, so really it is up to MAME to decide how it should be handled. Instead of supplying samples at a slower rate, shouldn't it be possible to reduce the sample rate? This will ensure auditory smoothness at the expense of pitch. This is generally a more natural effect.
User avatar
No.12637
Calamity
Developer
May 7, 2016, 12:05
Audio distortion, as variation in pitch, is indeed expected, sound glitches however, are not.

This works ok, with the expected pitch variation:

mame gradius -speed 0.99 -sound dsound
mame gradius -speed 1.01 -sound dsound


This causes sound glitches:

mame gradius -speed 0.99 -sound xaudio2
mame gradius -speed 1.01 -sound xaudio2


The core sound manager resamples the buffer when -speed or -refreshspeed is used, so it sends a different amount of samples. This causes overflows and underflows in xaudio2. It only works ok when the number of samples sent is an exact match of the buffer size.
User avatar
No.12648
R. Belmont
Developer
May 13, 2016, 18:32
edited on: May 13, 2016, 18:32
I would suggest -sound dsound be the default for people who hate audio and don't mind "at the expense of pitch", which those of us with perfect pitch to whom such things are like stabbing us with knives can run -sound xaudio2.

Or -speed can just turn off sound entirely, since clearly they're VIDEO games, the sound quality doesn't matter.
User avatar
No.12649
B2K24
Senior Tester
May 13, 2016, 21:31
-refreshspeed should just go away like -mt did.
User avatar
No.12657
intealls
Tester
May 15, 2016, 13:55
edited on: May 15, 2016, 13:55
-refreshspeed is a weird option, it doesn't provide smooth scrolling and the adjustments appear to be quite coarse, so pitch shifts will be noticable (even for those who don't possess 'perfect' pitch). -syncrefresh (which is in GM) is entirely different. It provides lovely, smooth scrolling (with inexpensive monitors) at the expense of a slight, static pitch shift (depending on the refresh rate of the monitor/game). If this is unbearable, it's quite easy to simply turn the option off.

@ R. Belmont
If sound quality doesn't matter, why are there plans for a higher quality resampler (https://github.com/mamedev/mame/issues/385 )? Why does RA have a sinc resampler?
User avatar
No.12659
denzilla
Tester
May 16, 2016, 03:32
Come on guys! Cut us peasants some slack until gsync/freesync are more common in monitors. I'm sure there are other things in mame junking up the code base more than refreshspeed.
User avatar
No.12720
Tourniquet
Developer
May 26, 2016, 22:51
https://www.reddit.com/r/MAME/comments/4km1hc/horrible_clicking_noise_in_missile_command/ is another report of this.
User avatar
No.12722
bradhugh
Developer
May 26, 2016, 22:52
I can look at this.
User avatar
No.13046
Tafoid
Administrator
Aug 11, 2016, 18:03
edited on: Aug 14, 2016, 01:30
This is reported to be fixed. Can someone who has access to current GIT sources and xaudio2 confirm this is so?
https://github.com/mamedev/mame/commit/30cf980dd60281de54e5478462eba9fb69b6ea65

This appears to have a side effect of causing a good 2-3 second latency in audio output.
User avatar
No.13058
Augusto
Tester
Aug 20, 2016, 02:41
Audio distortion perhaps was fixed.
`` This appears to have a side effect of causing a good 2-3 second latency in audio output.``
Correct.
Is random when latency is 2 or 3 seconds.
The framerate is some frames ahead of sound.
Press fast forward key for some seconds in ddragon or rygar.
Have chance that is code sound core need from video render to sync the audio.
User avatar
No.13093
Augusto
Tester
Sep 1, 2016, 03:09
Tested with current version fix for xaudio2 has good progress.
Have some audio distortions just for some games.
One good example is try powerins. Starting the game, character select screen and in indian stage has sound issues just if using xaudio2.
Thanks for read my post.
User avatar
No.15537
MetalGod
Senior Tester
Oct 15, 2018, 19:30
It seems it was fixed since mame 0.177 by Antonio Giner