有没有办法将内存中的原始数据作为样本添加到 Web Audio Api?我想添加一个 Int8Array (或 Int16Array)作为缓冲区,该缓冲区只有样本,没有 WAV 或 MP3 格式。我尝试过 audioContext.createBuffer 等但没有成功。
像这样的东西:
var buffer = audioContext.createBuffer(1,8192, 22000);
var intArray = new Int8Array(....);
// -- fill intarray
buffer.buffer = intArray;
...
var source = context.createBufferSource();
source.buffer = buffer;
source.connect(context.destination);
Run Code Online (Sandbox Code Playgroud)
如果这是不可能的,是否有一种与 contetx.decodeAudio() 兼容的声音格式,很容易在内存中“模拟”?即只是一个标题或其他东西。