Re: Output of HL2 is interrupted while switching TABS in browser


I got serious about pops, crackles, ticks, and things over on the test team list. I'll grab that and add it below this. Warning - it is a LOT of material to absorb. Inevitably math intrudes; but, it's simple "you can't graduate high school if you cannot do this arithmetic" stuff.

You are using small buffers to reduce latency, right? That factors into the following analysis.

Data is coming in generally at very high sample rates, call this frequency X samples per second. In the reception process it gets "down converted" and decimated, usually by a factor of 2^N. Eventually you get down to something like 100 ksps to as low as maybe 8 ksps. Regardless it is a rate determined by the front end sample rate and its frequency error. Call this Y in (1 + px). px is usually 0 to */- 0.0003.

The sound card works at sample rate Y, usually 48 ksps plus or minus a bit, py as with px above. In order to mate the date stream with the output data stream requirements you need a resampler.

To put some numbers on this I'll be cheeky and presume a typical high quality RTL dongle working at its optimum sample rate, 2.4 msps and a 48 ksps sound card as found on computer motherboards. The dongle is 1 ppm out. The motherboard is a bad one at 50 ppm out. The SSB signal is decimated and otherwise tweaked by powers of 2 down to 9.375 kHz, a division ratio of 256. I need to resample that up to 48 ksps. The resample ratio is 5.12. And it's all fixed ratios. So we deliver samples at 48000 * ( 1 + px ) to a device that wants them at 48000 * ( 1 + py ). Pushing the error around we essentially have an error of ( 1 + px )/( 1 + py ). In approximate terms this simplifies to ( 1 + px - py ) if we ignore px * py or py^2 terms. So we can approximate and say we are delivering 48 ksps plus an error to a 48 psps device. Suppose the audio buffers are 1500 samples. Every time the output demands audio the system has prepared 1500 * ( 1 + px - py ). This is cumulative. After awhile a buffer can come up short or long by one sample. What do we do about that sample. What do we do about the excess buffers when we've filled our limit of buffers? We could grow the buffer pool - a memory leak in appearance. So that solution is out. Besides if we come up short we don't have a buffer ready for the output when the output needs it. We get a hitch in the audio either way.

I have seen an application work by fidding the resampler ratio by tiny amounts to account for the differences in rates. This is a fairly finicky adjustment. But it's the only artifact free trick I have seen yet.

(Yes, Loren has used that in SoundMan Server, that cute little 1024x1024 ASIO based mixer, delay, equalize, low latency audio tool he sells. It was in his work to allow multiple digital sources and sinks that are not precisely in lock step with each other. It is hard enough to make stable at the 64 sample buffer size he uses that this was put on a back burner to simmer. I think that fire went out.)

I suspect you will find that all sound cards will tick, click, pop, whatever it does. There MIGHT be some sound processing system that includes a resampler process that matches incoming data rate to the sound card itself. That effectively means EVERY tool that connects to the sound card must either adapt its rate to the sound card (file playback) or get its audio resampled with an adaptive rate resampler (SDR processes). All you can do is negotiate how often.

There are two models for AV data streams. One is pull, the destination sound card (output) drives the timing by asking for buffer loads as it needs them. The other is "push" where the sound card (input) pushes audio to its consumer as it gets full buffers and it's the rest of the software's job to use it in time for the next buffer load.

The collision happens when you have a push source coupled to a pull destination. If the two are on the same card working with the same clock there is no problem. That is how Loren's SoundMan Server works. Because everything is off one ASIO one sound card or set of sound cards that are all precisely synchronized with each other the inherent push is matched precisely by a corresponding pull.

The differences you see are likely due to relative frequency differences vs buffer sizes. Suppose you are a net 50 ppm different in frequencies at 48 ksps, the most common rate for PC audio in videos and the like. So over 1 second you get either 48000 * ( 1.0005) or 48000 / ( 1.0005 ) samples, The net error is 48000 * 0.0005 or 24 samples. If you are running on 64 sample buffers, the smallest ASIO allows, that means you tick about once every 2.7 seconds. For a buffer size of 1500 (fairly common) it ticks about once a minute. For reference 64 samples is about 1.333 ms and 1500 samples is about 31 ms. Very often multiple buffers are used to give very long effective buffering. For 50 ppm error divide the total use buffer time by 24 and you get you time between ticks.

If that IS your problem the solution MAY be very long latency in your audio due to a very large pool of buffers. Or it may involve somebody actually making variable timing on the resampling work. (I an some time away from experimenting with this aspect of SDRs. I plan to doctor the use of the CuteSDR resampler to include an estimator for the sample rate error, which is very ugly to do with the small buffers I want to use. I just ripped up a lot of what I had done so it could be more flexible. I have to glue it all back together to make it work. Meanwhile we're running ethernet wire all over the place.... I've grown sick of the vagaries and lack of privacy given by wireless networking.)

{^_^} ===8<---

On 20200803 15:32:04, paul newcombe wrote:
When I was TXing for those Pics I had no browser turned on.
I was running just SDRC-VAC-WSJT  apart from automatic background programs that Win 7
starts.  I was not connected to a router or to the internet.
That spike is what the RXing stations see.
It is not on Thetis/PWRSDR but I do not want to use those programs HiHi
*From:* <> on behalf of jdow <jdow@...>
*Sent:* Monday, August 3, 2020 6:25 PM
*To:* <>
*Subject:* Re: [SDR-Radio] Output of HL2 is interrupted while switching TABS in browser
You might try slowing down and minimizing spectrum and waterfall displays. You
might also try "If it hurts when you bang your head on your keyboard, don't do
that." That is, run the browser on a different machine.
On 20200803 14:46:05, paul newcombe wrote:
Just to add to earlier notes.
This is a picture of one of the horizontal spikes received at a friends station
around 50 miles away.
These are only there when I us SDRC to TX with the Anan.
They do not occur with Thetis or PWRSDR.
I turned off all, as far as I can work out, internet connections.
I turned off the wireless connection to the internet.
I had just SDRC WSJT and VAC running.
I closed down all other programs, as far as I know, including Chrome.
I tried multiple computers and multiple Anan's.
Next test to try?
Paul N2EME
*From:* <> on behalf of Antoon,
PA3BWE <pa3bwe@...>
*Sent:* Monday, August 3, 2020 2:12 PM
*To:* <>
*Subject:* Re: [SDR-Radio] Output of HL2 is interrupted while switching TABS in
Just an update:
I'm running a QuadCore 8300 PC with 8G memory, not the newest but more then enought to do the work.
On average the system is @ 40% of CPU resources when decoding MSK in normal mode.
I just noticed that this also happens when putting the FOCUS from  to Chrome (without switching between tabs in Chrome).
I tried other applications as well but so far I only see this happening when using a browser.
antoon / pa3bwe
anan spike.jpg
anan TX spike.png

Join to automatically receive all group messages.