# Complex to bits

**URL:** <https://www.ruby-forum.com/t/complex-to-bits/237024>\
**Category:** GNU Radio\
**Created:** [October 19, 2013, 3:12pm UTC](https://www.ruby-forum.com/t/complex-to-bits/237024 "2013-10-19T15:12:45Z")\
**Posts on this page:** 4\
**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:** [October 19, 2013, 3:12pm UTC](https://www.ruby-forum.com/t/complex-to-bits/237024/1 "2013-10-19T15:12:45Z")

</div>

Hi everyone.  
Thanks for all the replies on my previous thread. I did some tests and  
found out that the FFT and IFFT do not add noise to my audio signal. It  
works perfectly! The noise is coming from another part of my flowgraph.  
Before I introduced the FFT and IFFT, I was working with an audio signal  
that was scaled and converted to int, so it could be unpacked into bits;  
those bits were processed and retrieved, packed, converted to float,  
descaled and turned back to audio. There was no noise then. Adding the  
FFT and IFFT made me use the complex type before the unpacking, so what  
I was using to make it possible to unpack the signal into bits no longer  
worked properly.  
I tried changing the scale constant, converting from complex to IShort  
and unpacking that, but neither worked.  
So, my question is: how do I unpack a complex signal into bits, and then  
pack it back? Considering I’m working on a audio signal that shouldn’t  
get noise added to it.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![guilherme\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a6a055/32.png) [@guilherme\_r](https://www.ruby-forum.com/u/guilherme_r)\
**Post date:** [October 19, 2013, 10:13pm UTC](https://www.ruby-forum.com/t/complex-to-bits/237024/2 "2013-10-19T22:13:59Z")

</div>

I just realized that float to bits is also acceptable, as long as the  
samples don’t lose precision.  
I didn’t tacked this by scaling the samples then converting to int  
because I don’t know what is the range of values for the outputs of the  
FFT and IFFT blocks.

From: removed\_email\_address@domain.invalid  
To: removed\_email\_address@domain.invalid  
Subject: Complex to bits  
Date: Sat, 19 Oct 2013 10:11:33 -0300

Hi everyone.  
Thanks for all the replies on my previous thread. I did some tests and  
found out that the FFT and IFFT do not add noise to my audio signal. It  
works perfectly! The noise is coming from another part of my flowgraph.  
Before I introduced the FFT and IFFT, I was working with an audio signal  
that was scaled and converted to int, so it could be unpacked into bits;  
those bits were processed and retrieved, packed, converted to float,  
descaled and turned back to audio. There was no noise then. Adding the  
FFT and IFFT made me use the complex type before the unpacking, so what  
I was using to make it possible to unpack the signal into bits no longer  
worked properly.  
I tried changing the scale constant, converting from complex to IShort  
and unpacking that, but neither worked.  
So, my question is: how do I unpack a complex signal into bits, and then  
pack it back? Considering I’m working on a audio signal that shouldn’t  
get noise added to it.  
Thanks in advance.

---

<div class="post-metadata">

**Author:** ![guilherme\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a6a055/32.png) [@guilherme\_r](https://www.ruby-forum.com/u/guilherme_r)\
**Post date:** [October 20, 2013, 8:25pm UTC](https://www.ruby-forum.com/t/complex-to-bits/237024/3 "2013-10-20T20:25:43Z")

</div>

Yesterday, during the night, I tried my luck on the #gnuradio IRC  
channel. One was kind enough to point me in the right  
direction. Up to this point I had no idea I could connect ports of  
different types. So, starting from the FFT’s output, I connected that to  
a complex Vector to Stream, as one would do normally, then I connected  
that to a byte Vector to Stream (1, gr.sizeof\_gr\_complex (which is 8)),  
then I connected that to a byte Vector to Stream (gr.sizeof\_gr\_complex,  
1), then I had a byte stream which I could safely unpack and pack and  
get the bits to work with.  
Thanks for all the help.

---

<div class="post-metadata">

**Author:** ![guilherme\_r](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a6a055/32.png) [@guilherme\_r](https://www.ruby-forum.com/u/guilherme_r)\
**Post date:** [October 21, 2013, 7:58am UTC](https://www.ruby-forum.com/t/complex-to-bits/237024/4 "2013-10-21T07:58:03Z")

</div>

HI Gui,  
why did you connect to two byte vector to stream blocks. Is it  
like one for the real part and one for the imaginary part?
