-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathlowpass.cpp
55 lines (46 loc) · 1.03 KB
/
lowpass.cpp
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
#include "lowpass.h"
#include<qfont.h>
#include<stdio.h>
Lowpass::Lowpass() : QComboBox() {
addItem(tr("off"),0);
addItem(tr("1Hz"), 1);
addItem(tr("2Hz"), 2);
addItem(tr("5Hz"), 5);
addItem(tr("10Hz"),10);
addItem(tr("20Hz"), 20);
addItem(tr("50Hz"), 50);
addItem(tr("||1Hz"), -1);
addItem(tr("||2Hz"), -2);
addItem(tr("||5Hz"), -5);
connect(this,
SIGNAL( activated(int) ),
this,
SLOT( setFrequencyIndex(int) ) );
setCurrentIndex(0);
}
void Lowpass::setFrequencyIndex ( int index ) {
frequency = (float)(itemData(index).toFloat());
if (fabs(frequency) > 0) {
lp.setup(samplingrate,
(float)fabs(frequency));
}
}
void Lowpass::setFrequency(float f) {
//_RPT1(0, "setFre lowpass=%fHz\n", f);
int index = findData(f);
if (index != -1) {
setCurrentIndex(index);
setFrequencyIndex(index);
}
}
float Lowpass::filter(float v) {
if (frequency > 0) {
return lp.filter(v);
}
else {
if (frequency < 0) {
return lp.filter(fabs(v));
}
}
return v;
}