Hi all. Bear with me, I promise this will be hardware related in a minute...
I'm working on a project for which I need to generate some FSK. I'm doing so by using a sin(...) function to calculate the values along the wave for N periods of frequency A and M periods of frequency B, both of duration T, and storing them in a buffer. I tried using the waveOutWrite function to play the buffer that I created, but it ended up creating a complex sine wave which, for the most part, looked like I wanted it to (frequency wise) but it looked pretty fat and ugly on the oscilloscope. I zoomed in on it and it had another sine-looking wave running along the major sine wave, which made the FSK get all hosed up. To fix this, I ended up creating my own WAV file and put the data from the buffer in that, saved the file to disk and used PlaySound(...) to play it.
Here's where it gets hardware (I think...possibly) related. Take for instance the low bit frequency, 1562.5 Hz. When I play it on the development PC (a dell with what shows up as a microsoft sound device, SoundMax Integrated Digital HD Audio) it is coming out too fast and hoses up the FSK...it looks on the scope to be about 1572.3. When I play them from the device on which it's intended to be played (Intel board with RealTek ALC662 audio chip) it comes out dead on at 1562.5.
And here are my questions: Why the heck is it behaving like this? Does it have something to do with the dell audio device being integrated and perhaps running off of the system clock rather than a dedicated audio clock which could be messing up the sample rate or something whereas the RealTek has a dedicated audio chip which, presumably, has it's own clock rate?
As an interesting side note, as far as I can tell, the WAVEFORMATEX WAVEOUTCAPS only seems to support up to 44.1kHz sample rates, so that's what I'm using as of now, but the RealTek ALC662 data sheet says that it does up to 96kHz. When I used 96kHz (even though WAVEOUTCAPS doesn't seem to know about that frequency) for the sample rate with the waveOutWrite file, it made a simple sine wave that looked fine on the scope. Why would that behave that way? Is it because the chip knows about it and I'm telling the software to tell the chip to use that frequency and if the MS functions don't know about that frequency then it's their problem, not the software or the chip's? Is there something magical about the 96kHz frequency that makes it work (being the chip max or something) or would some other [evenly divisible] lower frequency likely also make a nice wave? (although none that I tried seemed to)