Add Chain effect to connect effects together

This commit is contained in:
2019-07-22 10:43:53 +01:00
parent 146bf5a3c2
commit 732894a0fb
2 changed files with 73 additions and 0 deletions

View File

@@ -2715,6 +2715,11 @@ public class AudiobookRecorder extends JFrame {
if (eff != null) {
group.addEffect(eff);
}
} else if (e.getTagName().equals("chain")) {
Effect eff = (Effect)loadChain(e);
if (eff != null) {
group.addEffect(eff);
}
} else if (e.getTagName().equals("group")) {
Effect eff = (Effect)loadEffectGroup(e);
if (eff != null) {
@@ -2815,6 +2820,11 @@ public class AudiobookRecorder extends JFrame {
if (eff != null) {
store.addEffect(eff);
}
} else if (ie.getTagName().equals("chain")) {
Effect eff = (Effect)loadChain(ie);
if (eff != null) {
store.addEffect(eff);
}
} else if (ie.getTagName().equals("group")) {
Effect eff = (Effect)loadEffectGroup(ie);
if (eff != null) {
@@ -2850,6 +2860,11 @@ public class AudiobookRecorder extends JFrame {
return a;
}
public Chain loadChain(Element root) {
Chain c = new Chain(root.getAttribute("src"));
return c;
}
public Pan loadPan(Element root) {
Pan p = new Pan(Utils.s2d(root.getAttribute("pan")));
return p;

View File

@@ -0,0 +1,58 @@
package uk.co.majenko.audiobookrecorder;
import java.util.ArrayList;
public class Chain implements Effect {
String target;
public Chain(String t) {
target = t;
}
public Chain() {
target = null;
}
public void process(Sample[] samples) {
if (target != null) {
Effect t = AudiobookRecorder.window.effects.get(target);
if (t != null) {
t.process(samples);
}
}
}
public void setTarget(String t) {
target = t;
}
public String getTarget() {
return target;
}
public String toString() {
return "Chain to " + target;
}
public void dump() {
System.out.println(toString());
}
public void init(double sf) {
if (target != null) {
Effect t = AudiobookRecorder.window.effects.get(target);
if (t != null) {
t.init(sf);
}
}
}
public ArrayList<Effect> getChildEffects() {
return null;
}
public String getName() {
return toString();
}
}