[英]Does the number of hidden nodes in the fully connected layer has to be equal to the number of output categories?
[英]Do WebAudio scriptProcessorNodes *require* an output to be connected?
這是指向簡單jsFiddle的鏈接,該jsFiddle使用Web音頻測量實時輸入的響度(它將值作為百分比輸出到控制台)。
我原本打算只有一個輸入而沒有任何輸出,因為不需要延遲音頻信號等待我的自定義節點完成音量計算。
但是,很明顯,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) + "%");
}
這是Blink&Webkit實現中的錯誤。 根據規范:“僅當ScriptProcessorNode連接了至少一個輸入或一個輸出時,才調度音頻過程事件。” 不需要兩者。
現在,只需將其連接到連接到audiocontext.destination的零增益GainNode。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.