Sound Blaster Pro & 16

Support and general discussion.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Sound Blaster Pro & 16

Postby James-F » Wed 31 May, 2017 11:29 am

EDIT: All posts about stereo separation problems should be ignored, I was using the wrong OpenAL32.dll

I mainly will be running PCem with DOS configuration and SBPro or SB16 cards, so it is important that these cards emulation is accurate.

I am a long time Vogons member and done a lot of research with the real SBPro and SB16 cards on Vogons and know exactly how they behave in terms of Stereo functionality and OPL3 behavior.
Let me start by a short list of problems I immediately noticed that differ form the real cards and DOSBox.

1. The OPL volume is much louder than with the real cards and in DOSBox, I actually helped Qbix (dosbox dev) to fine tune the OPL to PCM volume to match exactly the real hardware creative cards.
2. Stereo separation is very poor. SBPro and SB16 should pan hard left and right when the mixer calls for it.

In dosbox with SBPro2 there is 14db of separation between left and right when hard panned, but in PCem there is only 7db.

Hardware SBPro2:
17.4db separation.
Hardware SBPro2.jpg
Hardware SBPro2.jpg (13.34 KiB) Viewed 1937 times

PCem:
6.5db separation.
PCem.jpg
PCem.jpg (13.31 KiB) Viewed 1941 times

DOSBox:
14.2db separation.
DOSBOX.jpg
DOSBOX.jpg (13.92 KiB) Viewed 1941 times



Moreover, the test tone I use is pure sine wave played using MPXPlay in DOS, so when I analyze it with a spectrum analyzer I can see that PCem has much greater harmonic content (distortion) than DOSBox or hardware.

Where can I find the OPL global volume in the source code?
I will try to fix that first to match the real hardware SBPro/SB16 cards.
Last edited by James-F on Sat 03 Jun, 2017 11:20 am, edited 2 times in total.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Wed 31 May, 2017 4:42 pm

There isn't a global volume control as such. OPL is mixed in in sound_sb.c, there are three functions - sb_get_buffer_opl2(), sb_get_buffer_opl3() and sb_get_buffer_emu8k().
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Wed 31 May, 2017 5:12 pm

Hi and thanks.
I don't seem to find the right parameter to lower the OPL volume.
Can you please be more specific which one?

This volume adjustment should not be part of the mixer parameters that a game/windows can change.
For example, with both Voice and FM mixer volume at max (16) the FM should be slightly quieter than it is now.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Wed 31 May, 2017 6:17 pm

There isn't a separate parameter for OPL volume balancing at present. You'll have to add one yourself.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Wed 31 May, 2017 6:20 pm

Unfortunately I have zero experience with programming, so I'll leave it at that.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Wed 31 May, 2017 9:11 pm

It's reasonably straightforward to add one. Change :

Code: Select all

out_l = ((sb->opl.buffer[c]     * mixer->fm_l) >> 16);
out_r = ((sb->opl.buffer[c + 1] * mixer->fm_r) >> 16);

to :

Code: Select all

out_l = ((((sb->opl.buffer[c]     * mixer->fm_l) >> 16) * YOUR_NUMBER_HERE) >> 16;
out_r = ((((sb->opl.buffer[c + 1] * mixer->fm_r) >> 16) * YOUR_NUMBER_HERE) >> 16;

YOUR_NUMBER_HERE should be between 0 and 65535, with 65535 being full volume.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Thu 01 Jun, 2017 5:58 am

Thank you very much!
The fixed line has one too many parentheses in the beginning, so it didn't compile at first...

I have measured many DOS ISA cards including the original SB1.5, SB2.0, SBPro2 and SB16 which I own.
http://www.vogons.org/viewtopic.php?f=62&t=49683&start=40
After tens of compilations the resulting golden number is 36000 for both the OPL2 and OPL3, with lowpass filters on.
This will give a true to hardware FM to PCM volume ratio.

BUT, these is a problem with the stereo separation in PCem and not only with the SBPro2 but SB16 also.
There is too much bleed between the channels, which results in only 6db separation with hard panning, this is considered very poor separation.

Hardware SB16
Delta: 38.08db
hardware sb16 pan.jpg
hardware sb16 pan.jpg (182.24 KiB) Viewed 1829 times


DOSBox
Delta: 40db
dosbox sb16 pan.jpg
dosbox sb16 pan.jpg (181.28 KiB) Viewed 1829 times


PCem:
Delta: 6.74db :?:
PCem sb16 pan.jpg
PCem sb16 pan.jpg (183.58 KiB) Viewed 1829 times
Last edited by James-F on Fri 02 Jun, 2017 7:54 pm, edited 3 times in total.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Thu 01 Jun, 2017 6:08 am

Hardware SBPro2 (hard panned RIGHT).
Delta: 16.68db
hardware SBPro pan.jpg
hardware SBPro pan.jpg (78.38 KiB) Viewed 1824 times


Yes, the SBPro1 and SBPro2 (they behave the same) are actually reversed to the SB16, but DOSBox and PCem go it wrong, the channel emulation behaves like the SB16.
That too we researched on Vogons: http://www.vogons.org/viewtopic.php?f=46&t=50539

Considering Filtering.

The PCem emulated SB1.x/2.0/SBPro card is filtered way too much compared to the real card, I can tweak the lowpass filter to match the real card using frequency analyzer.
Moreover, the OPL3 is NOT filtered at all on the SB16 card but I hear some permanent heavy lowpass filtering on it no matter what card I select.
The filtering on the OPL is also too heavy compared to the real SB1/2/SBPro cards, which does have a permanent OPL filtering but not that heavy like in PCem.

Can you please point me to the lowpass filtering section of SBPro and OPL in the code so I can teak the slope and frequency?
But again, there is a major problem with stereo separation so these tweaks including the OPL volume should be redone once you fix the stereo issue.
Thanks.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Thu 01 Jun, 2017 3:42 pm

For panning, PCem uses the following table to implement mixer attenuation :

Code: Select all

static int sb_att[]=
{
        310,368,437,520,618,735,873,1038,1234,1467,1743,2072,2463,2927,3479,
        4134,4914,5840,6941,8250,9805,11653,13850,16461,19564,23252,27635,32845,
        39036,46395,55140,65535
};

The SB16 mixer get programmed with left & right volumes between 0-255. PCem divides by 8, to give a 0-31 range, then looks up in the attenuation table. Assuming my maths are correct, this should give a 23.25dB delta when hard panning - less than real hardware, but still miles from the 6.74 you've measured. I'm not entirely sure why this is...

SB Pro uses 3 bits for left & right volumes, between 0-7. PCem boosts that to 17-31, which should result in a 10.5dB delta.

What do you have the SB16 tone controls set to? PCem does a fairly bad attempt at emulating them, which may be throwing out the results. The tone filters are disabled when bass & treble are set to exactly the middle.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Thu 01 Jun, 2017 3:49 pm

The SB digital filter is in filter.h, the function sb_iir(). I used Winfilter (http://www.winfilter.20m.com/) to get the coefficients, it's currently a Butterworth first order IIR filter, sample rate 48 kHz, fc=3.2 khz. Feel free to come up with something better!

The OPL filter is in sound_opl.c, opl2_update2() and opl3_update2(). It's pretty awful so if you come up with something a bit more accurate, send it my way and I'll implement it.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Thu 01 Jun, 2017 4:23 pm

What do you have the SB16 tone controls set to?

SBPro and SB16 show the same poor panning abilities in PCem or 6db.
I didn't install the drives for SB16, but SBPro doesn't have bass/treble controls nor does it needs drivers.

I do have sbp-set.exe which is the official mixer prog for the SBPro to test stuff.
I can test the db ratio of the 0-15 steps of the mixer.
BUT, the pan I use is not from the mixer but from the DSP, I plays a 440Hz mono wav and pan the samples left and right.

EDIT:
Yep, it's the mixer misbehaving.
With the hardware a balance of Master:0,15 turns the left channel completely off, but in PCem it is 6db difference.


Thanks for the filter information, I'll see if I can do something. Don't get your hopes high. :oops:
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Thu 01 Jun, 2017 7:49 pm

I'm really impressed, you actually got very close to the real SBPro2 filter!
The SB hardware programming guide actually calls for 3.2kHz of the output filter.
I think it is okay as it is because the SB2.0 is slightly less filtered, so it's a good balance.
Lowpass.jpg
Lowpass.jpg (88.24 KiB) Viewed 1756 times


Now, the OPL is definitely much more filtered then the hardware.
I'll see what I can do.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Thu 01 Jun, 2017 9:16 pm

Lo and behold, the SBPro2 is a simple 2nd order Butterworth at 3.2kHz which already lives in the code. :lol:
I only had to comment out the first order and change "NCoef 1" to "NCoef 2".

Lowpass 2nd.jpg
Lowpass 2nd.jpg (88.01 KiB) Viewed 1743 times


OPL next.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Thu 01 Jun, 2017 10:07 pm

Alright, I got the OPL filters fixed, and in balance to PCM.
I will upload a DIFF file as soon as possible.
OPL3 fixed.jpg
OPL3 fixed.jpg (97.82 KiB) Viewed 1737 times


I had to completely remove the filtering to match the SBPro OPL3 sound;
I also lowered the division number from 4 to 2 to boost the volume after removing the filter, and tweaked sound_sb.c to fix the balance.

Old:

Code: Select all

opl->filtbuf[0] = opl->buffer[opl->pos*2]   = (opl->buffer[opl->pos*2]   / 4) + ((opl->filtbuf[0] * 1) / 16);
opl->filtbuf[1] = opl->buffer[opl->pos*2+1] = (opl->buffer[opl->pos*2+1] / 4) + ((opl->filtbuf[1] * 1) / 16);


New:

Code: Select all

opl->filtbuf[0] = opl->buffer[opl->pos*2]   = (opl->buffer[opl->pos*2]   / 2);
opl->filtbuf[1] = opl->buffer[opl->pos*2+1] = (opl->buffer[opl->pos*2+1] / 2);
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Fri 02 Jun, 2017 6:00 am

Patch is up: https://www.sendspace.com/file/ya2spw

Sounds virtually indistinguishable from the hardware SBPro2 now that the filters match and volume balanced between FM/PCM.

The SB16 is another story altogether because it has frequency dependent FIR Rectangle steep filter, a "Brick Wall" filter.
That also can be created using WinFilter but only for one specific frequency, the SB16 dynamically changes the cut frequency according to half the requested by software sampling rate.

The stereo issue has to fixed asap because is affect all the sound cards operation, not only SBPro.
So balancing should be redone after the stereo fix.
PS. There is no stereo bug in 86Box (PCem-x).
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Fri 02 Jun, 2017 6:37 am

OPL3 is not recognized by Doom in PCem.

Setting the environment parameter:

Code: Select all

SET DMXOPTION=-opl3-phase

should enable OPL3 in Doom, that should be heard immediately when starting the game, but Doom will not switch to OPL3 mode.
It works fine in DOSBox or with real hardware, but not in PCem.

Moreover, the SBPro is not recognized by the official Creative TEST-SBP.EXE software, and SBCHECK.EXE reports ESS instead SBPro.
I assume there is no access to the IRQ?
https://www.sendspace.com/file/5b1cze
Last edited by James-F on Fri 02 Jun, 2017 10:03 am, edited 1 time in total.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Fri 02 Jun, 2017 9:49 am

Hardware Mixer chip behavior.
This is true for MASTER, VOC and FM.
Blank line means same value as before, ie; 02 and 03 are the same for the SBPro.
15,15 is normalized to 0db.

Code: Select all

Mixer   SBPro2   SB16

00,15   -48.5   -57.5
01,15           -54.8
02,15   -27.3   -51.0
03,15           -47.2
04,15   -21.5   -43.2
05,15           -39.6
06,15   -15.7   -35.6
07,15           -32.0
08,15   -11.0   -28.0
09,15           -24.0
10,15   -7.0    -20.0
11,15           -16.0
12,15   -3.0    -12.0
13,15           -8.0
14,15   0       -4.0
15,15   0        0


This is almost exactly to specification in the SB hardware programing guide, -4db steps from full scale to zero.
Notice that on the SBPro step 15 and 14 are the same.

Still, something is wrong with PCem mixer implementation.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Fri 02 Jun, 2017 4:00 pm

Mixer values more true to the hardware SB cards.
65535 is 0db and from there -2db each previous value.

Code: Select all

        50,65,82,103,130,164,207,260,328,413,520,655,825,1038,1307,
        1645,2072,2608,3283,4134,5205,6553,8250,10385,13075,16461,20724,26089,
        32845,41349,52055,65535
User avatar
omarsis81
Posts: 543
Joined: Thu 17 Dec, 2015 6:20 pm

Re: Sound Blaster Pro & 16

Postby omarsis81 » Fri 02 Jun, 2017 5:13 pm

Nice work you are doing James-F! Thanks
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Fri 02 Jun, 2017 7:03 pm

Committed your changes so far at rev 743. I'll have look into the SB Pro detection stuff.

For the SB16, it may be possible to generate the filters on the fly. If you can let me know what parameters to use I can have a go at that.

I'll also look into the stereo separation issue. I'm guessing that it might be an OpenAL problem.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Fri 02 Jun, 2017 7:51 pm

SarahWalker wrote:For the SB16, it may be possible to generate the filters on the fly. If you can let me know what parameters to use I can have a go at that.

The software sends a request to change sampling rate for the SB16 DSP, half that and you get the Cut frequency for the FIR filter.
General example: A game requests 11kHz sampling rate, the SB16/AWE32 will apply a brickwall (FIR) filter at 5.5kHz.
Sounds completely different that the simple passive filtering of previous SB cards.

In fact, all modern sound cards and DACs use very steep brickwall FIR filtering to eliminate aliasing, nyquist theorem etc..
Compact Disc standard use that too, the sampling rate is 44100Hz but the audible range is exactly half of that; from 20kHz to 22kHz (mere 2kHz range) there is an extreme drop from 0db to -96db.
The SB16 is one of the first (if not the) PC sound cards to implement this.
Last edited by James-F on Fri 02 Jun, 2017 8:01 pm, edited 1 time in total.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Fri 02 Jun, 2017 7:56 pm

Rev 744 fixes TEST-SBP.EXE.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Fri 02 Jun, 2017 8:21 pm

It is fixed only for the SB16, what about SBPro?
It's a SBP test software.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Fri 02 Jun, 2017 8:29 pm

Rev 745 fixes SBCHECK.EXE.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Fri 02 Jun, 2017 8:29 pm

It is fixed for the SB Pro...
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Sat 03 Jun, 2017 5:51 am

SBPro still doesn't pass TEST-SBP.EXE (dev 746), it only passes with SB16.
* Every claim I make is after compilation and testing, just to be sure. ;)
Still.jpg
Still.jpg (102.52 KiB) Viewed 1427 times
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Sat 03 Jun, 2017 6:57 am

OPL core comparison.
*PCem has the same core as DOSBox (compat).

Sarah, I don't understand why PCem (and dosbox) stuck with the old and inaccurate OPL cores when NukedOPL is 1:1 with the hardware.
I strongly suggest including NukedOPL in PCem and using it as the default.

Nuked.jpg
Nuked.jpg (109.42 KiB) Viewed 1416 times

PCem.jpg
PCem.jpg (105.91 KiB) Viewed 1416 times

DB fast.jpg
DB fast.jpg (120.45 KiB) Viewed 1416 times
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Sat 03 Jun, 2017 7:05 am

James-F wrote:SBPro still doesn't pass TEST-SBP.EXE (dev 746), it only passes with SB16.
* Every claim I make is after compilation and testing, just to be sure. ;)

Whoops! Got the test backwards. Fixed in rev 747.
SarahWalker
Site Admin
Posts: 1326
Joined: Thu 24 Apr, 2014 4:18 pm

Re: Sound Blaster Pro & 16

Postby SarahWalker » Sat 03 Jun, 2017 7:06 am

I was only made aware of NukedOPL just before the last PCem release, and it was at a point where I didn't want to make any more major changes. It's on my list for v13.
User avatar
James-F
Posts: 69
Joined: Tue 30 May, 2017 10:26 am

Re: Sound Blaster Pro & 16

Postby James-F » Sat 03 Jun, 2017 7:49 am

SarahWalker wrote:Whoops! Got the test backwards. Fixed in rev 747.

Nope, still has the error.

Also, it is important that the stereo issue is fixed because all the balancing I've done will be wrong once it's fixed.

Return to “General”

Who is online

Users browsing this forum: No registered users and 4 guests