EZ Web Audio / createAnalyzer
Function: createAnalyzer()
Call Signature
createAnalyzer(
options?):Promise<Analyzer>
Defined in: packages/core/src/index.ts:898
Create an Analyzer for audio visualization.
The context-free overload uses the shared AudioContext created by the library, so you do not need to obtain an AudioContext manually.
Parameters
options?
Optional analyzer configuration (fftSize, minDecibels, maxDecibels, smoothingTimeConstant)
Returns
Promise<Analyzer>
Analyzer instance
Example
import { createAnalyzer } from 'ez-web-audio'
// Context-free — no AudioContext needed
const analyzer = await createAnalyzer({ fftSize: 1024 })
sound.setAnalyzer(analyzer)
// With explicit AudioContext
const ctx = await getAudioContext()
const analyzer2 = await createAnalyzer(ctx, { fftSize: 2048 })
function visualize() {
const freqData = analyzer.getFrequencyData()
// Use freqData for visualization
requestAnimationFrame(visualize)
}
visualize()Call Signature
createAnalyzer(
audioContext,options?):Promise<Analyzer>
Defined in: packages/core/src/index.ts:899
Create an Analyzer for audio visualization.
The context-free overload uses the shared AudioContext created by the library, so you do not need to obtain an AudioContext manually.
Parameters
audioContext
BaseAudioContext
options?
Optional analyzer configuration (fftSize, minDecibels, maxDecibels, smoothingTimeConstant)
Returns
Promise<Analyzer>
Analyzer instance
Example
import { createAnalyzer } from 'ez-web-audio'
// Context-free — no AudioContext needed
const analyzer = await createAnalyzer({ fftSize: 1024 })
sound.setAnalyzer(analyzer)
// With explicit AudioContext
const ctx = await getAudioContext()
const analyzer2 = await createAnalyzer(ctx, { fftSize: 2048 })
function visualize() {
const freqData = analyzer.getFrequencyData()
// Use freqData for visualization
requestAnimationFrame(visualize)
}
visualize()