Search code examples
androidcordovavolumemicrophonerecording

Record and get volume to generate a waveform in Android using Cordova


I've been learning Cordova, now I am developing an app to record voice and I'd like to get the volume/Db/Amplitude of the sound being recorded. I know that there's no oficial plugin by Cordova about this, so I searched and tested some plugins out there:

I can't find more plugins. Is there something else I can do or use, or maybe I am doing something wrong? I think it's strange that I can´t find easy this kind of plugin, so maybe the solution it's starting to learn java from scratch? >:(

Thanks in advance.


Solution

  • You should use Crosswalk so that you can access the Web Audio API without a Cordova plugin. From there you could use something like this example:

    http://tyleregeto.com/article/extracting-audio-data-with-the-web-audio-api

    As of the current Crosswalk version, the Web Audio API is fully supported, and since you are using Cordova, you won't have any Cross-Origin issues to worry about (e.g. you will be on 'localhost' so there won't be any HTTPS problems).

    I have built a Metronome in Angular that I used in a recent Ionic app with Crosswalk, and it works perfectly (even on a pretty bad XGODY device I used for testing). See the Gist below:

    https://gist.github.com/MT--/ece6e388a693416aa7e7