How to get real-time microphone levels with Phonegap/Cordova?
Asked Answered
K

1

6

I am looking for a way to read volume data in real-time from the microphone. Just some kind of general "loudness". The purpose is to make lips move when you talk into the microphone on an html5 canvas element...

I basically want this plugin but for microphone levels instead of the camera:

https://github.com/casoninabox/luminance-cordova-ios

Does anyone know of any existing libraries to do this or how I might go about creating a plugin for iOS? I'm guessing it would involve the AVAudioSession?

Kaleb answered 20/1, 2015 at 17:45 Comment(6)
Why don't you write your own? :)Canotas
Looks like I am going to have to. I was just making sure I wasn't going to be reinventing the wheel.Kaleb
I've found a html5 solution here: scottizu.wordpress.com/2014/06/23/… but I think that for cordova on iOS you'd need it to work in safari, which does not support getUserMedia.Fadeout
Yea, that doesn't really solve my main problem of getting the real-time mic data from iOS though. I think I need to make a plugin. Someone made one for Android, but they didn't do iOS, maybe I'll fork it and add iOS. I'll post whatever I do back here for future people.Kaleb
How's it coming along Blankasaurus?Bushey
Any updates on this?Stoller
B
1

There is a plugin, that measures volume data in decibels: https://github.com/akofman/cordova-plugin-dbmeter

Install plugin with:

cordova plugin add cordova-plugin-dbmeter

Make sure that you add these lines to your app config.xml as that plugin doesn't currently support Swift 3.

<preference name="UseLegacySwiftLanguageVersion" value="true" />

Use plugin like that:

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    DBMeter.start(function(dB){
        console.log(dB);
    });
}
Bottali answered 10/3, 2017 at 10:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.