audioContext振荡器停止工作 [英] audioContext Oscillator stopped working

查看:193
本文介绍了audioContext振荡器停止工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Chrome中完美运行的代码存在问题,但现在我认为由于Chrome更新它停止了运行。

I have a problem with the code that worked perfectly in Chrome but nowadays I assume due to Chrome update it stopped working.

var audioContext = new(window.audioContext || window.webkitAudioContext);
var oscillator = audioContext.createOscillator();
oscillator.type = 0;
oscillator.connect(audioContext.destination);
oscillator.noteOn(0);
setTimeout(function () {
   oscillator.noteOff(0);
}, 5000 );

错误讯息如下:

The error message is the following

The provided value '0' is not a valid enum value of interface OscillatorType.
Uncaught TypeError: oscillator.noteOn is not a function

我没有发现任何线索为什么这停止工作。
我感谢您的帮助。

I didn't find any clue why this stopped working. I appreciate you help.

推荐答案

振荡器类型的有效值为'正弦','方形','锯齿','三角形'。一些浏览器也实现了'自定义'。

Valid values for oscillator.type are 'sine', 'square', 'sawtooth', 'triangle'. Some browsers also implement 'custom'.

http://webaudio.github.io/web-audio-api/#attributes-28

这篇关于audioContext振荡器停止工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆