Mednafen Members Members   Search Search   Help Help   Register Register   Login Login   Home Home
Home » Mednafen » Development » Mednafen sound output generating too many samples
Show: Today's Messages  :: Show Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Mednafen sound output generating too many samples [message #529] Sat, 07 October 2006 12:40 Go to next message
ArtVandelae  [PM]
I have recently been exploring the 0.6.5 source and have noticed some behavior that I am finding problematic when running the PC Engine emulation. It seems that when calling MDFNI_Emulate() the returned sound buffer is too long. For example, with the sound rate set to 48000 and the soundmultiplier setting at 1 the returned sound buffer is 802 to 803 samples in length as opposed to the 800 samples one would expect when running at 60fps.

Discarding the extra samples is not an option as doing so introduces noticeable popping sounds. Increasing the soundmultiplier factor can help but no matter what setting it is fed it still doesn't return a steady 800 samples per second (it will return mostly 800 length buffers with some 799 and 801 length buffers mixed in).

I'm not sure if there is a setting I am overlooking or if there is an internal timing issue that could be addressed to correct this behavior.

Aside from that, I must commend you on writing are very clean, understandable, and high quality emulator.
Re: Mednafen sound output generating too many samples [message #530 is a reply to message #529 ] Sat, 07 October 2006 13:46 Go to previous messageGo to next message
Administrator  [PM]
Simple explanation: the PC Engine doesn't run at exactly 60fps.
Re: Mednafen sound output generating too many samples [message #535 is a reply to message #529 ] Fri, 13 October 2006 00:45 Go to previous messageGo to next message
blargg  [PM]
Additionally, Blip_Buffer doesn't support an infinitely precise clock rate to sample rate ratio, so it probably wouldn't generate exactly 800 samples per 1/60 second even if the PC engine did generate that. This should never be a problem since a sound card's sample rate and display's refresh rate are never going to be exactly 48000 Hz and 60 Hz anyway. Simply put, you can't have two time masters since they will get out of sync over time. The best solution is to use sound as the master and slave the frame rate off that, since doubled/skipped frames are much less noticeable than audio glitches.

I should add that while Blip_Buffer has limited precision for the clock rate to sample rate ratio, the actual ratio it chooses is exact. This means that it might generate exactly 48010 samples per second rather than the desired 48000, the only effect being a slight lowering of pitch when output at 48000 samples per second.

[Updated on: Fri, 13 October 2006 00:53]

Re: Mednafen sound output generating too many samples [message #2551 is a reply to message #529 ] Fri, 01 June 2012 05:59 Go to previous message
filevans  [PM]
"since doubled/skipped frames are much less noticeable than audio glitches."

absolute nonsense, any frameskip looks annoying, a slight sound skip is much less noticable than a frameskip
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:Instead of a frontend, a QT-based full GUI --attn mednafen developers
Next Topic:Mednafen 0.9.22-WIP binaries for Mac and how to compile your own
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ ]

Current Time: Sat May 18 08:38:47 CDT 2024
.:: Contact :: Home ::.

Powered by FUDforum.
Copyright © FUDforum Bulletin Board Software