AudioContext.createMediaStreamSource alternative for iOS?


#1

I’ve developed an app using Ionic and the Web Audio API, that allows the user to plug in headphones, press the phone against their heart, and hear their own heartbeat.

It does this by using audio filter nodes.

 //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);
}

It runs fine when I deploy to Android, but it seems most of these features aren’t available on iOS mobile browsers.

I managed to make getUserMedia function using the iosRTC plugin, but createMediaStreamSource is still “not a function.”

So, I’m looking for an alternative to the Web Audio API that can filter out frequencies, or if there are any plugins I could use, that would be perfect.


#2

@RarestSolanum, how did you solved your problem? I want to generate sounds by frequency and time, after i want to bypass some filters on it
I didn’t found yet a plugin that could help me achieve this, do you have any suggestion?
Thanks

Edit: I’m pretty new to ionic


#3

@tiagomestreteixeira [1] I couldn’t solve this issue. I ended up
building a separate iOS app using Objective-C to implement the feature I
wanted.

That’s not saying it’s not possible now, since this was almost a year
ago, but if Safari still doesn’t support this feature then it’s unlikely
there’s anything you can do about it.