SDL_Delay causes coil noise

I’m having some problems with an emulator that uses SDL (DosBox), it being the only application that causes coil noise (or screeching) from the CPU. Somebody from their forums suggested me to replace SDL_Delay with busyWait in the source code and it fixed the problem, but that causes the emulator to use 100% CPU. Is there any work around or any fix to SDL_Delay? (assuming that’s what’s causing the noise)

since I’m on the same forum, DOSBox is using SDL 1.2x not SDL2 if that matters.

Whops, I forgot to mention that, I never use any app that uses SDL 2.X :stuck_out_tongue:

Is it really from the CPU?
I got that from the GPU in a game with vsync disabled.
Try enabling vsync in the game or even enforcing it in the driver.

Good luck :wink:

Cheers,
DanielAm 23.08.2014 17:44, schrieb andoru:

I’m having some problems with an emulator that uses SDL (DosBox), it
being the only application that causes coil noise (or screeching) from
the CPU. Somebody from their forums suggested me to replace SDL_Delay
with busyWait in the source code and it fixed the problem, but that
causes the emulator to use 100% CPU. Is there any work around or any fix
to SDL_Delay? (assuming that’s what’s causing the noise)

Well I know for certain the noise comes from the CPU due to the fact that in DosBox, you can set the amount of cycles it emulates (the more cycles, the more CPU intensive) and when I increase the amount of cycles, the coil noise lowers in pitch. And also what I said earlier: when using busyWait instead of SDL_Wait, there’s no coil noise, but the CPU is used to 100% so I think it’s the CPU that the noise comes from.
Unfortunately DosBox does not have a vsync feature, and I think it would impossible to implement it in the emulator. By driver do you mean a SDL video driver (DosBox doesn’t use one) or do you mean the video card driver’s settings? In the second case I’m using an integrated GPU and I’m on linux, so I have no way of setting any vsync settings :stuck_out_tongue:
So I couldn’t test that.

Well I know for certain the noise comes from the CPU due to the fact
that in DosBox, you can set the amount of cycles it emulates (the
more cycles, the more CPU intensive) and when I increase the amount
of cycles, the coil noise lowers in pitch. And also what I said
earlier: when using busyWait instead of SDL_Wait, there’s no coil
noise, but the CPU is used to 100% so I think it’s the CPU that the
noise comes from.
It could be caused by your CPU switching powersaving modes. Try
disabling it. On Linux this is cpufreq which can be controlled (at
least on my computer with Debian testing) with cpufreq-info and
cpufreq-set programs. There’s probably also some GUI tool for it
depending on your desktop.On Sun, 24 Aug 2014 22:01:29 +0000 “andoru” <andoru.blah at gmail.com> wrote:

I think you are attacking the problem the wrong way. I would try to locate
exactly what is causing the coil noise and replace those bad parts, or just
accept that your computer generates coil noise at some specific CPU current
draw/load. Anyway, I don’t think this is a topic for the SDL Development
List…

Simon

2014-08-29 11:10 GMT+02:00 Turo Lamminen <turo.lamminen at alternativegames.net>:

On Sun, 24 Aug 2014 22:01:29 +0000 “andoru” <andoru.blah at gmail.com> wrote:

Well I know for certain the noise comes from the CPU due to the fact
that in DosBox, you can set the amount of cycles it emulates (the
more cycles, the more CPU intensive) and when I increase the amount
of cycles, the coil noise lowers in pitch. And also what I said
earlier: when using busyWait instead of SDL_Wait, there’s no coil
noise, but the CPU is used to 100% so I think it’s the CPU that the
noise comes from.
It could be caused by your CPU switching powersaving modes. Try
disabling it. On Linux this is cpufreq which can be controlled (at
least on my computer with Debian testing) with cpufreq-info and
cpufreq-set programs. There’s probably also some GUI tool for it
depending on your desktop.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org