Mar*_*phy 5 ios cordova web-audio-api
我使用Cordova和Web Audio API开发了一个应用程序,允许用户插入耳机,按下手机,并听到自己的心跳.
它通过使用音频过滤节点来实现.
//Setup userMedia
context = new (window.AudioContext||window.webkitAudioContext);
navigator.getUserMedia = (navigator.getUserMedia ||
navigator.webkitGetUserMedia ||
navigator.mozGetUserMedia ||
navigator.msGetUserMedia);
navigator.getUserMedia(
{audio:true},
userMediaSuccess,
function(e) {
alert("error2 " + e.message);
});
function userMediaSuccess(stream)
{
//set microphone as input
input = context.createMediaStreamSource(stream);
//amplify the incoming sounds
volume = context.createGain();
volume.gain.value = 10;
//filter out sounds below 25Hz
lowPass = context.createBiquadFilter();
lowPass.type = 'lowpass';
lowPass.frequency.value = 25;
//filter out sounds above 425Hz
highPass = context.createBiquadFilter();
highPass.type = 'highpass';
highPass.frequency.value = 425;
//apply the filters and amplification to microphone input
input.connect(lowPass);
input.connect(highPass);
input.connect(volume);
//send the result of these filters to the phones speakers
highPass.connect(context.destination);
lowPass.connect(context.destination);
volume.connect(context.destination);
}
Run Code Online (Sandbox Code Playgroud)
当我部署到Android时,它运行良好,但似乎大多数这些功能在iOS移动浏览器上不可用.
我设法使用iosRTC插件制作getUserMedia函数,但createMediaStreamSource仍然"不是函数".
所以,我正在寻找可以过滤掉频率的Web Audio API的替代品,或者如果有任何我可以使用的插件,那将是完美的.
| 归档时间: |
|
| 查看次数: |
1643 次 |
| 最近记录: |