Skip to content

Commit d6f6f9d

Browse files
committed
qdetector: implementing reset() method properly
1 parent b0381cd commit d6f6f9d

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/framing/src/qdetector.proto.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,22 +114,17 @@ QDETECTOR() QDETECTOR(_create)(TI * _s,
114114
FFT_EXECUTE(q->fft);
115115
memmove(q->S, q->buf_freq_0, q->nfft*sizeof(TI));
116116

117-
// reset state variables
118-
q->counter = q->nfft/2;
119-
q->num_transforms = 0;
120-
q->x2_sum_0 = 0.0f;
121-
q->x2_sum_1 = 0.0f;
122-
q->state = QDETECTOR_STATE_SEEK;
123-
q->frame_detected = 0;
124-
memset(q->buf_time_0, 0x00, q->nfft*sizeof(TI));
125-
126-
// reset estimates
117+
// clear estimates
127118
q->rxy = 0.0f;
128119
q->tau_hat = 0.0f;
129120
q->gamma_hat = 0.0f;
130121
q->dphi_hat = 0.0f;
131122
q->phi_hat = 0.0f;
132123

124+
// reset state variables
125+
QDETECTOR(_reset)(q);
126+
127+
// set default threshold and range values
133128
QDETECTOR(_set_threshold)(q,0.5f);
134129
QDETECTOR(_set_range )(q,0.3f); // set initial range for higher detection
135130

@@ -336,6 +331,15 @@ int QDETECTOR(_print)(QDETECTOR() _q)
336331

337332
int QDETECTOR(_reset)(QDETECTOR() _q)
338333
{
334+
// reset state variables
335+
_q->counter = _q->nfft/2;
336+
_q->num_transforms = 0;
337+
_q->x2_sum_0 = 0.0f;
338+
_q->x2_sum_1 = 0.0f;
339+
_q->state = QDETECTOR_STATE_SEEK;
340+
_q->frame_detected = 0;
341+
memset(_q->buf_time_0, 0x00, _q->nfft*sizeof(TI));
342+
339343
return LIQUID_OK;
340344
}
341345

0 commit comments

Comments
 (0)