[Stk] BlitSquare bug?

Gary Scavone gary at ccrma.Stanford.EDU
Thu Mar 12 10:56:21 PDT 2015


Hi Steven,

The bandlimited square wave is formed by integrating a bipolar blit.  So, the line:

  lastBlitOutput_ += temp;

accomplishes the integration.  The subsequent filtering operation is a one-pole DC blocker and the line:

  dcbState_ = lastBlitOutput_;

simply saves the current input state for the subsequent iteration. The DC blocker is required to avoid a DC offset that can accumulate over time from the integration.

I don’t see a bug in the code.

Regards,

—gary

On Mar 3, 2015, at 10:11 AM, Steven Yi <stevenyi at gmail.com> wrote:

> Hi All,
> 
> I was translating the STK code for BlitSquare to another language and
> I have a question about the code.  As far as I can tell, the code in
> BlitSquare.h for the tick method looks to have a bug.  I noticed this:
> 
>  StkFloat temp = lastBlitOutput_;
>  ...
>  lastBlitOutput_ += temp;
> 
>  // Now apply DC blocker.
>  lastFrame_[0] = lastBlitOutput_ - dcbState_ + 0.999 * lastFrame_[0];
>  dcbState_ = lastBlitOutput_;
> 
> The value of dcbState_ and temp are both set to the lastBlitOutput_.
> The calculation adds temp, but then subtracts dbcState_, which
> effectively makes the line calculating last_frame_[0] :
> 
>  lastFrame_[0] = lastBlitOutput_ + 0.999 * lastFrame_[0];
> 
> if one takes out the "lastBlitOutput_ += temp" line.
> 
> In my translated code, I've plotted both the direct translation as
> well as a version removing the use of temp and dcbState_ and I got the
> same results.
> 
> Could someone confirm my analysis about this code?
> 
> Thanks!
> steven
> 
> _______________________________________________
> Stk mailing list
> Stk at ccrma.stanford.edu
> http://ccrma-mail.stanford.edu/mailman/listinfo/stk




More information about the Stk mailing list