chrisguttandin / standardized-audio-context

A cross-browser wrapper for the Web Audio API which aims to closely follow the standard.
MIT License
680 stars 33 forks source link

Changing in the gain doesn't always work #967

Closed ziriax closed 3 years ago

ziriax commented 3 years ago

I've been struggling for days with the following issue:

this.gainNode.gain.value = volume doesn't always work, the volume is often not changed.

this.gainNode.gain.setValueAtTime(volume, this.gainNode.context.currentTime + 0.1) does always work... Changing the 0.1 into a smaller number breaks it more often. (edited: didn't really help)

I'm using Chrome 87 on Windows 10 x64

I noticed the problem only seems to occur when using IMediaElementAudioSourceNode as a source, using an audio buffer works fine.

Any hints? I don't have reproducible code right now, could try.

ziriax commented 3 years ago

I have the same issue with the plain web audio API, so I this has nothing to do with this nice library.

Most likely a bug in my code.

Closing, sorry for the noise.

chrisguttandin commented 3 years ago

Hi Peter, since you mentioned that you're using a MediaElementAudioSourceNode I guess the audio is coming from a media element. Is it possible that the media element itself is still outputting audio on its own? A handy trick to check that is to insert a DelayNode at the end of the Web Audio audio graph to hear the difference.

I hope this helps.

ziriax commented 3 years ago

Thanks for the help, highly appreciated.

It was just a silly bug, the audio element was created more than once, and I was indeed playing the wrong audio element...