index.html 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>wavesurfer.js | Panner Example</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. <link rel="screenshot" itemprop="screenshot" href="https://katspaugh.github.io/wavesurfer.js/example/screenshot.png" />
  12. <!-- wavesurfer.js -->
  13. <script src="../../dist/wavesurfer.js"></script>
  14. <!-- Demo -->
  15. <script src="main.js"></script>
  16. </head>
  17. <body itemscope itemtype="http://schema.org/WebApplication">
  18. <div class="container">
  19. <div class="header">
  20. <ul class="nav nav-pills pull-right">
  21. <li><a href="/"><i class="glyphicon glyphicon-home"></i></a></li>
  22. </ul>
  23. <h1 itemprop="name">Panner Filter Example</h1>
  24. </div>
  25. <div id="demo">
  26. <div id="waveform">
  27. <div class="progress progress-striped active" id="progress-bar">
  28. <div class="progress-bar progress-bar-info"></div>
  29. </div>
  30. <!-- Here be the waveform -->
  31. </div>
  32. <div class="controls">
  33. <button class="btn btn-primary" data-action="play">
  34. <i class="glyphicon glyphicon-play"></i>
  35. Play
  36. /
  37. <i class="glyphicon glyphicon-pause"></i>
  38. Pause
  39. </button>
  40. <hr />
  41. <div class="row">
  42. <div class="col-sm-4">
  43. &larr; left
  44. </div>
  45. <div class="col-sm-4">
  46. <!-- Panner -->
  47. <input data-action="pan" type="range" min="-45" max="45" value="0" style="width: 100%" />
  48. </div>
  49. <div class="col-sm-4">
  50. right &rarr;
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="row marketing">
  56. <h3>How to Create a Panner Interface</h3>
  57. <p>
  58. This is an example of how to add an arbitrary Web
  59. Audio node into a wavesurfer.js graph. Panner node
  60. is one such node.
  61. </p>
  62. <hr />
  63. <div class="col-lg-6">
  64. <h4>1. Initialize wavesurfer.js</h4>
  65. <p>Create a <code>WaveSurfer</code> instance and load an audio clip.</p>
  66. <noindex><p>
  67. <pre><code>var wavesurfer = WaveSurfer.create({
  68. container: '#demo' // this is the only required param
  69. });
  70. wavesurfer.load('media.wav');</code></pre>
  71. </p></noindex>
  72. <h4>2. Create a Panner Node</h4>
  73. <p>
  74. Create a panner node and add it to the Web
  75. Audio graph using the <code>setFilter</code> method.
  76. </p>
  77. <noindex><p>
  78. <pre><code>var panner = wavesurfer.backend.ac.createPanner();
  79. wavesurfer.backend.setFilter(panner);</code></pre>
  80. </p></noindex>
  81. </div>
  82. <div class="col-lg-6">
  83. <h4>3. Create a Range Slider</h4>
  84. <p>
  85. In your HTML, add a range input.
  86. </p>
  87. <noindex><p>
  88. <pre><code>&lt;input id="panner-input" type="range" min="-45" max="45" value="0" /&gt;</code></pre>
  89. </p></noindex>
  90. <h4>4. Bind the Range Slider</h4>
  91. <p>
  92. Listen to the range input's <code>input</code> event and set the panner's position
  93. according to the input's value.
  94. <small>Adapted from <a href="http://stackoverflow.com/a/14412601/352796">this SO answer</a>.</small>
  95. </p>
  96. <noindex><p>
  97. <pre><code>var slider = document.querySelector('#panner-input');
  98. slider.addEventListener('input', function (e) {
  99. var xDeg = parseInt(e.target.value);
  100. var x = Math.sin(xDeg * (Math.PI / 180));
  101. wavesurfer.panner.setPosition(x, 0, 0);
  102. });</code></pre>
  103. </p></noindex>
  104. </div>
  105. </div>
  106. <div class="footer row">
  107. <div class="col-sm-12">
  108. <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>
  109. </div>
  110. <div class="col-sm-7">
  111. <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&nbsp;<a style="white-space: nowrap" rel="license" href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause License</a>.
  112. </div>
  113. <div class="col-sm-5">
  114. <div class="pull-right">
  115. <noindex>
  116. The audio file is from <a rel="nofollow" href="http://spokencorpora.ru/">spokencorpora.ru</a>, used with permission.
  117. </noindex>
  118. </div>
  119. </div>
  120. </div>
  121. </div>
  122. <div class="github-fork-ribbon-wrapper right">
  123. <div class="github-fork-ribbon">
  124. <a itemprop="isBasedOnUrl" href="https://github.com/katspaugh/wavesurfer.js">Fork me on GitHub</a>
  125. </div>
  126. </div>
  127. <script>
  128. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  129. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  130. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  131. })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  132. ga('create', 'UA-50026819-1', 'wavesurfer.fm');
  133. ga('send', 'pageview');
  134. </script>
  135. </body>
  136. </html>