Wednesday, 12 June 2019

get data from thumb oximeter through microphone jack using javascript

I have an old oximeter(the kind that attaches to your thumb). I wanted to see if I could plug it in to the microphone jack on my PC and stream the data to an iFrame using the getUserMedia API.

here is the JS I have so far:

window.AudioContext = window.AudioContext ||
                  window.webkitAudioContext;

const context = new AudioContext();

navigator.mediaDevices.getUserMedia({audio: true}).
then((stream) => {
    const microphone = context.createMediaStreamSource(stream);
    const filter = context.createBiquadFilter();

    microphone.connect(filter);

    var frame = createEle("iframe");//createEle is just create element function from my library

    frame.sandbox = "allow-scripts";
    updateFrame();

    function updateFrame(){
        setTimeout(function(){
            frame.srcdoc = filter.context.listener.value;//i want frame to display oximeter value and refresh every second
            console.log(filter.context.listener);
            updateFrame();
        },1000);
    }
    heartPage.append(frame);//heartPage is just a static element on my page
});



from get data from thumb oximeter through microphone jack using javascript

No comments:

Post a Comment