index.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>wavesurfer.js | Microphone plugin</title>
  6. <link href="data:image/gif;" rel="icon" type="image/x-icon" />
  7. <!-- Bootstrap -->
  8. <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
  9. <link rel="stylesheet" href="../css/style.css" />
  10. <link rel="stylesheet" href="../css/ribbon.css" />
  11. <!-- wavesurfer.js -->
  12. <script src="../../dist/wavesurfer.js"></script>
  13. <!-- microphone renderer -->
  14. <script src="../../dist/plugin/wavesurfer.microphone.js"></script>
  15. <!-- App -->
  16. <script src="app.js"></script>
  17. </head>
  18. <body itemscope itemtype="http://schema.org/WebApplication">
  19. <div class="container">
  20. <div class="header">
  21. <h1 itemprop="name"><a href="http://wavesurfer-js.org">wavesurfer.js</a><noindex> + Microphone</noindex></h1>
  22. </div>
  23. <div id="demo">
  24. <div id="waveform"></div>
  25. <div class="controls">
  26. <button id="micBtn" class="btn btn-primary" data-action="start">
  27. Microphone:
  28. <i class="glyphicon glyphicon-play"></i>
  29. Start
  30. /
  31. <i class="glyphicon glyphicon-stop"></i>
  32. Stop
  33. </button>
  34. </div>
  35. </div>
  36. <div class="row marketing">
  37. <div class="col-lg-4">
  38. <h4>wavesurfer.js Microphone Plugin</h4>
  39. <p itemprop="about">Visualizes audio input from a microphone in <strong>wavesurfer.js</strong> instances.</p>
  40. <h4>Installation</h4>
  41. <p>
  42. <ol>
  43. <li>add the Microphone plugin to the plugins property of the wavesurfer options</li>
  44. <li>create a new instance of wavesurfer by using the create function</li>
  45. <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>
  46. </ol>
  47. </p>
  48. <p>
  49. <a class="btn btn-large btn-success" href="../../dist/plugin/wavesurfer.microphone.min.js" itemprop="downloadUrl" download>Download the plugin</a>
  50. </p>
  51. </div>
  52. <div class="col-lg-8">
  53. <h4>Quick Start</h4>
  54. <noindex><p>
  55. <pre><code>var wavesurfer = WaveSurfer.create({
  56. container : '#waveform',
  57. waveColor : 'black',
  58. interact : false,
  59. cursorWidth : 0,
  60. plugins: [
  61. WaveSurfer.microphone.create()
  62. ]
  63. });
  64. wavesurfer.microphone.on('deviceReady', function(stream) {
  65. console.log('Device ready!', stream);
  66. });
  67. wavesurfer.microphone.on('deviceError', function(code) {
  68. console.warn('Device error: ' + code);
  69. });
  70. // start the microphone
  71. wavesurfer.microphone.start();
  72. // pause rendering
  73. //wavesurfer.microphone.pause();
  74. // resume rendering
  75. //wavesurfer.microphone.play();
  76. // stop visualization and disconnect microphone
  77. //wavesurfer.microphone.stopDevice();
  78. // same as stopDevice() but also clears the wavesurfer canvas
  79. //wavesurfer.microphone.stop();
  80. // destroy the plugin
  81. //wavesurfer.microphone.destroy();
  82. </code></pre>
  83. </p></noindex>
  84. <br />
  85. <h4>Options</h4>
  86. <table class="table table-striped table-bordered">
  87. <thead>
  88. <tr>
  89. <th>Name</th>
  90. <th>Required</th>
  91. <th>Default</th>
  92. <th>Description</th>
  93. </tr>
  94. </thead>
  95. <tbody>
  96. <tr>
  97. <td><code>wavesurfer</code></td>
  98. <td>yes</td>
  99. <td></td>
  100. <td>A WaveSurfer instance.</td>
  101. </tr>
  102. <tr>
  103. <td><code>bufferSize</code></td>
  104. <td>no</td>
  105. <td>4096</td>
  106. <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>
  107. </tr>
  108. <tr>
  109. <td><code>numberOfInputChannels</code></td>
  110. <td>no</td>
  111. <td>1</td>
  112. <td>Integer specifying the number of channels for this node's input. Values of up to 32 are supported.</td>
  113. </tr>
  114. <tr>
  115. <td><code>numberOfOutputChannels</code></td>
  116. <td>no</td>
  117. <td>1</td>
  118. <td>Integer specifying the number of channels for this node's output. Values of up to 32 are supported.</td>
  119. </tr>
  120. </tbody>
  121. </table>
  122. <h4>Events</h4>
  123. <table class="table table-striped table-bordered">
  124. <thead>
  125. <tr>
  126. <th>Name</th>
  127. <th>Description</th>
  128. </tr>
  129. </thead>
  130. <tbody>
  131. <tr>
  132. <td><code>deviceReady</code></td>
  133. <td>Invoked when the device is ready to use. Callback will receive a <code>LocalMediaStream</code> object that contains the microphone stream.</td>
  134. </tr>
  135. <tr>
  136. <td><code>deviceError</code></td>
  137. <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>
  138. </tr>
  139. </tbody>
  140. </table>
  141. </div>
  142. </div>
  143. <div class="footer row">
  144. <div class="col-sm-12">
  145. <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>
  146. </div>
  147. <div class="col-sm-12">
  148. <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>.
  149. </div>
  150. </div>
  151. </div>
  152. <div class="github-fork-ribbon-wrapper right">
  153. <div class="github-fork-ribbon">
  154. <a itemprop="isBasedOnUrl" href="https://github.com/katspaugh/wavesurfer.js">Fork me on GitHub</a>
  155. </div>
  156. </div>
  157. <script>
  158. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  159. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  160. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  161. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  162. ga('create', 'UA-50026819-1', 'wavesurfer.fm');
  163. ga('send', 'pageview');
  164. </script>
  165. </body>
  166. </html>