Sound Blaster Pro & 16
Sound Blaster Pro & 16
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. PCem:
6.5db separation. DOSBox:
14.2db separation.
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.
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. PCem:
6.5db separation. DOSBox:
14.2db separation.
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: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
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().
Re: Sound Blaster Pro & 16
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.
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: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
There isn't a separate parameter for OPL volume balancing at present. You'll have to add one yourself.
Re: Sound Blaster Pro & 16
Unfortunately I have zero experience with programming, so I'll leave it at that.
- SarahWalker
- Site Admin
- Posts: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
It's reasonably straightforward to add one. Change :
to :
YOUR_NUMBER_HERE should be between 0 and 65535, with 65535 being full volume.
Code: Select all
out_l = ((sb->opl.buffer[c] * mixer->fm_l) >> 16);
out_r = ((sb->opl.buffer[c + 1] * mixer->fm_r) >> 16);
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;
Re: Sound Blaster Pro & 16
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=6 ... 3&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 DOSBox
Delta: 40db PCem:
Delta: 6.74db
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=6 ... 3&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 DOSBox
Delta: 40db PCem:
Delta: 6.74db
Last edited by James-F on Fri 02 Jun, 2017 7:54 pm, edited 3 times in total.
Re: Sound Blaster Pro & 16
Hardware SBPro2 (hard panned RIGHT).
Delta: 16.68db 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.
Delta: 16.68db 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: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
For panning, PCem uses the following table to implement mixer attenuation :
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.
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
};
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: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
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.
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.
Re: Sound Blaster Pro & 16
SBPro and SB16 show the same poor panning abilities in PCem or 6db.What do you have the SB16 tone controls set to?
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.
Re: Sound Blaster Pro & 16
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. Now, the OPL is definitely much more filtered then the hardware.
I'll see what I can do.
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. Now, the OPL is definitely much more filtered then the hardware.
I'll see what I can do.
Re: Sound Blaster Pro & 16
Lo and behold, the SBPro2 is a simple 2nd order Butterworth at 3.2kHz which already lives in the code.
I only had to comment out the first order and change "NCoef 1" to "NCoef 2".
OPL next.
I only had to comment out the first order and change "NCoef 1" to "NCoef 2".
OPL next.
Re: Sound Blaster Pro & 16
Alright, I got the OPL filters fixed, and in balance to PCM.
I will upload a DIFF file as soon as possible. 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:
New:
I will upload a DIFF file as soon as possible. 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);
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);
Re: Sound Blaster Pro & 16
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).
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).
Re: Sound Blaster Pro & 16
OPL3 is not recognized by Doom in PCem.
Setting the environment parameter:
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
Setting the environment parameter:
Code: Select all
SET DMXOPTION=-opl3-phase
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.
Re: Sound Blaster Pro & 16
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.
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.
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
Notice that on the SBPro step 15 and 14 are the same.
Still, something is wrong with PCem mixer implementation.
Re: Sound Blaster Pro & 16
Mixer values more true to the hardware SB cards.
65535 is 0db and from there -2db each previous value.
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
Re: Sound Blaster Pro & 16
Nice work you are doing James-F! Thanks
- SarahWalker
- Site Admin
- Posts: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
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.
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.
Re: Sound Blaster Pro & 16
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.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.
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: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
Rev 744 fixes TEST-SBP.EXE.
Re: Sound Blaster Pro & 16
It is fixed only for the SB16, what about SBPro?
It's a SBP test software.
It's a SBP test software.
- SarahWalker
- Site Admin
- Posts: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
Rev 745 fixes SBCHECK.EXE.
- SarahWalker
- Site Admin
- Posts: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
It is fixed for the SB Pro...
Re: Sound Blaster Pro & 16
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.
* Every claim I make is after compilation and testing, just to be sure.
Re: Sound Blaster Pro & 16
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.
*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.
- SarahWalker
- Site Admin
- Posts: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
Whoops! Got the test backwards. Fixed in rev 747.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.
- SarahWalker
- Site Admin
- Posts: 2054
- Joined: Thu 24 Apr, 2014 4:18 pm
Re: Sound Blaster Pro & 16
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.
Re: Sound Blaster Pro & 16
Nope, still has the error.SarahWalker wrote: Whoops! Got the test backwards. Fixed in rev 747.
Also, it is important that the stereo issue is fixed because all the balancing I've done will be wrong once it's fixed.