# Complex square wave source

**URL:** <https://www.ruby-forum.com/t/complex-square-wave-source/220780>\
**Category:** GNU Radio\
**Created:** [June 20, 2012, 2:34am UTC](https://www.ruby-forum.com/t/complex-square-wave-source/220780 "2012-06-20T02:34:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [June 20, 2012, 2:34am UTC](https://www.ruby-forum.com/t/complex-square-wave-source/220780/1 "2012-06-20T02:34:05Z")

</div>

This is probably a Tom question, but I’m of course open to suggestions  
from  
anyone.

This is a restatement of Mario R.'s question on 6/8 after additional  
conversation on the IRC channel. I think it didn’t get much response due  
to  
the way it was phrased.

I’m not much of a DSP fundamentals guy, so take this with a grain of  
salt.  
Currently, the complex square source outputs a 90-degree-delayed square  
wave on the imaginary output, rather than an actual analytic square  
wave,  
which can be approximated by passing a float square source through a  
Hilbert filter. The imaginary component in that case is  
(2/pi)\*ln(tan(t/2)); when used with complex input I believe the  
imaginary  
part of the result will actually be the real square wave component,  
since  
it’s a Hilbert transform and so it’s reciprocal.

The same general comment applies to the sawtooth and triangle wave  
sources  
although their analytic representations are different.

So, I don’t actually care what the square wave source emits if there’s a  
reason for it, but was there a reason it was implemented as a delayed  
square wave rather than the analytic representation? Is there actually a  
use for complex square/saw/triangle wave sources? Am I just causing  
trouble  
and it’s way too late to be changing the behavior of this block?

–n

---

<div class="post-metadata">

**Author:** ![nickfaraday](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b2d939/32.png) [@nickfaraday](https://www.ruby-forum.com/u/nickfaraday)\
**Post date:** [June 20, 2012, 3:21am UTC](https://www.ruby-forum.com/t/complex-square-wave-source/220780/2 "2012-06-20T03:21:59Z")

</div>

> So, I don’t actually care what the square wave source emits if there’s a  
> reason for it, but was there a reason it was implemented as a delayed  
> square wave rather than the analytic representation? Is there actually a  
> use for complex square/saw/triangle wave sources? Am I just causing trouble  
> and it’s way too late to be changing the behavior of this block?

Some total nOOb added the triangle, square, sawtooth waveforms to signal  
source. There was a spot to fill in the complex versions of these  
waveforms, so it just kind of got filled in… doesnt mean much.

My only regret was not making ramp function cross 0.

-josh

---

<div class="post-metadata">

**Author:** ![nickfaraday](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/b2d939/32.png) [@nickfaraday](https://www.ruby-forum.com/u/nickfaraday)\
**Post date:** [June 21, 2012, 4:21am UTC](https://www.ruby-forum.com/t/complex-square-wave-source/220780/3 "2012-06-21T04:21:58Z")

</div>

On Tue, Jun 19, 2012 at 9:21 PM, Josh B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> waveforms, so it just kind of got filled in… doesnt mean much.
> 
> My only regret was not making ramp function cross 0.
> 
> -josh

Yeah, seems like it was the easiest solution to build. I’m sure we can  
update it to be a real analytic signal (although, using a Hilbert  
filter for the transform doesn’t perform a _real_ Hilbert transform  
since it’s limited by the filter representation of it).

If there’s a useful patch for this, send it along!

Tom
