Added clipping filter

This commit is contained in:
2019-07-14 22:15:10 +01:00
parent 4dd3a3b874
commit d207d246bf
4 changed files with 74 additions and 0 deletions

12
ExampleFilters/radio.eff Normal file
View File

@@ -0,0 +1,12 @@
<effect name="Radio">
<biquad type="notch" fc="140" q="20" gain="-50" />
<amplifier gain="0.1" />
<biquad type="peak" fc="1000" q="10" gain="45" />
<lfo frequency="5000" depth="0.3" />
<clipping clip="0.3" />
<biquad type="highshelf" fc="8000" q="1" gain="-20" />
<delayline>
<delay samples="100" gain="0.7" />
<delay samples="200" gain="0.5" />
</delayline>
</effect>

View File

@@ -14,6 +14,7 @@ public class AGC implements Effect {
attack = a;
decay = d;
limit = l;
gain = 1d;
}
public String getName() {

View File

@@ -2654,6 +2654,11 @@ System.err.println(format);
if (eff != null) {
group.addEffect(eff);
}
} else if (e.getTagName().equals("clipping")) {
Effect eff = (Effect)loadClipping(e);
if (eff != null) {
group.addEffect(eff);
}
}
}
}
@@ -2739,6 +2744,11 @@ System.err.println(format);
if (eff != null) {
store.addEffect(eff);
}
} else if (ie.getTagName().equals("clipping")) {
Effect eff = (Effect)loadClipping(ie);
if (eff != null) {
store.addEffect(eff);
}
}
}
}
@@ -2754,6 +2764,11 @@ System.err.println(format);
return a;
}
public Clipping loadClipping(Element root) {
Clipping c = new Clipping(Utils.s2d(root.getAttribute("clip")));
return c;
}
public LFO loadLFO(Element root) {
double f = Utils.s2d(root.getAttribute("frequency"));
double d = Utils.s2d(root.getAttribute("depth"));

View File

@@ -0,0 +1,46 @@
package uk.co.majenko.audiobookrecorder;
import java.util.ArrayList;
public class Clipping implements Effect {
double clip;
public Clipping() {
clip = 1.0d;
}
public Clipping(double g) {
clip = g;
}
public String getName() {
return "Clipping (" + clip + ")";
}
public ArrayList<Effect> getChildEffects() {
return null;
}
public double process(double sample) {
if (sample > clip) return clip;
if (sample < -clip) return -clip;
return sample;
}
public double getClip() {
return clip;
}
public void setClip(double g) {
clip = g;
}
public String toString() {
return getName();
}
public void dump() {
System.out.println(toString());
}
public void init(double sf) {
}
}