react-native-audio-api
Version:
react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification
30 lines (29 loc) • 997 B
JavaScript
;
import AudioScheduledSourceNode from "./AudioScheduledSourceNode.js";
import AudioParam from "./AudioParam.js";
import { InvalidStateError } from "../errors/index.js";
export default class OscillatorNode extends AudioScheduledSourceNode {
constructor(context, options) {
if (options?.periodicWave) {
options.type = 'custom';
}
const node = context.context.createOscillator(options || {});
super(context, node);
this.frequency = new AudioParam(node.frequency, context);
this.detune = new AudioParam(node.detune, context);
this.type = node.type;
}
get type() {
return this.node.type;
}
set type(value) {
if (value === 'custom') {
throw new InvalidStateError("'type' cannot be set directly to 'custom'. Use setPeriodicWave() to create a custom Oscillator type.");
}
this.node.type = value;
}
setPeriodicWave(wave) {
this.node.setPeriodicWave(wave.periodicWave);
}
}
//# sourceMappingURL=OscillatorNode.js.map