Skip to content

Commit d4e0cd8

Browse files
authored
Update EMAFilter.java
Removed Trailing spaces from EMAFilter.java
1 parent fcb8102 commit d4e0cd8

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

src/main/java/com/thealgorithms/audiofilters/EMAFilter.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
* <p>Based on the definition from
1111
* <a href="https://en.wikipedia.org/wiki/Moving_average">Wikipedia link</a>.
1212
*/
13-
public class EMAFilter {
14-
13+
public class EMAFilter {
1514
private final double alpha;
1615
private double emaValue;
17-
1816
/**
1917
* Constructs an EMA filter with a given smoothing factor.
2018
*
@@ -28,7 +26,6 @@ public EMAFilter(double alpha) {
2826
this.alpha = alpha;
2927
this.emaValue = 0.0;
3028
}
31-
3229
/**
3330
* Applies the EMA filter to an audio signal array.
3431
*
@@ -39,16 +36,14 @@ public double[] apply(double[] audioSignal) {
3936
if (audioSignal.length == 0) {
4037
return new double[0];
4138
}
42-
4339
double[] emaSignal = new double[audioSignal.length];
4440
emaValue = audioSignal[0];
4541
emaSignal[0] = emaValue;
46-
42+
4743
for (int i = 1; i < audioSignal.length; i++) {
4844
emaValue = alpha * audioSignal[i] + (1 - alpha) * emaValue;
4945
emaSignal[i] = emaValue;
5046
}
51-
5247
return emaSignal;
5348
}
5449
}

0 commit comments

Comments
 (0)