Update framework
This commit is contained in:
15
framework/resonator/effects/base-effect.d.ts
vendored
Normal file
15
framework/resonator/effects/base-effect.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
import ResonatorAudioContext from '../audio-context';
|
||||
import AudioGraph from '../audio-graph';
|
||||
export default class BaseEffect {
|
||||
protected ready: boolean;
|
||||
protected effectNode: any;
|
||||
protected effectParams: any;
|
||||
protected context: ResonatorAudioContext;
|
||||
protected graph: AudioGraph;
|
||||
protected inputNode: AudioNode;
|
||||
constructor(context: ResonatorAudioContext, graph: AudioGraph, params: any);
|
||||
connectOutput(node: AudioNode): void;
|
||||
connectInput(node: AudioNode): void;
|
||||
getOutput(): AudioNode;
|
||||
disconnect(): void;
|
||||
}
|
23
framework/resonator/effects/base-effect.js
Normal file
23
framework/resonator/effects/base-effect.js
Normal file
@@ -0,0 +1,23 @@
|
||||
export default class BaseEffect {
|
||||
constructor(context, graph, params) {
|
||||
this.graph = graph;
|
||||
this.context = context;
|
||||
this.effectParams = params;
|
||||
}
|
||||
connectOutput(node) {
|
||||
this.effectNode.connect(node);
|
||||
}
|
||||
connectInput(node) {
|
||||
this.inputNode = node;
|
||||
if (this.effectNode) {
|
||||
this.inputNode.connect(this.effectNode);
|
||||
}
|
||||
}
|
||||
getOutput() {
|
||||
return this.effectNode;
|
||||
}
|
||||
disconnect() {
|
||||
this.inputNode.disconnect();
|
||||
this.effectNode.disconnect();
|
||||
}
|
||||
}
|
10
framework/resonator/effects/convolver.d.ts
vendored
Normal file
10
framework/resonator/effects/convolver.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import BaseEffect from './base-effect';
|
||||
import ResonatorAudioContext from '../audio-context';
|
||||
import AudioGraph from '../audio-graph';
|
||||
export default class Convolver extends BaseEffect {
|
||||
private buffer;
|
||||
private channelSplitter;
|
||||
private channelMerger;
|
||||
constructor(context: ResonatorAudioContext, graph: AudioGraph, params: any);
|
||||
connectInput(node: AudioNode): void;
|
||||
}
|
20
framework/resonator/effects/convolver.js
Normal file
20
framework/resonator/effects/convolver.js
Normal file
@@ -0,0 +1,20 @@
|
||||
import BaseEffect from './base-effect';
|
||||
export default class Convolver extends BaseEffect {
|
||||
constructor(context, graph, params) {
|
||||
super(context, graph, params);
|
||||
console.log(`Creating convolver`);
|
||||
this.effectNode = this.context.getContext().createConvolver();
|
||||
this.effectNode.buffer = this.effectParams.buffer;
|
||||
}
|
||||
connectInput(node) {
|
||||
this.channelSplitter = this.context.getContext().createChannelSplitter(2);
|
||||
this.channelMerger = this.context.getContext().createChannelMerger(2);
|
||||
this.channelSplitter.connect(this.channelMerger, 0, 0);
|
||||
this.channelSplitter.connect(this.channelMerger, 1, 0);
|
||||
this.channelSplitter.connect(this.channelMerger, 0, 1);
|
||||
this.channelSplitter.connect(this.channelMerger, 1, 1);
|
||||
node.connect(this.channelSplitter);
|
||||
this.channelMerger.connect(this.effectNode);
|
||||
this.inputNode = node;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user