Mathieu Bouchard wrote:
On Sun, 4 Jul 2010, Martin Peach wrote:
As long as they are on the same card, they will be in perfect sync at the clock level unless you have some really unusual hardware. This is because the same clock is used for A/D and D/A. Usually they are on the same chip and the data from the ADC is clocked out using the same clock that loads the DAC.
Can you just explain to us why sync has to be done when you have two soundcards that are supposed to be sending you the same number of blocks per second ?
?
I mean, for example, suppose a soundcard that is nominally set at 44100 Hz is actually running at 44098 Hz ; then what happens to Pd objects that depend on the samplerate (such as [osc~], [lop~], etc) ? Do they use 44098, or 44100 ? that would be the same as whatever [samplerate~] says, but somehow, it always says exactly 44100.000 ... why ? Is it because my soundcard's clock is that much accurate ? (it's a cheap on-board thing)
The sample rate is set by the frequency of the crystal on the card, which is supposed to run at some multiple of 44100 or 48000, but that's set by the manufacturing tolerances and nothing is actually measuring it. Also because the crystal changes in size with temperature the frequency will change slightly as it warms up. Precision oscillators are kept inside ovens for that reason.
Pd assumes 44100Hz even if the card isn't doing that. (Some of the code seems to be actually hard-wired for 44100). For instance if I clock one sound card with the SPDIF output of another card on another machine that's running at 22050Hz, the test tone is 220Hz instead of 440 and Pd is none the wiser.
I recall seeing precisely "44098 Hz" when my soundcard was an ISA Ultrasound (Gravis) some 5-10 years ago, but I don't recall whether it was at Pd's startup, another programme's startup, or both.
I guess if you know the CPU frequency you can count samples to determine the sample rate, but that assumes that the CPU clock is what it says it is. Relativity and all that...
Martin