-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGainFilter.java
More file actions
52 lines (47 loc) · 1010 Bytes
/
GainFilter.java
File metadata and controls
52 lines (47 loc) · 1010 Bytes
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
package aoop;
/**
* Gain filter. modifies amplitude of sound
* @author Erik and Daniel
*/
public class GainFilter implements ScalableFilter{
/**
* sets scale of filter
* rescales to scale/33
* @param scale Value of 0 to 100
*/
@Override
public void setScale(double scale)
{
scale /= 33;
if(scale >= 0)
{
gain = scale;
}
else
{
gain = 0.0;
}
}
/**
* Applies filter to Sample s
* @param s sound sample to filter
* @return
*/
@Override
public Sample apply(Sample s){
double[] d = s.toArray();
for(int i = 0; i < d.length; i++){
d[i] *= gain;
}
return new Sample(d);
}
/**
* Name of filter
* @return name of filter
*/
public String getName()
{
return "Gain";
}
private double gain;
}