Lets improve DOSBox Sound Blaster emulation

Developer's Forum, for discussion of bugs, code, and other developmental aspects of DOSBox.

Lets improve DOSBox Sound Blaster emulation

Postby James-F » 2016-9-06 @ 08:01

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

DB 11.png

SB16 5.png

DB 5.png


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?
User avatar
James-F
Oldbie
 
Posts: 1448
Joined: 2015-11-30 @ 04:10

Re: Lets improve DOSBox Sound Blaster emulation

Postby ripsaw8080 » 2016-9-06 @ 15:57

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.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4389
Joined: 2006-4-25 @ 23:24

Re: Lets improve DOSBox Sound Blaster emulation

Postby KainXVIII » 2016-9-06 @ 16:01

Something-something Wizardry 7 :blush:
User avatar
KainXVIII
Member
 
Posts: 316
Joined: 2015-5-20 @ 15:04
Location: Yaroslavl

Re: Lets improve DOSBox Sound Blaster emulation

Postby James-F » 2016-9-06 @ 17:13

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.
User avatar
James-F
Oldbie
 
Posts: 1448
Joined: 2015-11-30 @ 04:10

Re: Lets improve DOSBox Sound Blaster emulation

Postby kolano » 2016-9-07 @ 05:23

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,
User avatar
kolano
Oldbie
 
Posts: 527
Joined: 2010-12-26 @ 21:03

Re: Lets improve DOSBox Sound Blaster emulation

Postby awgamer » 2016-9-07 @ 22:36

SDL 1.2 doesn't have audio recording.
awgamer
Oldbie
 
Posts: 568
Joined: 2014-7-26 @ 07:42

Re: Lets improve DOSBox Sound Blaster emulation

Postby Dominus » 2016-9-08 @ 06:17

And SDL2 has only added audio capture a couple of days ago to their source.
User avatar
Dominus
DOSBox Moderator
 
Posts: 7932
Joined: 2002-10-03 @ 09:54
Location: Ludwigsburg

Re: Lets improve DOSBox Sound Blaster emulation

Postby dr_st » 2016-9-08 @ 10:30

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.
User avatar
dr_st
Oldbie
 
Posts: 1899
Joined: 2015-4-09 @ 07:18

Re: Lets improve DOSBox Sound Blaster emulation

Postby James-F » 2016-9-08 @ 12:25

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/examples/hdl-inverse-sinc-filter.html?requestedDomain=www.mathworks.com
https://tomroelandts.com/articles/how-to-create-a-simple-low-pass-filter

Searching google for "FIR sinc filter c++" yield a lot of results.
User avatar
James-F
Oldbie
 
Posts: 1448
Joined: 2015-11-30 @ 04:10

Re: Lets improve DOSBox Sound Blaster emulation

Postby NewRisingSun » 2016-9-08 @ 18:14

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.
NewRisingSun
Oldbie
 
Posts: 852
Joined: 2005-9-02 @ 02:26

Re: Lets improve DOSBox Sound Blaster emulation

Postby James-F » 2016-9-08 @ 18:23

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.
User avatar
James-F
Oldbie
 
Posts: 1448
Joined: 2015-11-30 @ 04:10


Return to DOSBox Development

Who is online

Users browsing this forum: No registered users and 4 guests