Beep.js 介绍
Beep.js 是一款使用 WebAudio API 基于浏览器的 JavaScript 工具包,用来开发声音合成应用。你可以使用它来做一个电子琴。
示例:
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 ) ) })
Beep.js 官网
https://github.com/stewdio/beep.js
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。