我使用 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);
}
当我部署到 Android 时,它运行良好,但似乎大多数功能在 iOS 移动浏览器上不可用。
我设法使用 getUserMedia 函数iosRTC 插件 https://github.com/eface2face/cordova-plugin-iosrtc,但 createMediaStreamSource 仍然“不是一个函数”。
因此,我正在寻找 Web Audio API 的替代方案,可以过滤掉频率,或者如果有任何我可以使用的插件,那将是完美的。
在 ios 网络上没有办法做到这一点。您需要一个本机应用程序,因为 Apple 不支持 safari 中的音频输入。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)