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.
var 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);