Want to use PC Speaker and not Sound Blaster in StarControl 1

Here you can discuss the development of patches.

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripa » 2011-10-13 @ 22:27

Thank you very much for those recordings. I thought I there were problems with the emulation, but it's supposed to sound like that.

The silent noise in the menus is caused by the game setting the pc speaker output to a very high frequency (like 500 kHz). That frequency isn't audible directly, but I guess it causes distortion in the speaker which makes it slightly audible. Supaplex also does this between the notes of the music.

Currently, in Dosbox, there is protection against setting such a high frequency, because it wastes a huge amount of CPU time. In my patch the output is set high in such a case. Another solution is setting the frequency to some lower value, which makes the noise slightly audible.

edit: Nope and Atom were trivial to fix. They expect the PIT to have been programmed into some mode - they don't do it themselves. They switch the speaker output between PIT output (expecting it to be high) and forced low. Changing spkr.pit_output_level from 0 to 1 in the constructor fixes the demos.
ripa
Oldbie
 
Posts: 539
Joined: 2005-4-18 @ 00:53
Location: Finland

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripsaw8080 » 2011-10-13 @ 23:29

A similar situation can occur in official source because the timer is initially set to mode=3 cntr=1320, but the speaker state isn't set like it would be if the timer was programmed by port writes. So a few games fail to produce "standard" beeps because they don't mess with the timer at all. I've mentioned it to the devs, and I think their intention is to eventually do the initial programming of the timer in the emulated BIOS with port writes (like a real system BIOS would do for POST beeps), which will give the speaker its initial state as well.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4011
Joined: 2006-4-25 @ 23:24

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby h-a-l-9000 » 2011-10-14 @ 04:52

Code: Select all
// init the system timers
IO_WriteB(0x61, 0x00);
// timer 0: mode 3, 65536 ticks
IO_WriteB(0x43, 0x36); IO_WriteB(0x40, 0x0); IO_WriteB(0x40, 0x0);
// timer 1: mode 2, low byte only, 117 ticks (memory refresh)
IO_WriteB(0x43, 0x54); IO_WriteB(0x41, 0x75);
// timer 2: mode 3, 1320 ticks (from the POST beep)
IO_WriteB(0x43, 0xb6); IO_WriteB(0x42, 0x28); IO_WriteB(0x42, 0x5);
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby robertmo » 2011-10-14 @ 09:41

By the way, it looks ZZT has working footsteps sfx now (I haven't checked other similar games like Kroz, Castle Adventure, and Caves of Thor but I guess they might have similar problem that may be fixed now too).


I checked the silent sound in Supaplex and it doesn't look like sound rather like a noise.

I also checked Race Driving' (looks like it is Hard Drivin' III). This game also has silent sounds. It has more sound cards support and even pc speaker sounds are better quality so it is possible to recognize that after clicking the mouse you hear starting the engine. (You don't hear it with adlib or roland, and sound blaster doesn't work in this game). So the engine cannot be heard before as it wasn't started yet :) This game has silent sounds before and after starting the engine and during driving.

There are some problems in Tandy sound mode in dosbox. Hard to say how should it be as I don't have real Tandy computer. The I guess silent sound can be heard and it doesn't sound good as it breaks after you leave the road and doesn't fix when you come back to road. So I guess Tandy sound is not properly emulated, as I guess we shouldn't be able to hear that sound too in Tandy mode. (Although the breaking sound when leaving the road Is somewhat ok as it happens with Roland and Adlib too). However you hear the "broken" sound even before starting the engine. So I don't know what to think about it. Checking on real Tandy PC would be needed I guess.
User avatar
robertmo
l33t
 
Posts: 4111
Joined: 2003-6-18 @ 10:35


Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripa » 2011-10-14 @ 22:18

Good news: I found a bug in my mode 1 implementation, which caused Wizball and Perestroika's whine to be too audible. With the correction, the whine is much higher in frequency, and so less audible, and easier to remove by filtering (once I implement the filter, that is).

Bad news: I looked into how The 3 Stooges generates (tries to generate) sound and I'm baffled. 3 Stooges uses PIT mode 1 for speaker output like Star Control. PIT mode 1 works so that once the mode is set, output goes high immediately. Then the application can write a counter value to the PIT, which doesn't affect the output yet. To change the output, the application can toggle the PIT gate input from low to high ("trigger"), which causes the PIT to output a low pulse whose length is determined by the counter which was previously written. When the pulse is over, output goes high again. If the application causes another trigger while the low pulse is ongoing, the pulse is lenghtened by the current counter value.

3 Stooges triggers the PIT every 31 microseconds (~32kHz). However, the counter values it writes to the PIT are much longer than 31 microseconds (usually over 100 microseconds). This means that due to the constant retriggering, the speaker output stays low all the time --> no sound.
ripa
Oldbie
 
Posts: 539
Joined: 2005-4-18 @ 00:53
Location: Finland

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripsaw8080 » 2011-10-14 @ 23:21

Like Atom and Nope, EGA Battle Chess is also fixed by setting the initial speaker state.

Will Harvey's Music Construction Set: 1-voice output is fine, but 4-voice output is silent with the patch. 4-voice output works in official source, but volume has to be way up to hear it. Setting the initial speaker state doesn't help; and playing with 1-voice output before switching to 4-voice output also doesn't help.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4011
Joined: 2006-4-25 @ 23:24

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby robertmo » 2011-10-15 @ 13:13

I think it may be useful to notice that 3 stooges is also working with dosbox modified by ripsaw from this thread viewtopic.php?p=163331
But sfx are very silent compared to music (unlike other Cinemaware games working with ripsaw's modification)
BTW 3 stooges needs cycles about 300 for sfx not to play too fast.

ripa could you post your latest version so we could check it?
User avatar
robertmo
l33t
 
Posts: 4111
Joined: 2003-6-18 @ 10:35

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripa » 2011-10-15 @ 18:12

300 cycles explains why 3 Stooges was quiet. I was experimenting at 3000 cycles ("You idiots!").

I've attached the third revision. It fixes Nope and Atom demos, reduces whine in Wizball and Perestroika, and fixes The Three Stooges speech (normal core, cycles < 1000).

What's next:
- look at Battle Bugs and Will Harvey's Music Construction Set
- implementing proper filtering
- refactoring the pc speaker code

@leileilol:
Thanks for that video. It confirms that the emulated motor sound in HD2 is now correct.
You do not have the required permissions to view the files attached to this post.
ripa
Oldbie
 
Posts: 539
Joined: 2005-4-18 @ 00:53
Location: Finland

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripsaw8080 » 2011-10-15 @ 19:10

MCS appears to be fixed by your latest changes, and the volume of the 4-voice output is good, so no need to look at it now.

What was it that fixed 3 Stooges?
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4011
Joined: 2006-4-25 @ 23:24

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripa » 2011-10-15 @ 19:23

What was it that fixed 3 Stooges?

My initial implementation of mode 1 (that worked in StarCon 1) was incomplete/buggy. It didn't generate some (every other or so) low pulses it was supposed to. Same thing caused louder whine in Wizball and Perestroika.
ripa
Oldbie
 
Posts: 539
Joined: 2005-4-18 @ 00:53
Location: Finland

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby h-a-l-9000 » 2011-10-15 @ 19:32

Have to tell you that I currently attempt to rewrite the system timer, so the interface to the pcspeaker code may change if it works out.
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripsaw8080 » 2011-10-15 @ 20:06

The Bach Invention in MCS seems to lose some fast notes with 4-voice output; sounds like clicks instead of tones. Don't know if it's accurate or not, but the program is actually pretty good at adapting to system speed, so perhaps robertmo can compare to hardware.

Battle Bugs produces some speaker sounds, but the mission briefings sound like soft white noise instead of the speech you hear with other digitized sound options. Not sure if it's wrong or not, but I've read comments that there should be speech.

When experimenting with filtering, Bad Cat seems like a good test case; the digitized music in its credits screen has a lot of high frequency noise.
User avatar
ripsaw8080
DOSBox Author
 
Posts: 4011
Joined: 2006-4-25 @ 23:24

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripa » 2011-10-16 @ 07:21

Have to tell you that I currently attempt to rewrite the system timer, so the interface to the pcspeaker code may change if it works out.

What kind of a plan do you have for the rewrite? Currently, the speaker code duplicates a large amount of PIT functionality. If it's possible to have the PIT code notify the speaker code whenever the PIT channel 2 output changes, all of the duplicate functionality in the speaker code could be removed. Something like:

timer.cpp:
// PIT output changes
PCSpeaker_PIT_Output_Change(new_output_level);
ripa
Oldbie
 
Posts: 539
Joined: 2005-4-18 @ 00:53
Location: Finland

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby robertmo » 2011-10-16 @ 07:48

the slow one is done this way:
i start mcs first, than i turn off turbo so that everything is slower.
If i do it the other way: turn off turbo first and later start mcs speed will be normal.

BTW lowering dosbox cycles after starting mcs doesn't give similar results as switching turbo off i think.
You do not have the required permissions to view the files attached to this post.
User avatar
robertmo
l33t
 
Posts: 4111
Joined: 2003-6-18 @ 10:35

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby robertmo » 2011-10-16 @ 08:55

perestroika_title
You do not have the required permissions to view the files attached to this post.
User avatar
robertmo
l33t
 
Posts: 4111
Joined: 2003-6-18 @ 10:35

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby robertmo » 2011-10-16 @ 09:40

In battle bugs it is not just briefing speech that is broken but all game's sfx including click confirmation.
User avatar
robertmo
l33t
 
Posts: 4111
Joined: 2003-6-18 @ 10:35

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby h-a-l-9000 » 2011-10-16 @ 10:52

What kind of a plan do you have for the rewrite?


I'm thinking of this:

timer code calls a c function or class function with the type of output waveform (defined ints) and number of timer ticks (n):

- go and/or stay high
- go and/or stay low
- go low for 1 tick after n ticks
- go low for n ticks then high
- go high after n ticks
- repeatedly go low for 1 tick after n ticks
- (used with the above) change tick rate after the next low pulse
- generate square wave using n ticks (the n+1 / n-1 thing is handled by the pcspeaker code if at all), starting high
- (used with the above) change tick rate after the next output toggle

The current waveform can always be interupted by the next call.
1+1=10
h-a-l-9000
DOSBox Author
 
Posts: 4512
Joined: 2005-2-23 @ 00:14

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby jomalin » 2011-10-25 @ 21:17

ripa wrote:300 cycles explains why 3 Stooges was quiet. I was experimenting at 3000 cycles ("You idiots!").

I've attached the third revision. It fixes Nope and Atom demos, reduces whine in Wizball and Perestroika, and fixes The Three Stooges speech (normal core, cycles < 1000).

What's next:
- look at Battle Bugs and Will Harvey's Music Construction Set
- implementing proper filtering
- refactoring the pc speaker code

@leileilol:
Thanks for that video. It confirms that the emulated motor sound in HD2 is now correct.


NOTE FOR NOT DEVELOPERS: The exe file you provide requires some dll files to run. Installing Microsoft Visual C++ 2010 Redistributable Package (x86) will solve that.
jomalin
Newbie
 
Posts: 58
Joined: 2010-12-14 @ 11:42

Re: Want to use PC Speaker and not Sound Blaster in StarControl 1

Postby ripa » 2011-10-29 @ 15:49

I implemented better interpolation/filtering. Now Hard Drivin' 2 intro sounds pretty good. Perestroika intro also sounds almost exactly the same as the real thing. The improvement is mostly audible in games that use the PC speaker for outputing digitized sound.

If you can hear a high-pitched whine in such games, you can get rid of it by using a lower pcrate in dosbox.conf (16000 for Wizball for example, 32000 for StarCon2 and Perestroika - you should also lower mixer rate to match).

There are some lingering issues. First of all, when playing, you might hear slight crackling. However, if you capture the sound with Ctrl+F6, you can't hear it in the captured version. This leads me to believe that the callback with the new filtering takes too long to execute sometimes.

The second issue is that for speed reasons, I had to use a lookup table for the filtering, instead of evaluating the "impulse" function directly. This leads to worse sound quality compared to the reference implementation that doesn't use the lookup table. Also, there's some hidden bug in the lookup implementation, because if I increase the lookup table size to increase quality, it breaks completely.

The final issue is that the mixer sometimes request more samples that I expect it to. There's a hack for that, but it results in a couple of "too many samples" prints when you start up dosbox. The pc speaker code assumes that the mixer callback is called every emulated millisecond. I don't know how the mixer works, so I don't know if that assumption is correct.

NOTE FOR NOT DEVELOPERS: The exe file you provide requires some dll files to run. Installing Microsoft Visual C++ 2010 Redistributable Package (x86) will solve that.

I tried building a version that doesn't require the user to install a new version of MSVCRT, but it didn't work. I wonder how the official Dosbox build gets around that...
You do not have the required permissions to view the files attached to this post.
ripa
Oldbie
 
Posts: 539
Joined: 2005-4-18 @ 00:53
Location: Finland

PreviousNext

Return to DOSBox Patches

Who is online

Users browsing this forum: Evert and 3 guests