UNPKG

wavesurfer.js

Version:

Interactive navigable audio visualization using Web Audio and Canvas

205 lines (169 loc) 8.27 kB
<!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.min.js"></script> <!-- microphone renderer --> <script src="../../dist/plugin/wavesurfer.microphone.min.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 script tag</li> <li>create a <code>WaveSurfer</code> instance</li> <li>create a <code>Microphone</code> instance</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="../../plugin/wavesurfer.microphone.js" itemprop="downloadUrl">Download <strong>the plugin</strong> (3.2 KB)</a> </p> </div> <div class="col-lg-8"> <h4>Quick Start</h4> <noindex><p> <pre><code>var wavesurfer = Object.create(WaveSurfer); wavesurfer.init({ container : '#waveform', waveColor : 'black', interact : false, cursorWidth : 0 }); var microphone = Object.create(WaveSurfer.Microphone); microphone.init({ wavesurfer: wavesurfer }); microphone.on('deviceReady', function(stream) { console.log('Device ready!', stream); }); microphone.on('deviceError', function(code) { console.warn('Device error: ' + code); }); // start the microphone microphone.start(); // pause rendering //microphone.pause(); // resume rendering //microphone.play(); // stop visualization and disconnect microphone //microphone.stopDevice(); // same as stopDevice() but also clears the wavesurfer canvas //microphone.stop(); // destroy the plugin //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://creativecommons.org/licenses/by/3.0/deed.en_US"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by/3.0/80x15.png" /></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 xmlns:cc="http://creativecommons.org/ns#" href="https://github.com/katspaugh/wavesurfer.js" property="cc:attributionName" rel="cc:attributionURL">katspaugh</a> is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/3.0/deed.en_US">Creative Commons Attribution 3.0 Unported 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>