summaryrefslogtreecommitdiff
path: root/gsm-tvoid/src/lib/mm_c.cc
blob: 7b3e33506f16fd5b3378511634d7ea0f16bc98cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73

#include "mm_c.h"

mm_c::mm_c(float omega):
	d_omega(omega),
	d_mu(0.5),
	d_x_1(0.0,0.0),
	d_x_2(0.0,0.0),
	d_a_1(0.0,0.0),
	d_a_2(0.0,0.0),
	d_gain_mu(0.01),
	d_gain_omega(0.25 * d_gain_mu * d_gain_mu)
{}


gr_complex mm_c::slicer(gr_complex x)
{
	float real=SLICE_0_R, imag=SLICE_0_I;
	
	if(x.real() > 0.0)
		real = SLICE_1_R;
	
	if(x.imag() > 0.0)
		imag = SLICE_1_I;
	
	return gr_complex(real,imag);
}

float mm_c::update(gr_complex x_0, gr_complex a_0)
{
	//mm vars
	gr_complex x,y,u;
	
	x = (a_0 - d_a_2) * conj(d_x_1);
	y = (x_0 - d_x_2) * conj(d_a_1);
	u = y - x;
	d_mm = u.real();		//error signal
	
	//limit d_mm
	if (d_mm > 1.0) d_mm = 1.0;
	else if (d_mm < -1.0) d_mm = -1.0;

	//error feedback
	d_omega = d_omega + d_gain_omega * d_mm;
	
	//limit omega
/*		
	if (d_omega > d_max_omega)
		d_omega = d_max_omega;
	else if (d_omega < d_min_omega)
		d_omega = d_min_omega;
*/
	//update mu		
	d_mu = d_mu + d_omega + d_gain_mu * d_mm;
	//process mu / ii advances after burst processing for burst timing
	
	//update delay taps
	d_x_2 = d_x_1;
	d_x_1 = x_0;
	d_a_2 = d_a_1;
	d_a_1 = a_0;

	return d_mu;
}


float mm_c::update(gr_complex x_0)
{
	return update(x_0, slicer(x_0) );
}



personal git repositories of Harald Welte. Your mileage may vary