I developed an application using Cordova and a web audio API that allows the user to plug in headphones, press the phone on their heart and hear their own heartbeat.
He does this 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 works great when deployed to Android, but it seems most of these features are not available in iOS mobile browsers.
I managed to create the 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 plugins that I could use, that would be great.
source share