Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird ringing in sound #19

Open
pachuco opened this issue Apr 4, 2024 · 13 comments
Open

Weird ringing in sound #19

pachuco opened this issue Apr 4, 2024 · 13 comments

Comments

@pachuco
Copy link
Contributor

pachuco commented Apr 4, 2024

I do not have an actual SC55 to confirm this, but there is a strange high pitched ringing in the sound, as if interpolation is borked.

I've attached two files in this zip. The one with _hp suffix is filtered in audio editor to isolate the perceived flaw.
The other one is plain recording.

ringadingadingdong.zip

Platform is xp sp3 x86.

@pachuco
Copy link
Contributor Author

pachuco commented Apr 4, 2024

the_stink_files.zip

@nukeykt
Copy link
Owner

nukeykt commented Apr 4, 2024

Perhaps XP has crappy audio resampling, sc-55mkII outputs non standard 66207hz audio

@pachuco
Copy link
Contributor Author

pachuco commented Apr 4, 2024

Oh, that makes sense then.
Maybe I should shove an inline resampler at the output. I've had positive experiences before with snes gaussian on the OPL3, but maybe sinc would be better fit.

@datajake1999
Copy link

If I ever get around to writing a VST based on Nuked SC-55, I plan on integrating the Blargg resampler library, which I forked at https://github.com/datajake1999/blargg_resampler. It is a decent resampler that uses sinc interpolation.

@johnnovak
Copy link

johnnovak commented Apr 4, 2024

We've been using the Speex resampler (libspeex) in DOSBox Staging with very good results at quality setting 5. That setting is basically transparent on normal musical material for most normal people (except on specially prepared material when A/B-ing it in studio headphones, but even then the difference is extremely hard to spot).

It's very fast, even on low-end hardware like the Raspberry Pi 3, so my recommendation.

https://speex.org/docs/manual/speex-manual/node7.html#SECTION00760000000000000000

@Gerwin2k
Copy link

I am having similar trouble, but more so. Much more ringing/distortion in Windows 7 x64 official builds. Exactly the same with my Windows XP x86 builds (same on two entirely different systems). Only my Linux x64 build sound good, which kinda proves that the code and ROMs are not borked.
CPU usage is not even that much; Below 50% of one core.

I made .wav files with the same 66207Hz and 64000Hz sample rates, which play fine in different sound players.
Still investigating... Maybe SDL2 specific.

@pachuco
Copy link
Contributor Author

pachuco commented Apr 12, 2024

You are at mercy of OS/driver's interpolation.

On my X86 XP, different results from default audio driver and Virtual Audio Cable.
VAC does linear interpolation, I think, while default audio(SB Audigy LE) does nearest.

@Gerwin2k
Copy link

Both systems I mentioned use a Realtek audio chipset. I could maybe switch to the AMD graphics HDMI audio for testing.
I would like to test more systems at the office, but I don't want to install loopmidi on these for just a quick test.

Earlier I looked up details on Windows XP sound resampling, and it suggested that this OS switches to the actual sample rate when the hardware supports it, and when no other sound is playing.

@johnnovak
Copy link

johnnovak commented Apr 12, 2024

As me and some others mentioned, the answer is a built-in resampler. SpeexDSP is great, fast, and easy to use. It is the resampler that PulseAudio uses on Linux, from memory.

Btw, my Realtek driver on Win10 deals with the unorthodox rate just fine, no issues.

@Gerwin2k
Copy link

It would be interesting to test with an embedded resampler. Though I also have some evidence it is actually something else:

  • The Realtek Chipset in my main system was their flagship ALC889 (2011).
  • Earlier I wrote "I made .wav files with the same 66207Hz and 64000Hz sample rates, which play fine in different sound players.".
  • Windows 7 x64 has it too.
  • It sounds really bad. Almost unrecognizable.

But because I am seemingly one of the very few with this problem, I suppose I have to be investigate myself or be patient.

@pachuco
Copy link
Contributor Author

pachuco commented Apr 12, 2024

@johnnovak

I've tried shoving in a resampler but I can't seem to not mess up the thin balance between the audio thread and the work thread.
What's the sicrit?

@johnnovak
Copy link

johnnovak commented Apr 12, 2024

@johnnovak

I've tried shoving in a resampler but I can't seem to not mess up the thin balance between the audio thread and the work thread. What's the sicrit?

Haven't looked at the code, but most likely the way the threading is done is not great to begin with, then the extra overhead from the resampler might push it over the limit.

Make sure to use an efficient resampler. We use Speex all over the place in DOSBox Staging and there's threading involved etc. In our case, there's a render thread that gets MIDI messages and fills the buffer at whatever native rates, then the mixer and resampler is in another thread. That's what you want; don't overload the rendering thread even more.

@Gerwin2k
Copy link

I am finally listening to some reasonably good audio output. This made the difference:
//static const int audio_page_size = 512;
static const int audio_page_size = 2048;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants