Javascript Web音频上下文和缓冲区的最大输出数是多少
我正在尝试创建一个程序,它可以在一个缓冲区中将音频输出到任意数量的通道。我在Mac上使用Chrome43.0.2339.0金丝雀(64位)。我要输出到的硬件是一个MOTU16A,它能够通过thunderbolt连接实现128个IO通道。我已经创建了一支钢笔(基于一个修改过的MDN示例),它演示了我试图实现的目标: 以及守则:Javascript Web音频上下文和缓冲区的最大输出数是多少,javascript,audio,html5-audio,web-audio-api,Javascript,Audio,Html5 Audio,Web Audio Api,我正在尝试创建一个程序,它可以在一个缓冲区中将音频输出到任意数量的通道。我在Mac上使用Chrome43.0.2339.0金丝雀(64位)。我要输出到的硬件是一个MOTU16A,它能够通过thunderbolt连接实现128个IO通道。我已经创建了一支钢笔(基于一个修改过的MDN示例),它演示了我试图实现的目标: 以及守则: var audioCtx = new (window.AudioContext || window.webkitAudioContext)(); var button =
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var button = document.querySelector('button');
audioCtx.destination.channelCount = 8
var channels = audioCtx.destination.channelCount;
// Create an empty half-second buffer at the
// sample rate of the AudioContext
var frameCount = audioCtx.sampleRate * 0.5;
button.onclick = function(){
var myArrayBuffer = audioCtx.createBuffer(audioCtx.destination.channelCount, frameCount, audioCtx.sampleRate);
// Fill the buffer with white noise;
//just random values between -1.0 and 1.0
for (var channel = 0; channel < channels; channel++) {
// This gives us the actual ArrayBuffer that contains the data
var nowBuffering = myArrayBuffer.getChannelData(channel);
for (var i = 0; i < frameCount; i++) {
// Math.random() is in [0; 1.0]
// audio needs to be in [-1.0; 1.0]
nowBuffering[i] = Math.random() * 2 - 1;
}
}
// Get an AudioBufferSourceNode.
// This is the AudioNode to use when we want to play an AudioBuffer
var source = audioCtx.createBufferSource();
// set the buffer in the AudioBufferSourceNode
source.buffer = myArrayBuffer;
// connect the AudioBufferSourceNode to the
// destination so we can hear the sound
source.connect(audioCtx.destination);
// start the source playing
source.start();
}
var audioCtx=new(window.AudioContext | | window.webkitadiocontext)();
var button=document.querySelector('button');
audioCtx.destination.channelCount=8
var通道=audioCtx.destination.channelCount;
//在指定位置创建一个空的半秒缓冲区
//音频上下文的采样率
var frameCount=audioCtx.sampleRate*0.5;
button.onclick=函数(){
var myArrayBuffer=audioCtx.createBuffer(audioCtx.destination.channelCount、frameCount、audioCtx.sampleRate);
//用白噪声填充缓冲器;
//只是-1.0和1.0之间的随机值
用于(var通道=0;通道<通道;通道++){
//这将为我们提供包含数据的实际ArrayBuffer
var nowBuffering=myArrayBuffer.getChannelData(通道);
对于(变量i=0;i
您会注意到,在第4行中,我显式地将通道数设置为8,即使我的目的地支持128个通道(运行audioCtx.destination.maxChannelCount可以证明这一点)。此功能与预期一样,音频通过管道传输到所有8个通道。但是,每当我将通道数增加到8以上时,任何通道上都没有输出
我的问题是限制在哪里-它在音频缓冲区中吗?音频背景?我的硬件设置?有没有办法克服这些限制并输出到8个以上的通道;正在进行中。这很漂亮。您是否在node.js中运行此功能?这是为了客户端使用。据我所知,Node.js(和IO.js)本机不支持WebAudioAPI。有一个软件包声称是在前阿尔法阶段。这个错误已经被修补了吗?在完全相同的项目上工作此已修补,但如果您遇到问题,请在提交新的错误。如果可以,请确保将组件字段设置为“闪烁>网络音频”。