|
|
|
@@ -0,0 +1,32 @@ |
|
|
|
import Filter from "./Filter"; |
|
|
|
import { context, exposedNumber } from "../audio"; |
|
|
|
export default class StereoWidthFilter extends Filter { |
|
|
|
public kind = "Stereo Width"; |
|
|
|
private mono: GainNode; |
|
|
|
private stereo: GainNode; |
|
|
|
|
|
|
|
@exposedNumber("Width", 0, 1) |
|
|
|
public width = 1; |
|
|
|
|
|
|
|
constructor() { |
|
|
|
super("Stereo Width"); |
|
|
|
this.mono = context.createGain(); |
|
|
|
this.stereo = context.createGain(); |
|
|
|
|
|
|
|
this.mono.channelCount = 1; |
|
|
|
this.mono.channelCountMode = "explicit"; |
|
|
|
this.mono.gain.value = 1 - this.width; |
|
|
|
this.stereo.gain.value = this.width; |
|
|
|
|
|
|
|
this.filterInput.connect(this.mono); |
|
|
|
this.mono.connect(this.output); |
|
|
|
this.filterInput.connect(this.stereo); |
|
|
|
this.stereo.connect(this.output); |
|
|
|
} |
|
|
|
|
|
|
|
public tick(dt: number): void { |
|
|
|
super.tick(dt); |
|
|
|
this.mono.gain.value = 1 - this.width; |
|
|
|
this.stereo.gain.value = this.width; |
|
|
|
} |
|
|
|
} |