Update framework

This commit is contained in:
2022-11-26 02:22:02 +01:00
parent 9a6ce1f832
commit ae057940af
508 changed files with 26011 additions and 14248 deletions

View 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;
}

View 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();
}
}

View 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;
}

View 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;
}
}