Baron of Hell
Register | User Profile | Member List | F.A.Q | Privacy Policy | New Blog | Search Forums | Forums Home
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > PC speaker sound question
 
Author
All times are GMT. The time now is 16:32. Post New Thread    Post A Reply
Gez
Why don't I have a custom title by now?!


Posts: 10995
Registered: 07-07


I have looked a bit into it and found something interesting. However, there's something I'm curious about and which I didn't find in fraggle & andrewj's reverse-engineered specs: what is precisely the formula to derive frequency from counter value?

It seems to be that frequency = 1193170 / counter, but I'm not really sure about that. The first value corresponds exactly to 1193150 / counter and xx50 and it seems to give the smallest maximal deviation from the frequencies that are listed in the specs, though xx70 is closer to the average value.

Old Post 01-24-14 19:01 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
entryway
Forum Staple


Posts: 2711
Registered: 01-04


I don't understand the question. What are counter values? Do you mean value column from the Talk:PC_speaker_sound_effects page? These values are already frequencies, but not very precise.

440*(2^((194-Pos-98)/24)) is correct formula for same indexes.

Last edited by entryway on 01-24-14 at 21:38

Old Post 01-24-14 21:15 #
entryway is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10995
Registered: 07-07



entryway said:
I don't understand the question. What are counter values? Do you mean value column from the Talk:PC_speaker_sound_effects page?

Yeah, it's what was sent to the Intel 8523 counter.


code:
This table specifies the frequency for values in PC speaker sound effects. The value is given along with the corresponding output frequency and the precise counter value which should be programmed into the 8253 timer chip found in PCs to give this frequency.






entryway said:
440*(2^((194-Pos-98)/24)) is correct formula for same indexes.


(194-Pos-98)? Is that 96-Pos ((194-Pos)-98), or 292-Pos (194-(Pos-98))?



Basically what I want to do is generate PCM data to convert Doom's PC speaker sounds into RIFF-WAV sounds.

Old Post 01-24-14 21:55 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
entryway
Forum Staple


Posts: 2711
Registered: 01-04


I extended f=440*(2^((n-49)/12)) formula for 24 notes per octave f=440*(2^((n-98)/24)) and 'fix' it for indexes form 'talk' page.

Old Post 01-24-14 22:10 #
entryway is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
fraggle
Filled with the code of Doom


Posts: 7483
Registered: 07-00


Main thing to realise is that it's a musical scale. The chromatic scale used in western music has 12 tones, and the PC speaker format uses 24 (twice the "detail"). 440Hz is 'A'. Hence entryway's equations.

Old Post 01-25-14 01:08 #
fraggle is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10995
Registered: 07-07


Turns out that RIFF-WAV files don't work right at 140 hz. (At least not with the lib I use for playback.) I had to multiply each speaker data byte by some arbitrary large value to obtain the notes I was supposed to get. (I chose 315 because 140x315=44100.) With this increased sample rate, the formula I saw everywhere of sin(2 * PI * sample_num * frequency / sample_rate) does work.

Old Post 01-25-14 01:14 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
printz
CRAZY DUMB ZEALOT


Posts: 8780
Registered: 06-06


If you do make the WAV files, please filter them a bit so they're easier on the ear.

__________________
Automatic Wolfenstein - Version 1.0 - also on Android

Old Post 01-25-14 07:45 #
printz is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10995
Registered: 07-07


Adding filters would be completely overkill for my purposes, which were simply to add playback for this format in SLADE 3.

Which is in, as of devbuild b3-150. It's not perfect, but it's good enough for me.

Old Post 01-25-14 17:53 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Maes
I like big butts!


Posts: 12261
Registered: 07-06


There's already "PC Speaker to WAVE" code in Chocolate Doom and Mocha Doom, if you want to make your life a bit easier. The PC speaker sound are essentially sequences of fixed-length,fixed-volume, variable-frequency tones.

Once you figure out the correct frequency however, you can substitute square waves of a given frequency with sine or triangle waves, if you want a smoother or cheesier effect. Of course you need to generate tones that will have the correct duration at the target sample rate. tThere are 140 tones per second, so you have to divide the target sample rate (e.g. 44100/140) in order to find out how long each tone should be.

Of course, the frequency you must generate must be adapted to the sample frequency, too. If the PC speaker instructions tell you to play a 100 Hz tone at some point, said tone will be different at a sample rate of 11025, 22050 and 44100 Hz.

Old Post 01-26-14 01:47 #
Maes is online now Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Quasar
Moderator


Posts: 5962
Registered: 08-00


I believe he wanted to make sure that code was entirely accurate, and we have found through reverse engineering that it isn't, 100%.

There should be 128 values in the pitch table, mainly. Those values may not be used by any of the stock PC speaker SFX, but I assume by supporting this, SLADE intends to allow new ones to be created which should sound like they sound under DMX playback.

I'd encourage fraggle to update Choco's support with the newly discovered information.

Old Post 01-27-14 15:53 #
Quasar is offline Profile || Blog || PM || Email || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10995
Registered: 07-07


I'm not sure if allowing to create new PC speaker sounds is really pertinent (I don't expect that many people to actually use it), but I wanted to get playback for those that exist. What I got sounds close enough that I'm happy leaving it in that state, but is still a bit off. Maybe it'd be closer if I used a table of frequencies instead of the table of integer values I found in the exe.

Old Post 01-27-14 16:30 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10995
Registered: 07-07


I think I've found the answer to my original question here.
code:
frequency = 1193181 / value

The magic number is probably 1193181.

Old Post 02-08-14 21:06 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
printz
CRAZY DUMB ZEALOT


Posts: 8780
Registered: 06-06


Awesome! By the way, does Wolfenstein use the same format as Doom?

__________________
Automatic Wolfenstein - Version 1.0 - also on Android

Old Post 02-09-14 07:11 #
printz is offline Profile || Blog || PM || Homepage || Search || Add Buddy IP || Edit/Delete || Quote
Gez
Why don't I have a custom title by now?!


Posts: 10995
Registered: 07-07


No, based on what they say on the shikadi.net wiki, Wolf stores the inverse frequency data directly, but divided by 60 to fit into a syngle byte. So for Doom:
code:
frequency = 1193181 / freqs[byte value]

And for Wolfenstein 3D:
code:
frequency = 1193181 / (60 * byte value)

Old Post 02-09-14 07:31 #
Gez is online now Profile || Blog || PM || Search || Add Buddy IP || Edit/Delete || Quote
All times are GMT. The time now is 16:32. Post New Thread    Post A Reply
 
Doomworld Forums : Powered by vBulletin version 2.2.5 Doomworld Forums > Classic Doom > Source Ports > PC speaker sound question

Show Printable Version | Email this Page | Subscribe to this Thread

 

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are OFF
[IMG] code is ON
 

< Contact Us - Doomworld >

Powered by: vBulletin Version 2.2.5
Copyright ©2000, 2001, Jelsoft Enterprises Limited.