<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>wavesurfer.js | Microphone plugin</title> <link href="data:image/gif;" rel="icon" type="image/x-icon" /> <!-- Bootstrap --> <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="../css/style.css" /> <link rel="stylesheet" href="../css/ribbon.css" /> <!-- wavesurfer.js --> <script src="../../dist/wavesurfer.js"></script> <!-- microphone renderer --> <script src="../../dist/plugin/wavesurfer.microphone.js"></script> <!-- App --> <script src="app.js"></script> </head> <body itemscope itemtype="http://schema.org/WebApplication"> <div class="container"> <div class="header"> <h1 itemprop="name"><a href="http://wavesurfer-js.org">wavesurfer.js</a><noindex> + Microphone</noindex></h1> </div> <div id="demo"> <div id="waveform"></div> <div class="controls"> <button id="micBtn" class="btn btn-primary" data-action="start"> Microphone: <i class="glyphicon glyphicon-play"></i> Start / <i class="glyphicon glyphicon-stop"></i> Stop </button> </div> </div> <div class="row marketing"> <div class="col-lg-4"> <h4>wavesurfer.js Microphone Plugin</h4> <p itemprop="about">Visualizes audio input from a microphone in <strong>wavesurfer.js</strong> instances.</p> <h4>Installation</h4> <p> <ol> <li>add the Microphone plugin to the plugins property of the wavesurfer options</li> <li>create a new instance of wavesurfer by using the create function</li> <li>control the Microphone using the <code>start</code>, <code>stopDevice</code>, <code>play</code>, <code>pause</code>, <code>stop</code> and <code>togglePlay</code> methods</li> </ol> </p> <p> <a class="btn btn-large btn-success" href="../../dist/plugin/wavesurfer.microphone.min.js" itemprop="downloadUrl" download>Download the plugin</a> </p> </div> <div class="col-lg-8"> <h4>Quick Start</h4> <noindex><p> <pre><code>var wavesurfer = WaveSurfer.create({ container : '#waveform', waveColor : 'black', interact : false, cursorWidth : 0, plugins: [ WaveSurfer.microphone.create() ] }); wavesurfer.microphone.on('deviceReady', function(stream) { console.log('Device ready!', stream); }); wavesurfer.microphone.on('deviceError', function(code) { console.warn('Device error: ' + code); }); // start the microphone wavesurfer.microphone.start(); // pause rendering //wavesurfer.microphone.pause(); // resume rendering //wavesurfer.microphone.play(); // stop visualization and disconnect microphone //wavesurfer.microphone.stopDevice(); // same as stopDevice() but also clears the wavesurfer canvas //wavesurfer.microphone.stop(); // destroy the plugin //wavesurfer.microphone.destroy(); </code></pre> </p></noindex> <br /> <h4>Options</h4> <table class="table table-striped table-bordered"> <thead> <tr> <th>Name</th> <th>Required</th> <th>Default</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>wavesurfer</code></td> <td>yes</td> <td></td> <td>A WaveSurfer instance.</td> </tr> <tr> <td><code>bufferSize</code></td> <td>no</td> <td>4096</td> <td>The buffer size in units of sample-frames. If specified, the <code>bufferSize</code> must be one of the following values: 256, 512, 1024, 2048, 4096, 8192, 16384.</td> </tr> <tr> <td><code>numberOfInputChannels</code></td> <td>no</td> <td>1</td> <td>Integer specifying the number of channels for this node's input. Values of up to 32 are supported.</td> </tr> <tr> <td><code>numberOfOutputChannels</code></td> <td>no</td> <td>1</td> <td>Integer specifying the number of channels for this node's output. Values of up to 32 are supported.</td> </tr> </tbody> </table> <h4>Events</h4> <table class="table table-striped table-bordered"> <thead> <tr> <th>Name</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td><code>deviceReady</code></td> <td>Invoked when the device is ready to use. Callback will receive a <code>LocalMediaStream</code> object that contains the microphone stream.</td> </tr> <tr> <td><code>deviceError</code></td> <td>Invoked when the user doesn't allow the browser to access the microphone. Callback will receive a (string) <a href='https://developer.mozilla.org/en-US/docs/NavigatorUserMedia.getUserMedia#errorCallback'>error code</a>.</td> </tr> </tbody> </table> </div> </div> <div class="footer row"> <div class="col-sm-12"> <a rel="license" href="https://opensource.org/licenses/BSD-3-Clause"><img alt="BSD-3-Clause License" style="border-width:0" src="https://img.shields.io/badge/License-BSD%203--Clause-blue.svg" /></a> </div> <div class="col-sm-12"> <span xmlns:dct="http://purl.org/dc/terms/" href="http://purl.org/dc/dcmitype/Text" property="dct:title" rel="dct:type">wavesurfer.js</span> by <a href="https://github.com/katspaugh/wavesurfer.js">katspaugh</a> is licensed under a <a rel="license" href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause License</a>. </div> </div> </div> <div class="github-fork-ribbon-wrapper right"> <div class="github-fork-ribbon"> <a itemprop="isBasedOnUrl" href="https://github.com/katspaugh/wavesurfer.js">Fork me on GitHub</a> </div> </div> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-50026819-1', 'wavesurfer.fm'); ga('send', 'pageview'); </script> </body> </html>