小编Mar*_*phy的帖子

适用于iOS的AudioContext.createMediaStreamSource替代方案?

我使用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 …
Run Code Online (Sandbox Code Playgroud)

ios cordova web-audio-api

5
推荐指数
1
解决办法
1643
查看次数

标签 统计

cordova ×1

ios ×1

web-audio-api ×1