TASEmulators / desmume

DeSmuME is a Nintendo DS emulator
http://desmume.org
GNU General Public License v2.0
3.01k stars 550 forks source link

[Emulation Issue] Konami Castlevania Series persistent audio crackling #610

Closed KinDeDu closed 2 years ago

KinDeDu commented 2 years ago

Castlevania games on Desmume suffer from an ongoing problem of crackling audio with default or changed settings. The problem is present in the music or in the game menu although barely noticeable (Castlevania: Dawn of Sorrow, Castlevania: Order of Ecclesia).
While Castlevania Portrait of Ruin is the one that has it the most especially in the menu and during the game.

This is with Desmume (Default Settings, Game Menu):

https://user-images.githubusercontent.com/20727674/200991029-ba2c46af-9ead-48d2-b2dd-e010e6ace8de.mp4

This is as it should be (As on the DS, MelonDS and Drastic):

https://user-images.githubusercontent.com/20727674/200991114-63ae3c78-6311-442a-b503-3d5342bfe2f8.mp4

I've tried changing all settings, use all versions (old, nightly, DeSmuME X432R, Desmume Retroarch Core and Desmume 2015 Retroarch Core) but the problem persists.

I have tried on other emulators like MelonDs on PC and Drastic for Android and it does not happen.

Last on No$gba, the problem exists there as well but worse even changing the settings (although it also happens with other games that Desmume manages to emulate without these problems).

There are also videos on youtube about these games with Desmume, same problem

I have tested the emulator on various PC systems (Intel or Amd Cpu and Nvdia or Amd GPU, Intel iGPU) to see if it is not a problem with my PC.

I would like to know what it is caused by and if it is fixable.

zeromus commented 2 years ago

It's caused by shortcomings in the SPU emulation and/or the core emulator timing. The game is writing very small sound buffers in the manner of a double buffered stream, but desmume runs ahead playing the buffer too quickly and is in the middle of playing the 2nd buffer while the game is still putting data there, which means the data is replaced while it's in the middle of being decoded. Desmume needs to delay some time before starting the sound channel probably, so that the game has had time to fill the 2nd buffer before desmume's SPU tries to play it (and once things are aligned properly, it should stay aligned). It's fixable, sure.

petran79 commented 2 months ago

Problem still persists with that game. MelonDS does not have that issue fortunately.