UNPKG

react-native-audio-api

Version:

react-native-audio-api provides system for controlling audio in React Native environment compatible with Web Audio API specification

36 lines (32 loc) 1.17 kB
import { NotSupportedError } from '../errors'; import AudioNode from './AudioNode.web'; import { IIRFilterOptions } from '../types'; import BaseAudioContext from './BaseAudioContext.web'; export default class IIRFilterNode extends AudioNode { constructor(context: BaseAudioContext, options: IIRFilterOptions) { const iirFilterNode = new globalThis.IIRFilterNode( context.context, options ); super(context, iirFilterNode); } public getFrequencyResponse( frequencyArray: Float32Array<ArrayBuffer>, magResponseOutput: Float32Array<ArrayBuffer>, phaseResponseOutput: Float32Array<ArrayBuffer> ) { if ( frequencyArray.length !== magResponseOutput.length || frequencyArray.length !== phaseResponseOutput.length ) { throw new NotSupportedError( `The lengths of the arrays are not the same frequencyArray: ${frequencyArray.length}, magResponseOutput: ${magResponseOutput.length}, phaseResponseOutput: ${phaseResponseOutput.length}` ); } (this.node as globalThis.IIRFilterNode).getFrequencyResponse( frequencyArray, magResponseOutput, phaseResponseOutput ); } }