Open mr-spaghetti-code opened 3 years ago
I managed to fix this. When you use the 'sound' component to attach audio to an entity, you're actually using the audio entity THREE.Audio( listener ). The solution is to retrieve the 'sound' child attached to the entity using getObject3D('sound').children[0]
.
So the initContext function should look like this:
initContext: function () {
const data = this.data;
console.log(this.el)
console.log(this.el.getObject3D('sound'))
const sound = this.el.getObject3D('sound').children[0]
const threeAnalyser = new THREE.AudioAnalyser(sound, data.fftSize)
const analyser = (this.analyser = threeAnalyser.analyser)
analyser.smoothingTimeConstant = data.smoothingTimeConstant;
this.context = this.el.sceneEl.audioListener.context
this.levels = new Uint8Array(analyser.frequencyBinCount);
this.waveform = new Uint8Array(analyser.fftSize);
},
Note that this makes "src" redundant.
Hi there,
I am having trouble getting any data about my audio when I play the audio using the "sound" component attached to an entity.
For example, this does not work (note that I use the "sound" component and point it to #vocals):
But this does:
Do you know how I might be able to fix this?
Thanks so much. Happy to provide more examples.