pete-gordon / oricutron

Portable Oric-1/Atmos/Telestrat and Pravetz 8D emulator
http://www.petergordon.org.uk/oricutron/
GNU General Public License v2.0
69 stars 25 forks source link

Improve fidelity of 8912 audio output, making PING clearer #193

Closed erik-persson closed 10 months ago

erik-persson commented 10 months ago

This change is best appreciated by pressing Ctrl-G in Oricutron before and after the change.

The 8912 model has long been modelling the audio channels accurately from cycle to cycle, but only sampled them sparsely with a 44.1 kHz interval. The sparse sampling gives significant aliasing noise, mainly affecting high pitched sounds.

The present change replaces the sparse sampling with averaging. Within each sample interval, the cycle by cycle model output is added up, then finally divided to form the audio output sample.

We retain the pre-existing newout mechanism to save cycle by cycle work.

This is not a state of the art re-sampling technique, but it reduces the aliasing significantly, making PING sound close to on a real Oric.

pete-gordon commented 10 months ago

Wow nice one

iss000 commented 10 months ago

@erik-persson: can you recheck your code for SDL-1? Start Oricutron and type some ZAP's - the sound doesn't stop. See attached video. (SDL-2 seems to be OK).

https://github.com/pete-gordon/oricutron/assets/1128663/76e9e6bd-864e-4738-9053-db15fb78bbbf

erik-persson commented 10 months ago

Oh, that's a bad result! I had indeed only tested sdl2. I will try to reproduce tonight and hopefully amend this!

erik-persson commented 10 months ago

Tests under openSUSE 15.4

I have a linker error with sdl1 on my Mac after Sonoma, will sort that out and then try there too.

@iss000, may I ask which platform you saw affected?

erik-persson commented 10 months ago

Managed to build with sdl1 on macOS Sonoma 14.0 Required changing from clang 12.0.5 to clang 15.0.0 This also works without ZAP problems. sdl-config --version says 1.2.68.

iss000 commented 10 months ago

I'm on Linux Fedora 38 64-bit. Probably pipewire/wayland are playing tricks. But never experienced such problems before. (Again SDL2 is just fine). I'll try 1.2.68 too asap.