admin管理员组文章数量:1417070
I have two one-second audio sources as follows:
var context = system.AudioContext();
var source = context.createBufferSource();
var audioBuffer1 = context.createBuffer(1, float32Array_1.length, context.sampleRate);
audioBuffer1.getChannelData(0).set(float32Array_1);
var audioBuffer2 = context.createBuffer(1, float32Array_2.length, context.sampleRate);
audioBuffer2.getChannelData(0).set(float32Array_2);
Now I want to play these two audio sources with no delay between them. For a single source I can play the audio with the following code:
source.buffer = audioBuffer1;
source.connect(context.destination);
source.start(0);
How can I attach the second source such that there would be no delay between them.
I have two one-second audio sources as follows:
var context = system.AudioContext();
var source = context.createBufferSource();
var audioBuffer1 = context.createBuffer(1, float32Array_1.length, context.sampleRate);
audioBuffer1.getChannelData(0).set(float32Array_1);
var audioBuffer2 = context.createBuffer(1, float32Array_2.length, context.sampleRate);
audioBuffer2.getChannelData(0).set(float32Array_2);
Now I want to play these two audio sources with no delay between them. For a single source I can play the audio with the following code:
source.buffer = audioBuffer1;
source.connect(context.destination);
source.start(0);
How can I attach the second source such that there would be no delay between them.
Share Improve this question edited Aug 11, 2014 at 8:50 Xan 77.7k18 gold badges197 silver badges217 bronze badges asked Aug 11, 2014 at 8:47 BelaviyoBelaviyo 1872 silver badges11 bronze badges 2- Is the idea that you want to play them simultaneously, or that you want them to play sequentially ? – Kevin Ennis Commented Aug 11, 2014 at 15:48
- The idea is to play them sequentially with no glitch. – Belaviyo Commented Aug 11, 2014 at 19:04
1 Answer
Reset to default 6var context = system.AudioContext();
var source = context.createBufferSource();
var source2 = context.createBufferSource();
var audioBuffer1 = context.createBuffer(1, float32Array_1.length, context.sampleRate);
audioBuffer1.getChannelData(0).set(float32Array_1);
var audioBuffer2 = context.createBuffer(1, float32Array_2.length, context.sampleRate);
audioBuffer2.getChannelData(0).set(float32Array_2);
source.buffer = audioBuffer1;
source.connect(context.destination);
source2.buffer = audioBuffer2;
source2.connect(context.destination);
var time = context.currentTime;
source.start(time);
source2.start(time+audioBuffer1.duration);
本文标签: javascriptMultiple sources for AudioContext()Stack Overflow
版权声明:本文标题:javascript - Multiple sources for AudioContext() - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745259243a2650278.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论