admin管理员组文章数量:1292385
I have audio files and I am using Web Audio API to play them on browser. Now I want to play all the audio files simultaneously.
I got audio buffers for all the audio files using Web Audio API. I can loop through all and can play them but I want to merge all the audio buffers into one single audio buffer and then play it.
Does anyone have an idea to merge two audio buffers in Web Audio API?
I have audio files and I am using Web Audio API to play them on browser. Now I want to play all the audio files simultaneously.
I got audio buffers for all the audio files using Web Audio API. I can loop through all and can play them but I want to merge all the audio buffers into one single audio buffer and then play it.
Does anyone have an idea to merge two audio buffers in Web Audio API?
Share Improve this question edited Aug 13, 2019 at 8:10 Sylens 1,1778 silver badges31 bronze badges asked Jan 20, 2016 at 10:51 user3759750user3759750 1533 silver badges10 bronze badges3 Answers
Reset to default 3If you want to play all of the simultaneously, just connect each of your buffers to context.destination
(or most any other node that is connected to the destination) and start them all at the same time.
If you sum two or more audio PCM arrays, i.e. buffer1[i] + buffer2[i] for each sample, you will have a third audio containing both sounding together.
You can even use a multiply factor over each track to control its volume, for example.
Hope this helps. This is just the begining.
If you need just to play it you should to connect both of sources to destination.
To really merge two buffers into another one, you can use offlineAudioContext or merge arrays yourself like this https://github./audiojs/audio-buffer-utils
本文标签: javascriptWeb Audio APImerge two audio buffersStack Overflow
版权声明:本文标题:javascript - Web Audio API - merge two audio buffers - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741555581a2385134.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论