VOGONS


First post, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

Lets start by saying that nothing is wrong with the compatibility of the SB in dosbox, what wrong is how it sounds in comparison to a real SB.
We all know that the Sound Blaster has a Lowpass Filter at the frequency of playback, well at least SBPro and SB16.

I have captured the frequency response of a SB16 card and DOSBox on SB16 setting.

SB16 11.png
Filename
SB16 11.png
File size
174.83 KiB
Views
1643 views
File license
Fair use/fair dealing exception
DB 11.png
Filename
DB 11.png
File size
180.52 KiB
Views
1643 views
File license
Fair use/fair dealing exception
SB16 5.png
Filename
SB16 5.png
File size
163.23 KiB
Views
1643 views
File license
Fair use/fair dealing exception
DB 5.png
Filename
DB 5.png
File size
189.13 KiB
Views
1643 views
File license
Fair use/fair dealing exception

The SB16 has a very steep Sinc "brickwall" lowpass filter at the played back frequency which also eliminates aliasing with low sampling rates (most games).
A proper lowpass filter is not only there to sound good but is essential to eliminate aliasing artifacts according to nyquist theorem.
I know that dosbox already implements a dynamic lowpass filter of the SB16 which moves with the frequency but it is of the wrong order, it looks like a typical first-order LPF which sounds nothing like the SBPro or the SB16.
As you can see DOSBox does it absolutely wrong and it sounds like so.

I would like to suggest and help to put some collective effort in improving this aspect of dosbox because sound is one of the most important aspects of gaming and nostalgic value.
The proper filter is called Sinc filter or "brick-wall" filter and the equations for it are readily available everywhere including wikipedia.
I can try to implement it myself if I knew where the LPF section in the source code is, it is not in sblaster.cpp from what I see.

Anyone interested?

Last edited by James-F on 2020-01-09, 08:11. Edited 1 time in total.


my important / useful posts are here

Reply 1 of 43, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

A low-pass filter is implemented in the SB emulation of the DOSBox-X branch, so you can try looking at that, but I don't expect it would drop into the current official source easily because the SB stuff deviates significantly.

Reply 3 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

Thanks ripsaw8080, The X branch sounds closer to the real hardware but still not accurate, and yes, the source in sblaster.cpp and mixer.cpp differs a lot.
I think it will be over my head to do something about it lacking the programming abilities.


my important / useful posts are here

Reply 4 of 43, by kolano

User metadata
Rank Oldbie
Rank
Oldbie

Still hoping someone could implement the Mic/Line inputs on SB (or other) cards. I have a variety of DOS eyecandy software with features requiring such I'd like to try,

Eyecandy: Turn your computer into an expensive lava lamp.

Reply 6 of 43, by Dominus

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator

And SDL2 has only added audio capture a couple of days ago to their source.

Windows 3.1x guide for DOSBox
60 seconds guide to DOSBox
DOSBox SVN snapshot for OS X (10.4-10.14 ppc/intel 32/64bit) codesigned for gatekeeper
DOSBox SVN with SDL2 snapshot for OS X (10.7-10.14 intel 64bit) codesigned for gatekeeper

Reply 7 of 43, by dr_st

User metadata
Rank l33t
Rank
l33t
James-F wrote:

Thanks ripsaw8080, The X branch sounds closer to the real hardware but still not accurate, and yes, the source in sblaster.cpp and mixer.cpp differs a lot.
I think it will be over my head to do something about it lacking the programming abilities.

Since DOSBox does have some filtering capabilities, I assume that there is a digital filter implementation (FIR/IIR) there somewhere (if not, it's not difficult to add).

This can be solved by simply designing a better filter for the desired frequency response (MATLAB, for instance, has plenty of tools to design such filters, with a great deal of flexibility). This can be done offline, and the filter coefficients can simply be saved and passed to DOSBox as hard-coded.

Reply 8 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

The logic behind it is quite simple, read the sampling frequency (which the game sets) and apply a sinc filter equation at half the sampling rate.
This is exactly what DOSBOX-X does (according to sblaster.cpp notes), but instead they tailored the filter by ear instead measuring it with an analyzer and seeing that it is a simple sinc/FIR filter.
SBPro2, SB16, ESS, they all use the Sinc/FIR filter to brickwall at half the sampling rate, whether it's 8k 11k 22k or 44k.
In fact, all modern sound cards, CD players and DACs in general do that to eliminate in-band audible aliasing.

Actually the MATHLAB part is done:
http://www.mathworks.com/help/hdlfilter/examp … w.mathworks.com
https://tomroelandts.com/articles/how-to-crea … low-pass-filter

Searching google for "FIR sinc filter c++" yield a lot of results.


my important / useful posts are here

Reply 9 of 43, by NewRisingSun

User metadata
Rank Oldbie
Rank
Oldbie

Speak for the Sound Blaster 16 if you want, but the Sound Blaster Pro definitely does not use a brick wall filter. Instead, it uses a simple 3.2 kHz filter that can be turned on and off by software, somewhat similar to the Amiga's low-pass filter.

Reply 10 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

Alright but not even the simple 3.2kHz filter is emulated properly.
Yes, I am aware that only the SB16 has dynamic filtering which changes with the playback frequency.

Since I cannot write code, I'm in no position to make further requests.
I can only hope someone with the right skills and goals will adopt this project and make dosbox better for us all.


my important / useful posts are here

Reply 11 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

It saddens me that DOSBox in 2020 still doesn't have a proper lowpass filtering emulation to sound like original DOS era sound cards.
DOSBox sounds shrill with a lot of high frequencies in comparison to a good old DOS era SB card.
The SBPro2 (best DOS sound card imo) for example Is a very simple 2nd order at 3.2kHz butterworth lowpass filter and should be very easy to implement in SDL.

Retro PCs with original sound cards getting expensive these days, and I would like to see (hear) DOSBox recreating sound experience as accurately as possible.
What's more, PCem already has a proper Lowpass filter so take that as a reference.

Here is a filter calculator that exports a ready C or VHDL code: http://www.winfilter.20m.com/ ** PCem uses that with great success.

Here is what SBPro2 (CT1600) and PCem are doing:
file.php?mode=view&id=74095

Last edited by James-F on 2020-01-09, 07:10. Edited 1 time in total.


my important / useful posts are here

Reply 12 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

I used the WinFilter tool with DOSBox 49716 sampling rate and generated a SBPro2 frequency response and exported it as DOSBoxIIR.c.
I lack the programming skills but if anyone can make a test build that passes the PCM audio (only) using this .c file I can measure it and compare to real SBPro2.

note: IIR filter coefficients will only be correct if using 49716 sampling rate,, but if it ever gets implemented into DOSBox we can use this small IIR filter for every sampling rate dosbox has to offer.

Attachments


my important / useful posts are here

Reply 13 of 43, by appiah4

User metadata
Rank l33t
Rank
l33t

James-F, it was my understanding that the SB Pro and 16 Low-Pass filters are significantly different, with the SB Pro having a gradually increasing filter beyond a certain frequency whereas the SB16 has a filter that kicks in abruptly at a certain frequency? Can you confirm? If this is true, I would rather have a Low Pass filter that mimics an SB Pro than an SB 16 in DOSBox, personally.

Retronautics: A digital gallery of my retro computers, hardware and projects.

Reply 14 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

Yes, SB16 has a modern "brickwall" filtering with very high amount of taps, which most modern CD players, sound cards, and software media players use to this day to prevent aliasing when playing lower sampling rate files.
The SBpro2 (and older) have a super simple analog (Resistors+Caps) 2nd order lowpass filter which is very simple to implement in code, and light in terms of emulation processing requirements.
Moreover, I think the 2nd order lowpass filter of the SBPro2 sounds much better for lower PCM sampling rates like 11kHz that most DOS games actually used than the brickwall filter of the SB16.

Anyway, I really hope to see this implemented in DOSBox because sound is a huge part of the DOS experience (imo).


my important / useful posts are here

Reply 15 of 43, by KainXVIII

User metadata
Rank Member
Rank
Member
appiah4 wrote on 2020-01-09, 07:13:

If this is true, I would rather have a Low Pass filter that mimics an SB Pro than an SB 16 in DOSBox, personally.

Or both, which we can choose in conf file.

Reply 16 of 43, by appiah4

User metadata
Rank l33t
Rank
l33t
James-F wrote on 2020-01-09, 07:30:
Yes, SB16 has a modern "brickwall" filtering with very high amount of taps, which most modern CD players, sound cards, and softw […]
Show full quote

Yes, SB16 has a modern "brickwall" filtering with very high amount of taps, which most modern CD players, sound cards, and software media players use to this day to prevent aliasing when playing lower sampling rate files.
The SBpro2 (and older) have a super simple analog (Resistors+Caps) 2nd order lowpass filter which is very simple to implement in code, and light in terms of emulation processing requirements.
Moreover, I think the 2nd order lowpass filter of the SBPro2 sounds much better for lower PCM sampling rates like 11kHz that most DOS games actually used than the brickwall filter of the SB16.

Anyway, I really hope to see this implemented in DOSBox because sound is a huge part of the DOS experience (imo).

Can't such a filter be applied to DOSBox sound as a post process? Surely it should be possible to write an external program that captures the audio output from a single process, apply a filter to it and then resend it to the mixer?

Also, I believe this only applies to the DOSBox SB Emlulation in the current branch? How about NukedOPL3, does it do the proper filtering?

Retronautics: A digital gallery of my retro computers, hardware and projects.

Reply 17 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

Filtering is applied only to PCM audio,, OPL is unfiltered (sb16) or slightly filtered (sbpro2) on the real sound cards.
Hence, we don't want filtering on the global output of DOSBox.

We could have separate filters for OPL and PCM which will produce super accurate results.
Any dosbox dev here has interest in that topic?

Last edited by James-F on 2020-01-09, 08:11. Edited 1 time in total.


my important / useful posts are here

Reply 18 of 43, by appiah4

User metadata
Rank l33t
Rank
l33t
James-F wrote on 2020-01-09, 08:07:

Filtering is applied only to PCM audio,, OPL is unfiltered or very slightly filtered on the real sound card.
Hence, we don't want filtering on the global output of DOSBox.

We could have separate filters for OPL and PCM which will produce super accurate results.

Ahh.. I see, I didn't know this.

Can you test the frequency response for OPL3 as you did with PCM above to confirm this?

Retronautics: A digital gallery of my retro computers, hardware and projects.

Reply 19 of 43, by James-F

User metadata
Rank Oldbie
Rank
Oldbie

Yes I can. 😃

ME wrote:

Same for OPL3 lowpass, use Adlib Tracker 2 player called adt2play.exe to play the noise.a2m file and capture with spectrum analyzer.

Re: FM and PCM Volume Balance of SB Cards

It's only a matter if any developer has a few spare minutes to implement this.
I'll do the measurements.

Last edited by James-F on 2020-01-09, 08:15. Edited 2 times in total.


my important / useful posts are here