View on GitHub

Microphone-analyzer

Download this project as a .zip file Download this project as a tar.gz file

microphone-analyzer

microphone-analyzer is a polymer element that enables document microphone input data analysis.

Dependencies:

Install

Command line:

bower install ddcast/microphone-analyzer

Include in your document <head>:

<script src="components/platform/platform.js"></script>
<script src="components/microphone/microphone.js"></script>

<link rel="import" href="components/polymer/polymer.html"> 
<link rel="import" href="components/microphone-analyzer/microphone-analyzer.html"> 

Release notes

Usage

The air event is fired at the interaval specified by the length option. event.detail will contain the following properties:

Element attributes (based on srubin/microphone):

Example

HTML:

<microphone-analyzer length=".5" overlap=".25" channels="1">
  <audio-range start="0" end="1"><em>speak up!</em></audio-range>
  <audio-range start="1.01" end="2">quiet</audio-range>
  <audio-range start="2.01" end="3">normal</audio-range>
  <audio-range start="3.01" end="4">loud</audio-range>
  <audio-range start="4.01" end="5">very loud</audio-range>
</microphone-analyzer>

JavaScript:

var microphoneAnalyzer = document.querySelector('microphone-analyzer');

microphoneAnalyzer.valuefilter = function (rms) {
  var vol = rms * 100;

  return vol;
};

microphoneAnalyzer.addEventListener('air', function(e) {
  console.log(e.detail.value);
});