[hpsdr] Mercury sampling rate

Alex, VE3NEA alshovk at dxatlas.com
Sat Apr 12 11:50:56 PDT 2008


Alberto,

The clock generator in the soundcards is crystal controlled and typically 
has an accuracy of 10^-4 or better. Consider a program that inputs audio 
data at a rate of 48 kHz in blocks of 1K samples, and suppose that the 
output rate is lower than the input rate by 10^-4. When the input device 
produces 10,000 blocks, the output device will consume only 9,999 blocks, so 
one extra block is produced every 200 seconds. This results in one crackle 
in the output audio every 3 minutes or so - which is totally acceptable and 
is very difficult to detect by the ear in the background noise. Note that 
the crackle occurs only in the data sent to the speakers but not in the data 
used to compute the spectra, decode digital signals, etc.

If the streaming buffer is properly designed, an extra block of data 
produces exactly one click in the audio, but a poorly designed buffer may 
result in a sequence of clicks that starts when the extra block is received 
and lasts for seconds. This happens when the read and write pointers in the 
buffer point at the same data block. A simple algorithm that avoids such 
situation and ensures that no more than one click is caused by an extra data 
block is implemented in my MmeAudioStream component, the source code is at 
(http://www.dxatlas.com/dev).

73 Alex VE3NEA




----- Original Message ----- 
>   Hi Alex,
>
>   thanks for your message and the pointer. But there is still one thing 
> that I can't understand how you can accomplish
> without the use of a rational factor resampler. The scheme you pictured is 
> fine, and it would work perfectly if the
> sampling rate of the sound cards were perfect. But it isn't... When you 
> produce the output audio to be sent to the sound
> card, you maybe encounter a card where the nominal 11025 Hz are actually 
> 11026 or 11027... the effect of this is that if
> you produce output buffers based on the nominal sample rate, sooner or 
> later you will find yourself in a situation of
> buffer starvation, with a consequent click in the audio.
>
> What I do in Winrad is to have a FIFO for the output buffers, and 
> monitoring the degree of filling of this FIFO I change
> slightly the downsampling ratio (maybe of a factor of only 0.001) so to 
> keep this number constant, avoiding overflows or
> underflows. This is the only way I have found to cope with sound cards 
> with a non exact sampling rate.
>
> If I disable the adjustment of the resampling factor, depending on the 
> card I will end in a sequence of clicks, maybe
> not immediately, but after a few minutes. But sooner or later it will 
> happen.
>
> I don't how you did manage this problem in Rocky. Maybe there is a way 
> simpler than mine, and I would be quite
> interested in knowing it.  TNX.
>
> 73  Alberto  I2PHD


 1208026256.0


More information about the Hpsdr mailing list