i dont know if this question fits in this forum. But im a little confused how PCM format works. What im trying to do is to simulate a 4 bit DAC (Digital to Analog Converter), well somebody in other forum told me that is not necessary to emulate the DAC cos the Sound Card has one. But if i send the 4 bit value to "waveOutWrite" it isnt playing what it should play.

Another question i have is, if i want to send a determinated hz to the sound card to play (suppose 120khz) and the only way to access the sound card (not thinking in directplay) is waveoutWrite, this means thru PCM, How do i do this?
Posted on 2005-01-14 15:30:53 by Ateneo
120kHz for a soundcard is nuts. Though, there are cards with 192kHz sample rate, they're expensive. With waveOutXXX your minimum latency is 40ms.
You should do this: either create some algo to automatically create some signal and fill in a 40ms buffer, or manually set output values , with which you fill the whole 40ms buffer:

mov ecx,SamplesNum
mov al,ValueToPut (let's say you have set 8-bit output)
shl al,4
mov edi,Output40msBuffer
rep stosb ; not 100% fast, but for the sake of simplicity

then with the mouse or keyboard you change manually the value of ValueToPut. You'll get too slow response, but for educational purposes it'll be ok.

To set up the waveOut stuff, you first prepare two WAVEHDRs, write one of them, and in the snd loop you write the next. I haven't toyed with waveOut for 3 years, it's obsolete, I prefer DirectSound.
Posted on 2005-01-15 05:10:51 by Ultrano
Ya you should just take your 4bit sample data and pop it into the upper nibble of the 8-bit sample. And like Ultrano stated, direct-DAC days are gone. The original SB's (up to SB16) allowed for this, but it is not wise because you had to use the CPU to time the sample rate. IT is best to use a buffer to buffer your sample data.
Posted on 2005-01-15 16:53:30 by x86asm