noteplayer
Version:
WebAudio musical audio note player
1,977 lines (484 loc) • 22.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Global</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Global</h1>
<section>
<header>
<h2></h2>
</header>
<article>
<div class="container-overview">
<dl class="details">
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="buildFromFrequency"><span class="type-signature"></span>buildFromFrequency<span class="signature">(noteFreq, audioContext<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
builds a notePlayer from a specific frequence
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>noteFreq</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last">sound frequency, in Hertz</td>
</tr>
<tr>
<td class="name"><code>audioContext</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The audioContext to render the sound. Created if not provided</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line90">line 90</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>buildFromFrequency(440)</code></pre>
<h4 class="name" id="buildFromKeyNb"><span class="type-signature"></span>buildFromKeyNb<span class="signature">(noteKeyNb, audioContext<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
builds a notePlayer from a specific piano key number
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>noteKeyNb</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last">corresponding number on a piano keyboard</td>
</tr>
<tr>
<td class="name"><code>audioContext</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The audioContext to render the sound. Created if not provided</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line120">line 120</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>buildFromKeyNb(49)</code></pre>
<h4 class="name" id="buildFromKeyNb"><span class="type-signature"></span>buildFromKeyNb<span class="signature">(noteKeyNb, audioContext<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
builds a notePlayer from a specific piano key number
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>noteKeyNb</code></td>
<td class="type">
<span class="param-type">number</span>
</td>
<td class="attributes">
</td>
<td class="description last">corresponding number on a piano keyboard</td>
</tr>
<tr>
<td class="name"><code>audioContext</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The audioContext to render the sound. Created if not provided</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line144">line 144</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>buildFromKeyNb(49)</code></pre>
<h4 class="name" id="buildFromName"><span class="type-signature"></span>buildFromName<span class="signature">(noteName, audioContext<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
builds a notePlayer from a specific musical note name
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>noteName</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="attributes">
</td>
<td class="description last">Concatenation of note + octave [1-8]</td>
</tr>
<tr>
<td class="name"><code>audioContext</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">The audioContext to render the sound. Created if not provided</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line48">line 48</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>buildFromName("C4")</code></pre>
<h4 class="name" id="play"><span class="type-signature"></span>play<span class="signature">(callback<span class="signature-attributes">opt</span>)</span><span class="type-signature"> → {Object}</span></h4>
<div class="description">
plays the note
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">callback function</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line177">line 177</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Oscillator
</div>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">Object</span>
</dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>play(function(){console.log("end play")})</code></pre>
<h4 class="name" id="setAttack"><span class="type-signature"></span>setAttack<span class="signature">(n)</span><span class="type-signature"></span></h4>
<div class="description">
Updates value of the note's attack
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">[0-1] the closer to 0 the longer the attack</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line264">line 264</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setAttack(0.3)</code></pre>
<h4 class="name" id="setAudioContext"><span class="type-signature"></span>setAudioContext<span class="signature">(ac)</span><span class="type-signature"></span></h4>
<div class="description">
assigns a specific audiocontext to the note
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>ac</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Web Audio audioContext</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line214">line 214</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setAudioContext(ac)</code></pre>
<h4 class="name" id="setDestinationNode"><span class="type-signature"></span>setDestinationNode<span class="signature">(dn)</span><span class="type-signature"></span></h4>
<div class="description">
assigns a specific destination node to the note (any connectable audioNode)
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>dn</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Web Audio destinationNode</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line224">line 224</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setDestinationNode(audioContext.destination)</code></pre>
<h4 class="name" id="setDuration"><span class="type-signature"></span>setDuration<span class="signature">(d)</span><span class="type-signature"></span></h4>
<div class="description">
changes the time the note has to be played for
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>d</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Time to play the note for, in second</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line234">line 234</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setDuration(2.3)</code></pre>
<h4 class="name" id="setRelease"><span class="type-signature"></span>setRelease<span class="signature">(n)</span><span class="type-signature"></span></h4>
<div class="description">
Updates value of the note's release
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>n</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">[0-1] the closer to 0 the longer the release</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line274">line 274</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setRelease(0.3)</code></pre>
<h4 class="name" id="setVerbose"><span class="type-signature"></span>setVerbose<span class="signature">(v<span class="signature-attributes">opt</span>)</span><span class="type-signature"></span></h4>
<div class="description">
switches verbose mode on/ff
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Attributes</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>v</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last">True or false, default is true</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line254">line 254</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setVerbose(); setVerbose(false)</code></pre>
<h4 class="name" id="setVolume"><span class="type-signature"></span>setVolume<span class="signature">(v)</span><span class="type-signature"></span></h4>
<div class="description">
changes the volume
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>v</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Volume level</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="notePlayer.js.html">notePlayer.js</a>, <a href="notePlayer.js.html#line244">line 244</a>
</li></ul></dd>
</dl>
<h5>Example</h5>
<pre class="prettyprint"><code>setVolume(0.5)</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="notePlayer.html">notePlayer</a></li></ul><h3>Global</h3><ul><li><a href="global.html#buildFromFrequency">buildFromFrequency</a></li><li><a href="global.html#buildFromKeyNb">buildFromKeyNb</a></li><li><a href="global.html#buildFromName">buildFromName</a></li><li><a href="global.html#play">play</a></li><li><a href="global.html#setAttack">setAttack</a></li><li><a href="global.html#setAudioContext">setAudioContext</a></li><li><a href="global.html#setDestinationNode">setDestinationNode</a></li><li><a href="global.html#setDuration">setDuration</a></li><li><a href="global.html#setRelease">setRelease</a></li><li><a href="global.html#setVerbose">setVerbose</a></li><li><a href="global.html#setVolume">setVolume</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.0</a> on Fri Dec 02 2016 10:02:02 GMT+0000 (GMT)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>