analyzeWaveform
analyzeWaveform(
audioBuffer,options?):object
Defined in: packages/pleco-xa/src/scripts/analysis/WaveformData.ts:317
Calculates waveform statistics for analysis
Parameters
Section titled “Parameters”audioBuffer
Section titled “audioBuffer”any
Web Audio API AudioBuffer
options?
Section titled “options?”Analysis options
Returns
Section titled “Returns”object
Statistical analysis of waveform
crestFactor
Section titled “crestFactor”crestFactor:
number
dcOffset
Section titled “dcOffset”dcOffset:
number
duration
Section titled “duration”duration:
any=audioBuffer.duration
dynamicRange
Section titled “dynamicRange”dynamicRange:
number
length
Section titled “length”length:
any=channelData.length
peak:
number
rms:
number
sampleRate
Section titled “sampleRate”sampleRate:
any=audioBuffer.sampleRate
zeroCrossingRate
Section titled “zeroCrossingRate”zeroCrossingRate:
number=zcr
Example
Section titled “Example”import { analyzeWaveform } from './analysis/WaveformData.ts';
const stats = analyzeWaveform(audioBuffer);console.log('Peak amplitude:', stats.peak);console.log('RMS level:', stats.rms);console.log('Dynamic range:', stats.dynamicRange);