VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

How high (in absolute percentage of the maximum output) can an input range be (from 0 to max voltage(the same for negative voltage)) before a overflow is occurring?

I have a nyquist low-pass filter on each sound channel (depending on the used samplerate given by SDL/SDL2) and a 18.2Hz high-pass filter on the final output (after summing and clipping all channels) before being sent to the rendering OS/DAC(using SDL/SDL2's sample-based sound rendering function).

Anyone? It's currently reducing the sound to become a range of (0.5*0.99999) of the 16-bit signed samples before passing it through the low-pass filter on each channel(clipping said channel after applying the low-pass filter to 16-bit range).
Said reduction of the volume will cause the sound to not clip yet.

How high can I go with this without it causing clipping using said filters?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 1 of 6, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie

It depends on a lot of details of your filter implementation - and isn't necessarily an easy calculation. But why do you actually need a high-pass filter in the first place? Lower frequencies aren't going to be audible either way - the speaker/air/ear system filters them out regardless just as it does on the real hardware that you're emulating.

Reply 2 of 6, by superfury

User metadata
Rank l33t++
Rank
l33t++

What happens then if you supply a 5V(or however max amplitude is scaled) voltage(e.g. only +32767) values to SDL? That can happen if some app hangs while sampling for some reason(e.g. sound blaster not receiving interrupt ACK anymore with the last sample being 255 in 8-bit mode or 65535(both unsigned samples))? Won't that possibly burn the speaker coil?

Last edited by superfury on 2020-09-17, 13:58. Edited 1 time in total.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 6, by reenigne

User metadata
Rank Oldbie
Rank
Oldbie
superfury wrote on 2020-09-17, 13:31:

What happens then if you supply a 5V voltage(e.g. only +32767) values to SDL? That can happen if some app hangs while sampling for some reason(e.g. sound blaster not receiving interrupt ACK anymore with the last sample being 255 in 8-bit mode or 65535(both unsigned samples))? Won't that possibly burn the speaker coil?

No. Sound cards and speakers are designed so that they can't be destroyed by software like this (which might be done by putting a capacitor in series with the speaker - a hardware high-pass filter). Btw, the speaker in the original PC and XT don't even have this - it's perfectly possible for software to put 5VDC through it, and it is not damaged by doing this (I have done this lots of times with my XT).

Reply 4 of 6, by superfury

User metadata
Rank l33t++
Rank
l33t++

Just checked again. It's reducing the volume to x0.5 for the nyquist low-pass filter before resampling. The high pass after that is set to 18.2Hz. Both are a simple RC filter.

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 5 of 6, by superfury

User metadata
Rank l33t++
Rank
l33t++

After disabling the high-pass filter and only leaving the required low-pass nyquist filter(required for resampling) in place, the sound no longer seems to clip? I've also changed the volume reduction to no longer happen(multiplying by 1.0, thus not changing volume).

Although the sound (at least as generated by the MIDI device) is very loud now? Windows 10's volume mixer displays it's at 100% volume most of the time?

Edit: Having removed the high-pass filter of 18.2Hz from the mixer code(that mixes all MIDI, adlib and other sound devices together) seems to fix the clipping somehow (by the naked eye, looking at the Windows 10 volume indicator and hearing the sound being played no longer ticking)?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 6 of 6, by superfury

User metadata
Rank l33t++
Rank
l33t++

OK. I had to implement channel-specific high-pass filters instead. The MIDI renderer can't use it due to sound becoming too soft.
But the other sound channel actually can generate DC voltage, which causes the rendering system to try and output that to SDL. And if the rendering system isn't running at 100% full speed, said signal will go high when it's rendering up-to-date, then low immediately after because the emulator doesn't have any samples left to render. So that causes a slow square wave to be sent to the speaker because it cannot render samples fast enough, causing the speaker to give a fast rated ticking noise, which shouldn't happen.
With those new filters on the sound renderer, controlled by emulated hardware(most just enable the filter), the strange ticking noise is gone.

Most of the cases were happening with hardware giving -5V DC or +5VDC on the inputs(e.g. covox speech thing being set to 0, thus -5V). Of couse this can happen with all kinds of hardware that are controlled by software. So I enabled the high pass filters for all devices but the MIDI synth(which doesn't need it).

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io