VOGONS


Emulate PC Speaker with Soundcard

Topic actions

Reply 20 of 44, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Thanks for the nice pictures, neither option will be implemented any soon,
the "keep value" is of no use because OFF is zero and nothing else.

Reply 21 of 44, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author
Index: src/hardware/pcspeaker.cpp
===================================================================
RCS file: /cvsroot/dosbox/dosbox/src/hardware/pcspeaker.cpp,v
retrieving revision 1.24
diff -u -r1.24 pcspeaker.cpp
--- src/hardware/pcspeaker.cpp 15 Jul 2007 16:36:27 -0000 1.24
+++ src/hardware/pcspeaker.cpp 4 May 2009 06:49:01 -0000
@@ -305,15 +305,21 @@
if(spkr.chan) spkr.chan->AddSamples_m16(len,(Bit16s*)MixTemp);

//Turn off speaker after 10 seconds of idle or one second idle when in off mode
+ bool turnoff = false;
Bitu test_ticks = PIC_Ticks;
- if ((spkr.last_ticks+10000)<test_ticks) {
- spkr.last_ticks=0;
- if(spkr.chan) spkr.chan->Enable(false);
+ if ((spkr.last_ticks + 10000) < test_ticks) turnoff = true;
+ if((spkr.mode == SPKR_OFF) && ((spkr.last_ticks + 1000) < test_ticks)) turnoff = true;
+
+ if(turnoff){
+ if(spkr.volwant == 0) {
+ spkr.last_ticks = 0;
+ if(spkr.chan) spkr.chan->Enable(false);
+ } else {
+ if(spkr.volwant > 0) spkr.volwant--; else spkr.volwant++;
+
+ }
}
- if((spkr.mode == SPKR_OFF) && ((spkr.last_ticks+1000) <test_ticks)) {
- spkr.last_ticks=0;
- if(spkr.chan) spkr.chan->Enable(false);
- }
+
}
class PCSPEAKER:public Module_base {
private:

I had the decrement at SPKR_VOLUME/1000; but that gave a slight hum. This doesn't produce and audable sound.

There are sometimes very small clicks, but those aren't recorded so they don't come from the pcspeaker emulation.

The drawback is that turning off the pcspeaker takes 5 seconds this way.

Water flows down the stream
How to ask questions the smart way!

Reply 22 of 44, by Malignant Manor

User metadata
Rank Newbie
Rank
Newbie

The PC speaker emulation seems to cause clicking even in the Windows desktop when playing Wizardry 7. After applying the patch, I noticed a few clicks when alt-tabbing and it stopped occurring after a short period of time. Then I disabled the turnoff and the clicks occurred all the time when doubleclicking folders or text files.

This does not occur when I play .wav files directly though. This only happens after a sound effect is played in the game using PC speaker and persists until PC Speaker emulation is disabled or DOSBox is closed. Wizardry 7 is also screwy with sfx in general under DOSBox. (SFX other than PC Speaker sound horrible.) Do you have any suggestions on what I can try to change to fix the PC Speaker clicking with this game or any idea what is happening?

Reply 23 of 44, by Tsyu

User metadata
Rank Newbie
Rank
Newbie
Malignant Manor wrote:

The PC speaker emulation seems to cause clicking even in the Windows desktop when playing Wizardry 7. After applying the patch, I noticed a few clicks when alt-tabbing and it stopped occurring after a short period of time. Then I disabled the turnoff and the clicks occurred all the time when doubleclicking folders or text files.

This does not occur when I play .wav files directly though. This only happens after a sound effect is played in the game using PC speaker and persists until PC Speaker emulation is disabled or DOSBox is closed. Wizardry 7 is also screwy with sfx in general under DOSBox. (SFX other than PC Speaker sound horrible.) Do you have any suggestions on what I can try to change to fix the PC Speaker clicking with this game or any idea what is happening?

This has to do with the way the PC speaker emulation code handles silence. If you open the PC speaker output in a wave editor, you will see that the line representing the silence isn't centered until the speaker is shut off, and this is why you are experiencing those clicking sounds. Even with Qbix's patch, the silence isn't really centered until the speaker is deactivated. The only way to fix this would be to alter the code, perhaps even completely rewrite it (I don't really know C++ so I can't say for sure).

If you can't code, the only thing you can do is avoid switching to other programs while playing PC speaker games.

Reply 24 of 44, by Malignant Manor

User metadata
Rank Newbie
Rank
Newbie

The patch works for the Secret Agent game.

Just to clarify in case it is needed, the popping sounds in Wizardry 7 do not seem to be related to PC speaker emulation shutoff. PC speaker emulation causing the sound screw ups after a sound is played and switching to the Windows desktop happens no matter what game is tested. Of course, this wasn't an issue before because there was a 1 second delay before shutoff. With the patch, there is a 10 second delay, but that isn't a big deal.

Reply 25 of 44, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

so the "only" problem remaining would be the fact that the sound pops if you switch away from DOSBox ?
Just don't do that ?

Water flows down the stream
How to ask questions the smart way!

Reply 27 of 44, by Malignant Manor

User metadata
Rank Newbie
Rank
Newbie

so the "only" problem remaining would be the fact that the sound pops if you switch away from DOSBox ?
Just don't do that ?

Not for Wizardry 7. That game pops after every sfx but doesn't seem to be related to PC speaker emulation shutoff. All sfx options (SB, Adlib, etc) are mangled in DOSBox for that game or don't work. PC speaker emulation is the only one that sounds correct but with a popping issue. That patch should help a lot of other games though.

I think I remember DOSBox doing that to me before and I had to change both priority values in dosbox.conf to the same.

Thanks, priority "pause" when DOSBox isn't focused fixes the Windows desktop sfx issues when switching out of DOSBox and PC speaker emulation is on.

Edit: The forums didn't seem to want to add attachments or it needs a human to authorize.

Here is a sample of the sfx played through DOSBox, a door opening with Sound Blaster and PC speaker emulation. (Off the top of my head, this is the only game I own that I have problems with the sound emulation.)

Reply 28 of 44, by Tsyu

User metadata
Rank Newbie
Rank
Newbie

If you mute the FM channel in the DOSBox mixer, do you get sound in Wizardry 7 when the Sound Blaster option is enabled? I think the game may be using a trick to play sound effects on the OPL2 chip. I have another game that can do this, and the result is similar.

Reply 29 of 44, by Malignant Manor

User metadata
Rank Newbie
Rank
Newbie

Muting the FM channel mutes the SB sfx.

Reply 30 of 44, by BaldrNevari

User metadata
Rank Newbie
Rank
Newbie

I'm having difficultly implementing this patch. Where is this particular bit of code located?

Thanks.

Reply 31 of 44, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The file name is at the top of the patch's block, for the exact location check
the comments around the unchanged lines.

Reply 32 of 44, by BaldrNevari

User metadata
Rank Newbie
Rank
Newbie

*sigh*

All that work for nothing. The sound still pops at the beginning at end of each sound effect when using the PC Speaker, and the SB emu plays horrendously distorted sounds.

I have a feeling that because so few people play this game, a solution will most likely never be produced.

Reply 33 of 44, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Yeah could be.

Reply 34 of 44, by leileilol

User metadata
Rank l33t++
Rank
l33t++

Keen also sounds funny. It should sound more like this

apsosig.png
long live PCem

Reply 35 of 44, by HunterZ

User metadata
Rank l33t++
Rank
l33t++

I think that Metal Mutant by Silmarils also uses the same tricks as Wizardry 7 to try to use the OPL chip as a DAC. Since Metal Mutant doesn't let you choose your sound card, you probably have to disable SB emulation to force it to use PC speaker sound. I haven't tried playing it in DOSBox for a while so I'm not 100% sure.

Wiz7 didn't sound any better on the OPL than it did via the PC Speaker though, so figuring out why the clicks are happening in DOSBox would probably be a better idea than trying to figure out the OPL-as-DAC thing.

Reply 36 of 44, by ripa

User metadata
Rank Oldbie
Rank
Oldbie

I've made some modifications to dosbox's pc speaker emulation. Basically I just added a highpass filter, which makes the waveform look similar to what a real pc speaker outputs. Attached picture shows the difference. Top is vanilla dosbox 0.74, middle is dosbox-0.74 with my mod, bottom is a recording I nicked from another post in this thread. They aren't the exact same sounds, but you probably get the idea. I'll post more in the development section later. This might help with the popping issue.

In case the attached pic doesn't show up, here's a link:
http://i27.tinypic.com/2dqr61k.png

Reply 37 of 44, by jal

User metadata
Rank Oldbie
Rank
Oldbie
ripa wrote:

I've made some modifications to dosbox's pc speaker emulation.

Looks good. Did you contact the authors to see if it can be included in 0.75?

JAL

Reply 38 of 44, by ripa

User metadata
Rank Oldbie
Rank
Oldbie

Looks good. Did you contact the authors to see if it can be included in 0.75?

Not yet, but they read this forum.

I made a slight improvement (attachment: top dosbox, bottom real). Now there's a bit of overshoot in the "tail" (decay). A bit too much compared to the real thing. This hasn't fixed Wizardry 7's popping by the way. I'm trying to understand the pc speaker code to find out why. Anyone have a recording of Wizardry 7 on a real pc?

Reply 39 of 44, by Kippesoep

User metadata
Rank Oldbie
Rank
Oldbie

Do you think you could upload some WAV files to compare? I'm interested to hear what it sounds like.

My site: Ramblings on mostly tech stuff.