import { default as OptionInterface } from './interfaces/OptionInterface'; import { INorm } from '@thi.ng/random'; import { NoiseType } from './NoiseType'; /** * Reverb effect class */ export default class Reverb { /** Version strings */ static readonly version: string; /** Build date */ static readonly build: string; /** AudioContext */ private readonly ctx; /** Wet Level (Reverberated node) */ private readonly wetGainNode; /** Dry Level (Original sound node) */ private readonly dryGainNode; /** Impulse response filter */ private readonly filterNode; /** Convolution node for applying impulse response */ private readonly convolverNode; /** Output gain node */ private readonly outputNode; /** Option */ private readonly options; /** Connected flag */ private isConnected; /** Noise Generator */ private noise; /** * Map of noise types to their respective generator functions. */ private readonly noiseMap; /** * Constructor * * @param ctx - Root AudioContext * @param options - Configure */ constructor(ctx: AudioContext, options?: Partial); /** * Connect the node for the reverb effect to the original sound node. * * @param sourceNode - Input source node */ connect(sourceNode: AudioNode): AudioNode; /** * Disconnect the reverb node * * @param sourceNode - Input source node */ disconnect(sourceNode?: AudioNode): AudioNode | undefined; /** * Dry/Wet ratio * * @param mix - Ratio (0~1) */ mix(mix: number): void; /** * Set Impulse Response time length (second) * * @param value - IR length */ time(value: number): void; /** * Impulse response decay rate. * * @param value - Decay value */ decay(value: number): void; /** * Delay before reverberation starts * * @param value - Time[ms] */ delay(value: number): void; /** * Reverse the impulse response. * * @param reverse - Reverse IR */ reverse(reverse: boolean): void; /** * Filter for impulse response * * @param type - Filiter Type */ filterType(type?: BiquadFilterType): void; /** * Filter frequency applied to impulse response * * @param freq - Frequency */ filterFreq(freq: number): void; /** * Filter quality. * * @param q - Quality */ filterQ(q: number): void; /** * set IR source noise peaks * * @param p - Peaks */ peaks(p: number): void; /** * set IR source noise scale. * * @param s - Scale */ scale(s: number): void; /** * Noise source * * @param duration - length of IR. */ private getNoise; /** * Inpulse Response Noise algorithm. * * @param type - IR noise algorithm type. */ setNoise(type: NoiseType): void; /** * Set the random number algorithm used for noise generation. * * @param algorithm - Random algorithm implementing {@link INorm} */ setRandomAlgorithm(algorithm: INorm): void; /** * Return true if in range, otherwise false * * @param x - Target value * @param min - Minimum value * @param max - Maximum value */ private static inRange; /** Builds the impulse response buffer from the current options. */ private buildImpulse; }