Thursday, April 29, 2010

[Discuss-gnuradio] Regarding gr_squelch_base_cc.cc

Hi list,
I was looking at the gr_pwr_squelch_cc- code, and there is a thing I
just want to check the meaning of. It is not as much that I don't
believe the code works correctly, it's just that some lines of code
confuse and scare me. ;)

The lines are 59 and 64,
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;
61:
62: case ST_UNMUTED:
63: if (mute())
64: d_state = d_ramp ? ST_DECAY : ST_MUTED; // If not ramping, go
straight to muted
65: break;

It might be that I don't fully understand the "?"- construct, but if I
try to translate line 64 into an if- statement, I would do it (with my
understanding) to something like:

if(d_state = d_ramp){
d_state = ST_DECAY;
}
else{
d_state = ST_MUTED;
}

But this can't be the way since this will always set d_state = ST_DECAY
(?) Or it could be the way, but in that case... Why the crazy ?- construct?

As I said earlier, I'm scared and confused, since the code does it's job
but it looks very... Suspicious

BR
Mattias


_______________________________________________
Discuss-gnuradio mailing list
Discuss-gnuradio@gnu.org
http://lists.gnu.org/mailman/listinfo/discuss-gnuradio

No comments:

Post a Comment