構建基于瀏覽器的合成器JavaScript工具包:Beep.js
Beep是一個 JavaScript 框架用于構建基于瀏覽器的合成器,使用了WebAudio API。
var trigger = new BEEP.Trigger( '2Eb', function(){// Let’s call this our “Foundation Voice” // because it will sing the intended Note. this.voices.push( new BEEP.Voice( this.note, this.audioContext ) .setOscillatorType( 'sine' ) .setGainHigh( 0.4 ) ) // This Voice will sing a Perfect 5th above the Foundation Voice. this.voices.push( new BEEP.Voice( this.note.hertz * 3 / 2, this.audioContext ) .setOscillatorType( 'triangle' ) .setGainHigh( 0.1 ) ) // This Voice will sing 2 octaves above the Foundation Voice. this.voices.push( new BEEP.Voice( this.note.hertz * 4, this.audioContext ) .setOscillatorType( 'sawtooth' ) .setGainHigh( 0.01 ) ) // This Voice will sing 1 octave below the Foundation Voice. this.voices.push( new BEEP.Voice( this.note.hertz / 2, this.audioContext ) .setOscillatorType( 'square' ) .setGainHigh( 0.01 ) )
})</pre>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!