Child pages
  • Smooth Playback

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Overview

Achieving smooth playback of emulated games running on libretro cores depends on a number of factors. The Emulators plugin controls the timing of playback by advancing the game one frame at a time and is required to do this at or near the original framerate of the game, as reported by the libretro core, in order for playback to be smooothsmooth. There are a number of ways this is achieved depending on the configured settings and circumstances, namely by using VSync to advance a frame every time the monitor refreshes, by blocking until enough audio has been played to queue the next batch of audio, or by manually timing the required interval. Each of these methods has advantages and disadvantages

VSync

VSync can be enabled by going to Settings→ Plugins→ Emulators→ Libretro→ Enable VSync.

VSync offers the most consistent and reliable method for timing but relies on your monitor refresh rate matching the original framerate of the game (usually 50 or 60hz), if it does not match then playback will be too fast or slow. You can use this method in conjunction with MP2's refresh rate changer to automatically adjust the refresh rate of your monitor to match the game, see refresh rate changing below.

Using VSync, in conjunction with the refresh rate changer if necessary, will often get you very close to the expected framerate, however there are often still small differences, this can cause audio buffer over/underruns which leads to audio glitches over time because libretro cores deliver exactly one frame of audio per frame of video, so if the video framerate is slightly fast then audio playing back at the expected rate won't keep up (and vice versa), this can be mitigated by enabling dynamic audio rate control described below.

Refresh rate changing

MediaPortal 2 includes an automatic refresh rate changer which the plugin can integrate with to automatically switch the refresh rate of the monitor to match the target framerate of the game. It can be enabled under Settings→ Players→ Video Player. Use this in conjunction with VSync to achieve the most consistent framerate.

Dynamic audio rate control

To compensate for small differences in the monitor refresh rate affecting audio you can enable dynamic audio rate control (Settings→ Plugins→ Emulators→Dynamic audio rate control), this will attempt to adjust the audio playback rate to match the actual refresh rate. Adjusting the playback rate will affect the pitch of the audio so this will only adjust the playback rate up to the delta configured in this setting. A delta up to 0.005 (i.e. allowing the plugin to increase/decrease the playback rate up to 0.5%) should only cause an inaudible change whilst allowing small compensations to be made, so it is still neccessary for the monitor refresh rate to closely match the target framerate for this to be effective. This setting has no affect if VSync is disabled.

Syncing to audio

If VSync is disabled the plugin will instead attempt to sync the framerate to the audio playback rate. A libretro core delivers exactly one frame of audio per video frame, by waiting for enough audio to be played to be able to buffer the next frame of audio a reasonably accurate method of timing can be achieved and gurantees that the audio buffer will never overrun. However this tends to cause small variations in the playback rate which may be noticeable as small stutters in video playback but is completely independent of the monitor refresh rate.

Manual timing

The plugin will only attempt to use manual timing if VSync is disabled and there is no audio to play that can be used to synchronise to. Due to timers being inconsistent and highly dependent on current resource usage, etc, this is a very crude method of achieving a certain framerate and is only used by the plugin as a last resort.