2
我正在使用網絡音頻隨機振盪器,並且遇到了scriptProcessorNode問題。我的算法使用隨機遊走來確定波形中的動態斷點,然後在它們之間進行插值。腳本處理器節點振盪器頻率
隨着斷點在x軸上的移動,我認爲振盪波形的頻率會改變,但這只是一種濾波效果,頻率似乎只是由scriptProcessorNode緩衝區大小決定的,它必須是一個功率2介於256和16384之間。
如何更改scriptProcessorNode振盪器的頻率?
這裏是我的合成代碼:
scriptNode.onaudioprocess = function(audioProcessingEvent) {
walk(); //use random walk to generate new x/y position for each breakpoint
var outputBuffer = audioProcessingEvent.outputBuffer;
var lastPoint = 0;
var index = 0;
// linearly interpolate between the new breakpoint positions
for(var i = 0; i < breakpoint.length-1; i++) {
var y = breakpoint[lastPoint].y;
for(var channel = 0; channel <= 0;channel++) {
var outputData = outputBuffer.getChannelData(channel);
if(i != 0){
if(y >= breakpoint[i].y) {
while(y >= breakpoint[i].y) {
y = (breakpoint[i].m*index)+breakpoint[i].b;// y = m(x)+b
outputData[index] = y;
index++;
}
} else if(y <= breakpoint[i].y) {
while(y <= breakpoint[i].y) {
y = (breakpoint[i].m*index)+breakpoint[i].b;
outputData[index] = y;
index++;
}
}
}
}
lastPoint = i;
}
}
這裏是工作示例的鏈接:http://andrewbernste.in/bernie/gendy011.html
在恩尼斯·克塞諾基斯GENDY隨機合成程序這是所有基於。
謝謝!
它從代碼似乎'M'應該改變頻率吧? – notthetup
@notthetup'm'是等式'y = m(x)+ b'中的斜率,用於在每個點之間進行線性插值。我正在嘗試將'scriptNode.bufferSize'與波形寫入緩衝區的頻率分開。我一直在研究這個例子,使一個scriptProcessorNode振盪器的音調與緩衝區無關,但我還沒有破解它。 http://sriku.org/blog/2013/01/30/taming-the-scriptprocessornode/#replacing-oscillator-with-scriptprocessornode。任何指導將不勝感激! –