From: pesjogre@nada.kth.se (Peter Sj{gren)
Subject: Re: SoundBlaster sampling frequency accuracy
Originator: pesjogre@byse.nada.kth.se
Reply-To: pesjogre@nada.kth.se (Peter Sj{gren)
Organization: Royal Institute of Technology, Stockholm, Sweden
Date: Thu, 27 Aug 1992 14:10:37 GMT


Thank you for your answers!


In article <176946INN2pv@ensta.ensta.fr> you write:
>frequency is coded on one byte, at offset 4 in a Voice Data block. The
>sampling rate is the determined by using the formula:
>
>SR(1 byte)=256-1000000/SamplingRate
>
>	Which means exactly what I was saying... As the sampling rate is
>defined on 1 byte, it's precision is of 1/256=0.4% which means that when
>sampling ANYTHING at 11000Hz, you may actually be sampling at anything
>between 10989 and 11111 Hz... and, when replaying, you have the same
>possible variations... Dont be surprised if the sound you sample then play
>again varies... You may have sampled at 10989 and played at 11111 Hz...
>Or vice versa...
>

Yes, that is true. But even if the sampling frequency is stored in the 
SoundBlaster card in one byte (which has few discrete values) the soundcard
can, still, provide a sampling frequency that is much more accurate than
between two levels in the representation of the sampling frequency in one
byte.

For example, if we, in the above formula have a SR-byte value of, say 156,
the sampling rate would be   1000000/(256-156) = 10000. The question is 
now how accurate THIS value (10000 Hz) is. And that is only dependent on
the implementation in the sound card. This accuracy has nothing to do with
how many discrete steps the sampling frequency can by specified in. In this
case I want exactly 10000 Hz and I couldn't tell the card that more accurately
with a 64-bit word.


By the way...

I recorded the tuning fork on a PC in Windows 3.1 SoundRecorder and I think
that the SoundRecorder wants to record in 11025 Hz (that is what it says
in the .WAV file that is produced by the SoundRecorder). The formula gives:

  SR(byte) = 256 - 1000000/11025 = 165.29705...  that is NOT an even number

so the soundblaster card must (if it stores the sampling frequency in one
byte) round this value. I don't know how the Windows SoundBlaster drive
does it, but just suppose that it is rounded up to 166. Then the sampling
frequency would be:

	1000000/(256-166) = 11111.11111 .....

and that would give a frequency of 11025/11111.111 * 440 = 436.6 when
you record a 440 Hz tone and think the sampling frequency is 11025 and
it really is 11111 Hz. (436 Hz +- 0.7  is what I got in the experiment.)

>	A Sound Blaster never was precise...
Perhaps, perhaps not...
>

Windows Multimedia waveaudio devices seem to (according to the Multimedia
reference in SDK) "prefer" to record and play at sampling rates of
44100, 22050, 11025 etc and if the above SR(byte) formula is used in
SoundBlaster cards it seems that the sampling rate in the soundblaster 
cannot be stored correctly. That is 11025 Hz becomes 11111 Hz and so on.
How is this with other sound cards, are they able to exacly represent
11025, 22050 and 44100???

Please correct me if I am wrong and tell me more information in either
case. Especially how the rounding is performed in the SoundBlaster drive and
how other cards represent the sampling rate.

Thank you very much!
Peter Sjogren			(peter@jada.se    or    pesjogre@nada.kth.se)
Sweden