您好,欢迎访问一九零五行业门户网

使用JavaScript/HTML5实时生成声音

web audio api用于控制音频,允许您选择音频源。您还可以添加效果;创建音频可视化、平移等。
示例您可以尝试运行以下代码片段来生成声音−
// use one context per document. here we are creating one context for one document. you can create for other documents alsovar context = new (window.audiocontext || window.webkitaudiocontext)();// oscillatorvar os = context.createoscillator(); os.type = 'sine'; // sine is the default. so you can also use square, saw tooth, triangleos.frequency.value = 500; // setting the frequency hzos.connect(context.destination); // connecting to the destination// starting the oscillatoros.start(); os.stop(context.currenttime + 5); // stop 5 seconds after the current time
以上就是使用javascript/html5实时生成声音的详细内容。
其它类似信息

推荐信息