# Waveform after AM demodulation looks weird

**URL:** <https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685>\
**Category:** GNU Radio\
**Created:** [April 25, 2014, 2:24pm UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685 "2014-04-25T14:24:42Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![musicdenotation](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@musicdenotation](https://www.ruby-forum.com/u/musicdenotation)\
**Post date:** [April 25, 2014, 2:24pm UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/1 "2014-04-25T14:24:42Z")

</div>

Hi, you can find in attach AM demodulator grc file. Everything is  
straight  
forward with demod but audio file generated looks weird. Only positive  
values of amplitude. In FFT i do see symmetric picture. I  
enabled/disabled  
DC offset option in osmosdr block, but it did not help.  
Originally file is generated as raw audio and after processed with sox  
(-t  
raw -r 16k -b 16 -e signed-integer). I have also tried to use wav sink  
block - the same result.

Find wav file in attach.

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 25, 2014, 3:13pm UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/2 "2014-04-25T15:13:06Z")

</div>

On Fri, Apr 25, 2014 at 04:14:30PM +0400, Anton K. wrote:

> Hi, you can find in attach AM demodulator grc file. Everything is  
> straight forward with demod but audio file generated looks weird. Only  
> positive values of amplitude.

The particular definition of “amplitude” adopted by GNU Radio (and  
pretty much everyone else in SDR as far as I know) is “absolute value”.  
It is correct for it to always be positive.

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 25, 2014, 3:27pm UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/3 "2014-04-25T15:27:16Z")

</div>

But when we have only positive values that means in fact we have 0.5 DC  
offset, and that is bad. Moreover i’ve made test recording with GQRX -  
waveform is fine! Looking into the code, nothing special, am  
demod-\>low-pass-\>wav-sink.

–  
public PGP key

> **[pkey - Pastebin.com](https://pastebin.com/dqZqgyVE)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 25, 2014, 3:42pm UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/4 "2014-04-25T15:42:36Z")

</div>

On Fri, Apr 25, 2014 at 05:25:54PM +0400, Anton K. wrote:

> But when we have only positive values that means in fact we have 0.5  
> DC offset, and that is bad. Moreover i’ve made test recording with  
> GQRX - waveform is fine! Looking into the code, nothing special, am  
> demod-\>low-pass-\>wav-sink.

See “DC removal”:

[https://github.com/csete/gqrx/blob/master/dsp/rx\_demod\_am.cpp#L54](https://github.com/csete/gqrx/blob/master/dsp/rx_demod_am.cpp#L54)

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 26, 2014, 9:07am UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/5 "2014-04-26T09:07:03Z")

</div>

* * *

Discuss-gnuradio mailing list  
removed\_email\_address@domain.invalid  
[https://lists.gnu.org/mailman/listinfo/discuss-gnuradio](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 26, 2014, 10:29am UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/6 "2014-04-26T10:29:01Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Actually I’m a little confused - Is seeing an AGC in an AM demodulator  
something you usually do?  
Especially the feedforward AGC should be rather err jumpy with a scope  
of but 256 samples, unless I’m missing something; f\_sample seems to be  
1024ksps, thus 256 samples max search and rescaling should behave very  
badly if there are baseband signal contents below 4kHz – and that  
should be the case for audio, usually?

Greetings,  
Marcus

On 25.04.2014 16:03, Marcus L. wrote:

> – public PGP key [pkey - Pastebin.com](http://pastebin.com/dqZqgyVE)  
> The particular definition of “amplitude” adopted by GNU Radio (and
> 
> \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> mailing list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEcBAEBAgAGBQJTWn5MAAoJEBQ6EdjyzlHtWSEIAKSNLkujZEL/lpmy/CBrK76+  
144zh4QY9QkAd9jgYHE/lSp6oAP2EEIXI7xQw1AC+2c2c2+pcG92ydJs/2/pvEa3  
zfyVUtSr5e8qByokifDCq1HeMFG4q5Uis/cNgWlQPBeWR5My6ngnE3xC4TmMhGO6  
WCYFqyrf7dz+P/cXClRs9jIVv4HKPLCZky9qdmG/9rXFxovQt369boaXDdvtc6Ga  
dnNswR2zXh63IH+ZWaARTiB61GJ/oPw/yh1jL9inVOFhioZstUFK0xS1ACxFZBiY  
P1nHuixHkGXmIp6jp1QXo6H9QAqVZ5z/H4Tngd8EM+i+KsqxaJncvzGW7MVgaQA=  
=XADd  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 26, 2014, 10:40am UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/7 "2014-04-26T10:40:49Z")

</div>

Marcus, w/o AGC audio sometimes is creapy. I have tested AGC2, tried to  
play with attack and decay, but at last when there is a plane in the  
vicinity dongle overloads and sound become very loud. Then i tested FAGC  
and it fits well! 1024M/64 gives 16k and 256 samples equals - 62 ms of  
signal. Works ok for me.

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 25, 2014, 3:59pm UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/8 "2014-04-25T15:59:44Z")

</div>

Thanks a lot. It does work!

–  
public PGP key

> **[pkey - Pastebin.com](https://pastebin.com/dqZqgyVE)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 28, 2014, 11:25am UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/9 "2014-04-28T11:25:53Z")

</div>

When I looked into the attached graphical flowgraph in the first email,  
the  
signal was multiplied by zero (constant multiplier) before feeding into  
file sink and audio sink. In this case what you get was probably  
amplified  
noise.  
Was it zero or something else?

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 26, 2014, 10:59am UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/10 "2014-04-26T10:59:41Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

A shoot, I overlooked the 64 decimation rate… Sorry about that.

On 25.04.2014 17:36, Anton K. wrote:

> Actually I’m a little confused - Is seeing an AGC in an AM
> 
> > > > An AM demodulator is a squaring function. It can only
> > > > 
> > > > The particular definition of “amplitude” adopted by GNU Radio  
> > > > (and pretty much everyone else in SDR as far as I know) is  
> > > > “absolute value”. It is correct for it to always be  
> > > > positive.
> 
> * * *
> 
> > > >

\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio

> > \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Discuss-gnuradio  
> > mailing list [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> > [Discuss-gnuradio Info Page](https://lists.gnu.org/mailman/listinfo/discuss-gnuradio)

-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1  
Comment: Using GnuPG with Thunderbird - [http://www.enigmail.net/](http://www.enigmail.net/)

iQEbBAEBAgAGBQJTWoU1AAoJEBQ6EdjyzlHtQAYH+KNwTI+XPjKFyb+kId+Y9fxv  
uthK+LH7CTAm85j9gb4mIeGe7Wpe2gZZ0sqvDgyXL594urUSvfbmyCy/p0GI7WfC  
evmwyX4HBZIuXBdqIkj0NdhvwpaBHBYUE1R2JfVIK1ZqaApNtGVxoKpOyI38XCg1  
m68tsU3HASfVQxIWfuJS0mBgwPo8wSCTXLOoUqc1YTVXd+tXNNAVLbFEDUOgVuib  
irkUhUYdNi85SwO3ildun/9xEwXB3g4FeB3Hq66TccE5M7zvZsOBa4oF/uKITRoG  
cvOc/EuBRCG+u1lI2owwQXsUuGWmHhN+xcjtkzn4Qa+2b+zR9bPPGS70ru45vQ==  
=+L1B  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![antonk](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://www.ruby-forum.com/u/antonk)\
**Post date:** [April 28, 2014, 11:54am UTC](https://www.ruby-forum.com/t/waveform-after-am-demodulation-looks-weird/240685/11 "2014-04-28T11:54:51Z")

</div>

This, is a squelch, variable changes between 0 and positive gain value.

–  
public PGP key

> **[pkey - Pastebin.com](https://pastebin.com/dqZqgyVE)**
>
> Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
