react-native-audio-api
Version:
react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification
38 lines (37 loc) • 1.03 kB
JavaScript
;
import AudioNode from "./AudioNode.js";
import { InvalidStateError } from "../errors/index.js";
export default class WaveShaperNode extends AudioNode {
isCurveSet = false;
_curve = null;
constructor(context, options) {
const node = context.context.createWaveShaper(options || {});
super(context, node);
if (options?.curve) {
this._curve = options.curve;
this.isCurveSet = true;
}
}
get curve() {
return this._curve;
}
get oversample() {
return this.node.oversample;
}
set curve(curve) {
if (curve !== null) {
if (this.isCurveSet) {
throw new InvalidStateError('The curve can only be set once and cannot be changed afterwards.');
}
if (curve.length < 2) {
throw new InvalidStateError('The curve must have at least two values if not null.');
}
this.isCurveSet = true;
}
this.node.setCurve(curve);
}
set oversample(value) {
this.node.oversample = value;
}
}
//# sourceMappingURL=WaveShaperNode.js.map