RealtimeSpectrumAnalyzer
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:46
Real-time spectrum analyzer class
Example
Section titled “Example”import { RealtimeSpectrumAnalyzer } from './SpectrumAnalyzer.js';
const analyzer = new RealtimeSpectrumAnalyzer(canvas, audioContext, { fftSize: 2048, style: 'bars', color: '#00ff88'});
// Connect to audio sourceaudioSource.connect(analyzer.getAnalyserNode());analyzer.start();Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new RealtimeSpectrumAnalyzer(
canvas,audioContext,options?):RealtimeSpectrumAnalyzer
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:47
Parameters
Section titled “Parameters”canvas
Section titled “canvas”any
audioContext
Section titled “audioContext”any
options?
Section titled “options?”Returns
Section titled “Returns”RealtimeSpectrumAnalyzer
Properties
Section titled “Properties”analyser
Section titled “analyser”analyser:
any
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:70
animationId
Section titled “animationId”animationId:
number
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:88
audioContext
Section titled “audioContext”audioContext:
any
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:50
canvas
Section titled “canvas”canvas:
any
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:48
ctx:
any
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:49
frequencyData
Section titled “frequencyData”frequencyData:
Uint8Array<any>
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:83
frequencyLabels
Section titled “frequencyLabels”frequencyLabels:
object[]
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:91
freq:
number
label:
string
position
Section titled “position”position:
number
isRunning
Section titled “isRunning”isRunning:
boolean
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:87
options
Section titled “options”options:
object
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:52
barGap
Section titled “barGap”barGap:
number=1
color:
string='#00ff88'
fftSize
Section titled “fftSize”fftSize:
number=2048
gradient
Section titled “gradient”gradient:
any=null
logScale
Section titled “logScale”logScale:
boolean=true
maxDb:
number=-10
minDb:
number=-100
showGrid
Section titled “showGrid”showGrid:
boolean=false
smoothing
Section titled “smoothing”smoothing:
number=0.8
style:
string='bars'
timeData
Section titled “timeData”timeData:
Uint8Array<any>
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:84
Methods
Section titled “Methods”getAnalyserNode()
Section titled “getAnalyserNode()”getAnalyserNode():
AnalyserNode
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:98
Get the analyser node for connecting to audio sources
Returns
Section titled “Returns”AnalyserNode
Web Audio API AnalyserNode
start()
Section titled “start()”start():
void
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:105
Start real-time analysis and rendering
Returns
Section titled “Returns”void
stop()
Section titled “stop()”stop():
void
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:120
Stop real-time analysis
Returns
Section titled “Returns”void
updateOptions()
Section titled “updateOptions()”updateOptions(
newOptions):void
Defined in: packages/pleco-xa/src/scripts/SpectrumAnalyzer.js:132
Update visualization options
Parameters
Section titled “Parameters”newOptions
Section titled “newOptions”any
New options to merge
Returns
Section titled “Returns”void