# Port flowgraph from Python to C++

**URL:** <https://www.ruby-forum.com/t/port-flowgraph-from-python-to-c/234812>\
**Category:** GNU Radio\
**Created:** [July 29, 2014, 11:55pm UTC](https://www.ruby-forum.com/t/port-flowgraph-from-python-to-c/234812 "2014-07-29T23:55:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [July 29, 2014, 11:55pm UTC](https://www.ruby-forum.com/t/port-flowgraph-from-python-to-c/234812/1 "2014-07-29T23:55:13Z")

</div>

Hello,  
I was able to create a flowgraph in GRC to demodulate a signal  
(low-frequency battery telegram of wireless microphones). Now I started  
to port the generated code from Python to C++.  
I had to realize that some blocks are Python-only, like the FM  
Demodulator. I was able to rebuild the FM Demodulator in C++, for one  
exception: The FM demodulator uses optfir, which is implemented in  
Python, so it cannot be used in C++. So I replaced it with firdes (I  
noticed the parameter difference in transition band end and transition  
band width).  
Another thing is that the Frequency-Xlating-Filter uses a complex  
lowpass, but in C++ I could only find a complex band-pass, so I used a  
band-pass with lower frequency 0, is that the same?

Also it works, the signal is a lot noisier and the result cannot be  
decoded in many cases. I think the reason are the different filters.  
Could that be the reason?  
As I understood, both optfir and firdes create just a bunch of numbers  
and that´s it. As my program is not going change the filter parameters  
they could be hardcoded in my program, right?

Best regards  
Stefan

---

<div class="post-metadata">

**Author:** ![Stefan\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Stefan\_O](https://www.ruby-forum.com/u/Stefan_O)\
**Post date:** [July 30, 2014, 3:34pm UTC](https://www.ruby-forum.com/t/port-flowgraph-from-python-to-c/234812/2 "2014-07-30T15:34:45Z")

</div>

On Tue, Jul 29, 2014 at 5:53 PM, Stefan O.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Another thing is that the Frequency-Xlating-Filter uses a complex  
> Best regards  
> Stefan

You can use gr\_filter\_design (or in GRC call it with Tools-\>Filter  
Design  
Tool) to show you the filter you designed.

But I think your problem is the bandpass filter you created is probably  
only half of the bandwidth you want, so you’re cutting out a large  
amount  
of information in your signal. The frequency xlating filter takes in the  
filter you define and moves it to the center frequency of the incoming  
signal by a complex multiply. You want this to then be a low-pass filter  
defined to be symmetric around 0. You can then use the  
freq\_xlating\_fir\_filter\_ccf version of the filter to take in the real  
taps  
defined by the lowpass filter. Alternatively, keep with the complex  
bandpass but define the lower passband edge as -B and the upper edge as  
+B.

Tom

---

<div class="post-metadata">

**Author:** ![Stefan\_O](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a8b319/32.png) [@Stefan\_O](https://www.ruby-forum.com/u/Stefan_O)\
**Post date:** [July 30, 2014, 4:06pm UTC](https://www.ruby-forum.com/t/port-flowgraph-from-python-to-c/234812/3 "2014-07-30T16:06:17Z")

</div>

On 07/29/2014 11:53 PM, Stefan O. wrote:

> Hello,  
> I was able to create a flowgraph in GRC to demodulate a signal  
> (low-frequency battery telegram of wireless microphones). Now I started

Awesome! Are you planning to publish the code somewhere?

M
