-
Notifications
You must be signed in to change notification settings - Fork 0
0R Getting frequencies and amplitudes from audio source
Luis Murillo Baltodano edited this page Aug 2, 2020
·
1 revision
analyzer = analyseAudio(audio)
Make sure you call this function after an user input, like a click or another type of event because there might be problems with autoplay blocking for media sources
analyzer.getFrequencies()
analyzer.getAmplitudes()
These will return a 1024 elements long array full of frequencies or amplitudes
analyzer.getFrequencies().average
analyzer.getAmplitudes().average
let analyser
preset(({analyseAudio, setAudioToggle}) => {
setAudioToggle({
src: 'https://luisarmando-testcoder.github.io/keeper/mp3/moving.mp3'
}, audio => {
if (!analyser) analyser = analyseAudio(audio)
// To avoid reasining the analyzer if it is already connected previously to a different MediaElementSourceNode
})
})