discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Capturing maximum complex value


From: Kevin Reid
Subject: Re: [Discuss-gnuradio] Capturing maximum complex value
Date: Sun, 17 Mar 2019 12:45:49 -0700

On Sun, Mar 17, 2019 at 12:08 PM John Ackermann N8UR <address@hidden> wrote:
On 3/17/19 3:01 PM, Kevin Reid wrote:

> One of the AGC blocks that has separate attack and decay rates (agc2_cc
> or agc3_cc) could be used to do this: set attack to 1, decay to 0,
> ignore the output, and read (1.0 / agc.gain()) to find the peak-hold
> magnitude.
>
> In my own application, I am using this chain for peak detection
> /without/ hold:
>      blocks.complex_to_mag_squared(),
>      blocks.stream_to_vector(itemsize=gr.sizeof_float,
> nitems_per_block=window),
>      blocks.max_ff(window),
> blocks.probe_signal_f()
> but you would need to separately poll (at the sample rate divided by the
> window length) and max-hold this to catch long-term peaks. On the
> upside, as I just found out, it uses less CPU time than running the AGC
> (on my processor).

This is where I get myself confused -- to get a magnitude do I need to
do an FFT, or can I just look at the raw complex stream, or the output
of complex_to_mag_squared without an FFT?

If you want to detect clipping, you want to know if the magnitude of any sample is greater than 1.0 — that's all there is to it. No FFT. My code happens to divide the stream into vectors but that is the only similarity.

Performing a FFT will not help you detect clipping. To illustrate this: suppose your signal content is a bunch of different sine waves of constant amplitude and slightly different frequencies. The maximum sample magnitude in the combined signal will occur when the phases of all those sines align, which will happen periodically. But the FFT's job is to separate out those sines into independent bins of constant amplitude. A signal that clips and one that doesn't can look very similar in the frequency domain, but in the time domain the difference is obvious because you're looking directly at what matters — the sample values that are (after scaling) being sent to the DAC.
 
I've used something like the
blocks you describe to capture the max within each FFT frame, but what
I'm looking for now is any instant where I get clipping, no matter how
brief.

And there's another hint: if you're looking for brief events, you probably want time-domain and not frequency-domain methods.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]