First post, by vladstamate
- Rank
- Oldbie
Hi all, I know a lot about computer software but sound emulation (and sound basics) is one area that I am not ashamed to admit I do not know as much. I know there are a few people here that understand way better than me how this works (like gdjacobs, Scali, Jepael, reenigne, superfury and others) so I have a few questions.
Lets take the simple PC speaker for example. The 8253 channel 2 can be set to have a certain frequency by loading the reload value with a number. So the frequency would be (1.192Mhz/number) which gives us some Hertz. Whenever the channel 2 line goes high the speaker moves in one direction and whenever it goes low the speaker moves in another dimension, therefore creating sound. Am I understanding this correctly?
Now the first part I do not understand is how do I go from that to emulating the sound using a digital sound card which wants a stream of numbers (is that PCM?)? SDL (which is what I am using) is for now set up to accept a buffer of uint8_t values (so 8bit unsigned values) to talk to my host sound card and produce sound. What is the equivalence between the speaker moving at a certain frequency (all I have is I can sample the 8253 and that can give me a count and the frequency itself, basically where in the duty cycle of the wave I am) and the 8bit values in my sound buffer? Those 8 bit values are not frequencies (I gather) but rather "loudness" right? So a value of 0 in SDL should mean silent but 255 means loudest? This is the part where I get lost...
If I set my host sound card to accept (generate) sound at say 44Khz does that mean I need to sample the 8253 at a frequency of 44Khz? If yes what do I do with the value I see in 8253 channel 2?
I feel like there is some basic sound theory that I miss here...
YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/