blob: 103103637c6969c08affb0747947760854540557 (
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
|
//$Id$
package Fir;
public class Fir {
/**
* Construct a Finite Impulse Responce filter.
*
* @param coefficient: The coefficient of the impulse responce.
* @param samplQueue: A queue that contains the last input m elements.
*/
public Fir(double coefficient[], SampleQueue sampleQueue) {
this.mCoefficient = coefficient;
this.mSampleQueue = sampleQueue;
}
/**
* Computes the next output. This output depends from the
* contents of the SampleQueue.
*/
public double Filter() {
double filteredSample = 0;
for (int i = 0; i < this.mCoefficient.length; i++)
filteredSample += this.mCoefficient[i]+this.mSampleQueue.GetItem(i);
return filteredSample;
}
/**
* Returns the SampleQueue.
*/
public SampleQueue GetSampleQueue() {
return this.mSampleQueue;
}
/**
* Sets the SampleQueue.
*/
public void SetSampleQueue(SampleQueue sampleQueue) {
this.mSampleQueue = sampleQueue;
}
private double mCoefficient[];
private SampleQueue mSampleQueue;
}
|