discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Discuss-gnuradio] Regarding gr_squelch_base_cc.cc


From: Johnathan Corgan
Subject: Re: [Discuss-gnuradio] Regarding gr_squelch_base_cc.cc
Date: Thu, 29 Apr 2010 04:14:20 -0700

On Thu, Apr 29, 2010 at 01:55, Mattias Kjellsson <address@hidden> wrote:

> 57: case ST_MUTED:
> 58: if (!mute())
> 58:    d_state = d_ramp ? ST_ATTACK : ST_UNMUTED; // If not ramping, go 
> straight to unmuted
> 60: break;

The 'condition ? expr1 : expr2' construct is an expression that
evaluations to 'expr1' if 'condition' is true, otherwise it evaluates
to 'expr2'.

Here, 'condition' is d_ramp, 'expr1' is ST_ATTACK, and 'expr2' is ST_UNMUTED.

Thus, line 58 says:

"Assign to d_state the value of 'ST_ATTACK' if d_ramp is true,
otherwise assign to d_state the value of 'ST_UNMUTED'."

In other words, the variable d_state is the left side of an
assignment, and the right side of the assignment evaluates to either
ST_ATTACK or ST_UNMUTED, depending on whether d_ramp is true.

It may help to mentally parse line 58 with parenthesis just before
'd_ramp' and after 'ST_UNMUTED'.

Specifically, this is *not* a test of the value of d_state.

Hope this helps with your fear and confusion :-)

Johnathan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]