2013-04-04 59 views

回答

1

你不保存您的實際節點,只是價值 - 所以,當你嘗試連接到oscillator.frequency,你傳遞一個整數值(400 - 你保存的頻率在節點中)。嘗試http://jsfiddle.net/GCSEq/6/ - 這存儲節點,並正確路由到AudioParam。

this.oscillator = context.createOscillator(); 
this.gain = context.createGainNode(); 

和 osctest2.play(osctest.oscillator.frequency,1000);

(你在控制檯得到一個錯誤。)

+0

我得到一個錯誤,說:「未捕獲的InvalidStateError:無法執行'開始'上的'振盪器節點':不能多次啓動啓動「。當多次使用啓動和停止功能時。在停止振盪器之後是否有辦法停止和啓動振盪器?我正在嘗試製作一個音序器。 – Emanegux 2014-02-14 00:44:56

7

https://coderwall.com/p/h1jnmg

var saw = context.createOscillator(), 
     sine = context.createOscillator(), 
     sineGain = context.createGainNode(); 

//set up our oscillator types 
saw.type = saw.SAWTOOTH; 
sine.type = sine.SINE; 

//set the amplitude of the modulation 
sineGain.gain.value = 10; 

//connect the dots 
sine.connect(sineGain); 
sineGain.connect(saw.frequency); 
+0

感謝它的工作。 – zya 2013-04-04 21:58:03

+0

但即時通訊嘗試使一個易於使用的對象構造函數具有良好的路由功能。似乎我無法將第二個瞬間的輸出傳遞給第一個。看看:http://jsfiddle.net/ehsanziya/GCSEq/2/ – zya 2013-04-04 22:01:07

+0

嗯,不 - 你不能直接把 – cwilso 2013-04-05 03:54:12