小编Apt*_*ary的帖子

WebAudio scriptProcessorNodes*是否需要连接输出?

这是一个简单的jsFiddle链接,它使用网络音频测量实时输入的响度(它将值作为百分比输出到控制台).

http://jsfiddle.net/XSnsF/

我计划有一个输入而没有输出,因为没有必要延迟我的音频信号等待我的自定义节点完成音量.

但是,很明显,如果连接的话,scriptProcessor 只会记录值context.destination.难道我做错了什么?或者这是一个错误?或者这是预期的行为?

function gotStream(stream) {

    var mediaStreamSource = context.createMediaStreamSource(stream);

    var gainNode = context.createGain();
    gainNode.gain.value = 3;

    var levelChecker = context.createScriptProcessor(2048);

    mediaStreamSource.connect(gainNode);
    gainNode.connect(levelChecker);

    //Commenting out the line directly below stops the script processor from working!
    levelChecker.connect(context.destination);
    levelChecker.onaudioprocess = process;

}

function process(e) {
    var buffer = e.inputBuffer.getChannelData(0);

    var maxVal = 0;

    for (var i = 0; i < buffer.length; i++) {

        if (maxVal < buffer[i]) {
            maxVal = buffer[i];
        }
    }

    console.log(Math.round(maxVal * 100) + …
Run Code Online (Sandbox Code Playgroud)

nodes scriptprocessor web-audio-api

2
推荐指数
1
解决办法
399
查看次数

标签 统计

nodes ×1

scriptprocessor ×1

web-audio-api ×1