react-orchestra
Version:
A toolbox to build interactive and smart instruments on the web and mobile.
1,600 lines (412 loc) • 19 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: Instrument</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">Class: Instrument</h1>
<section>
<header>
<h2>Instrument</h2>
<div class="class-description">Instrument Class. Use it to play music from the browser</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="Instrument"><span class="type-signature"></span>new Instrument<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Create an instrument. It will import audio context and prepare its internal state.
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line19">line 19</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="get"><span class="type-signature"></span>get<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Loads instrument from the web and stores it as a resolvable promise
</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>instrumentName.</code></td>
<td class="type">
</td>
<td class="description last">List of all instrument names in src/constants/INSTRUMENTS</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line35">line 35</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<musicPlayer>
</div>
<h4 class="name" id="play"><span class="type-signature"></span>play<span class="signature">(notes, meta, note)</span><span class="type-signature"></span></h4>
<div class="description">
play array of notes
</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>notes</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>meta</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>note</code></td>
<td class="type">
</td>
<td class="description last">settings</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line204">line 204</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
<h4 class="name" id="startPlayingChordByChordName"><span class="type-signature"></span>startPlayingChordByChordName<span class="signature">(firstNoteName, chordName, note)</span><span class="type-signature"></span></h4>
<div class="description">
startPlayingChordByChordName
</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>firstNoteName</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>chordName</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>note</code></td>
<td class="type">
</td>
<td class="description last">settings</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line176">line 176</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const instrument = new Instrument();
instrument.startPlayingChordByChordName('A3', 'maj', {instrumentName: 'acoustic_grand_piano', startTimeInMS: 0, durationInMS: 1000, endTimeInMS: 1000})</code></pre>
<h4 class="name" id="startPlayingChordByNoteNames"><span class="type-signature"></span>startPlayingChordByNoteNames<span class="signature">(noteNames, note)</span><span class="type-signature"></span></h4>
<div class="description">
Start playing chord by note names
</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>noteNames</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>note</code></td>
<td class="type">
</td>
<td class="description last">settings</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line143">line 143</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const instrument = new Instrument();
instrument.startPlayingChordByNoteNames(['A3','C3','E3'], {instrumentName: 'acoustic_grand_piano', startTimeInMS: 0, durationInMS: 1000, endTimeInMS: 1000})</code></pre>
<h4 class="name" id="startPlayingNote"><span class="type-signature"></span>startPlayingNote<span class="signature">(note)</span><span class="type-signature"></span></h4>
<div class="description">
Start playing note, if note.payload.durationInMS is -1 it will keep playing infinitely until it is explicitly stopped.
{ payload: { id, instrumentName, startTimeInMS, instrumentName, name, gain, duration }}
</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>note</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line80">line 80</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
<h4 class="name" id="stop"><span class="type-signature"></span>stop<span class="signature">(notes, meta, note)</span><span class="type-signature"></span></h4>
<div class="description">
stop playing array of notes
</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>notes</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>meta</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>note</code></td>
<td class="type">
</td>
<td class="description last">settings</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line234">line 234</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
<h4 class="name" id="stopPlayingChordByChordName"><span class="type-signature"></span>stopPlayingChordByChordName<span class="signature">(firstNoteName, chordName, note)</span><span class="type-signature"></span></h4>
<div class="description">
stopPlayingChordByChordName
</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>firstNoteName</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>chordName</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>note</code></td>
<td class="type">
</td>
<td class="description last">settings</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line191">line 191</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const instrument = new Instrument();
instrument.stopPlayingChordByChordName('A3', 'maj', {instrumentName: 'acoustic_grand_piano', startTimeInMS: 0, durationInMS: 1000, endTimeInMS: 1000})</code></pre>
<h4 class="name" id="stopPlayingChordByNoteNames"><span class="type-signature"></span>stopPlayingChordByNoteNames<span class="signature">(noteNames, note)</span><span class="type-signature"></span></h4>
<div class="description">
Stop playing chord by note names
</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>noteNames</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
<tr>
<td class="name"><code>note</code></td>
<td class="type">
</td>
<td class="description last">settings</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line159">line 159</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
<h5>Example</h5>
<pre class="prettyprint"><code>const instrument = new Instrument();
instrument.stopPlayingChordByNoteNames(['A3','C3','E3'], {instrumentName: 'acoustic_grand_piano', startTimeInMS: 0, durationInMS: 1000, endTimeInMS: 1000})</code></pre>
<h4 class="name" id="stopPlayingNote"><span class="type-signature"></span>stopPlayingNote<span class="signature">(note)</span><span class="type-signature"></span></h4>
<div class="description">
Stop playing note
{ payload: { id, instrumentName, startTimeInMS, instrumentName, name, gain, duration }}
</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>note</code></td>
<td class="type">
</td>
<td class="description last"></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="Instruments.js.html">Instruments.js</a>, <a href="Instruments.js.html#line109">line 109</a>
</li></ul></dd>
</dl>
<h5>Returns:</h5>
<div class="param-desc">
Promise<notePlayer>
</div>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Instrument.html">Instrument</a></li><li><a href="Note.html">Note</a></li></ul><h3>Global</h3><ul><li><a href="global.html#addOctaveToNoteName">addOctaveToNoteName</a></li><li><a href="global.html#getInterval">getInterval</a></li><li><a href="global.html#getIntervalPermutationsFromNoteNames">getIntervalPermutationsFromNoteNames</a></li><li><a href="global.html#getJSONFromMidiURL">getJSONFromMidiURL</a></li><li><a href="global.html#getNoteNamesFromChordName">getNoteNamesFromChordName</a></li><li><a href="global.html#getNoteNamesFromIntervals">getNoteNamesFromIntervals</a></li><li><a href="global.html#getScaleNotes">getScaleNotes</a></li><li><a href="global.html#getScalesFromNoteNames">getScalesFromNoteNames</a></li><li><a href="global.html#getTracksAndMetaFromParsedMidi">getTracksAndMetaFromParsedMidi</a></li><li><a href="global.html#getTracksAndMetaFromUrl">getTracksAndMetaFromUrl</a></li><li><a href="global.html#getUniqueNoteNames">getUniqueNoteNames</a></li><li><a href="global.html#getUniqueNoteNamesNoOctave">getUniqueNoteNamesNoOctave</a></li><li><a href="global.html#isInHigherOctave">isInHigherOctave</a></li><li><a href="global.html#removeOctaveFromNoteName">removeOctaveFromNoteName</a></li><li><a href="global.html#reOrderNotes">reOrderNotes</a></li><li><a href="global.html#updateTempo">updateTempo</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> on Sun Nov 20 2016 16:43:09 GMT+0200 (EET)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>