react-orchestra
Version:
A toolbox to build interactive and smart instruments on the web and mobile.
177 lines (126 loc) • 6.95 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Home</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">Home</h1>
<h3> </h3>
<section>
<article><h1>InstrumentJS</h1><p><a href="https://circleci.com/gh/RakanNimer/InstrumentJS"><img src="https://circleci.com/gh/RakanNimer/InstrumentJS.svg?style=shield&circle-token=a8f9a00f2444ffc5ed93d542155bb256860e0243" alt="CircleCI"></a></p>
<p>A suite of helpers and objects to play and compose music from your browser.</p>
<h2>Installation</h2><pre class="prettyprint source lang-sh"><code> npm install --save git+https://a616ae14b9b11774d04278d924c162e3f9276e9b:x-oauth-basic@github.com/rakannimer/InstrumentJS.git</code></pre><p>You can now use it by importing it in your app :</p>
<pre class="prettyprint source lang-javascript"><code>
import { Note, Instrument, InstrumentHelpers } from 'InstrumentJS';</code></pre><h2>API</h2><h3>Functional Helpers</h3><p>Data in, data out : </p>
<pre class="prettyprint source lang-javascript"><code>import { Note, Instrument, InstrumentHelpers } from 'InstrumentJS';
const getUniqueNoteNamesTest = () => {
const notes = [
new Note({ name: 'A3' }),
new Note({ name: 'C3' }),
new Note({ name: 'A3' }),
new Note({ name: 'B3' }),
new Note({ name: 'C3' }),
];
const uniqueNoteNames = InstrumentHelpers.getUniqueNoteNames(notes);
return { input: notes, output: uniqueNoteNames };
};
const getUniqueNoteNamesNoOctaveTest = () => {
const notes = [
new Note({ name: 'A3' }),
new Note({ name: 'C3' }),
new Note({ name: 'A3' }),
new Note({ name: 'B3' }),
new Note({ name: 'C3' }),
];
const uniqueNoteNamesNoOctave = InstrumentHelpers.getUniqueNoteNamesNoOctave(notes);
return { input: notes, output: uniqueNoteNamesNoOctave };
};
const removeOctaveFromNoteNameTest = () => {
const noteNameNoOctave = InstrumentHelpers.removeOctaveFromNoteName('A3');
return { input: 'A3', output: noteNameNoOctave };
};
const addOctaveToNoteNameTest = () => {
const noteName = InstrumentHelpers.addOctaveToNoteName('A', 3);
return { input: '(A, 3)', output: noteName };
};
const getIntervalTest = () => {
const noteNameOne = 'C';
const noteNameTwo = 'B';
const interval = InstrumentHelpers.getInterval(noteNameTwo, noteNameOne);
return { input: "('C', 'B')", output: interval };
};
const getIntervalPermutationsFromNoteNamesTest = () => {
const noteNamesNoOctave = ['A', 'B', 'C'];
const permutations = InstrumentHelpers.getIntervalPermutationsFromNoteNames(noteNamesNoOctave);
return { input: noteNamesNoOctave, output: permutations };
};
const getScalesFromNoteNamesTest = () => {
const noteNames = ['A3', 'B3', 'C3'];
const permutations = InstrumentHelpers.getScalesFromNoteNames(noteNames);
return { input: noteNames, output: permutations };
};
const getNoteNamesFromIntervalsTest = () => {
const firstNoteName = 'A3';
const intervals = [0, 2, 4];
const noteNames = InstrumentHelpers.getNoteNamesFromIntervals(firstNoteName, intervals);
return { input: `(${firstNoteName}, ${JSON.stringify(intervals)})`, output: noteNames };
// console.log('getNoteNamesFromIntervals');
};
const getNoteNamesFromChordNameTest = () => {
const firstNoteName = 'A3';
const chordName = 'min';
const noteNames = InstrumentHelpers.getNoteNamesFromChordName('A3', 'min');
return { input: `(${firstNoteName}, ${chordName})`, output: noteNames };
};
const getJSONFromMidiURLTest = () => {
return InstrumentHelpers.getJSONFromMidiURL(url).then(output => ({ input: url, output }));
};
const getTracksAndMetaFromParsedMidiTest = () => {
return InstrumentHelpers.getJSONFromMidiURL(url)
.then(jsonParsedMidi => ({ jsonParsedMidi, tracksAndMeta: InstrumentHelpers.getTracksAndMetaFromParsedMidi(jsonParsedMidi) }))
.then(result => ({ input: result.jsonParsedMidi, output: result.tracksAndMeta }));
};
const getTracksAndMetaFromUrlTest = () => {
return InstrumentHelpers.getTracksAndMetaFromUrl(url)
.then(tracksAndMeta => (
{ input: url, output: tracksAndMeta }
));
};
const getScaleNotesTest = () => {
const note = 'A';
const scale = 'aeolian';
const startOctave = 3;
const count = 3;
const scaleNotes = InstrumentHelpers.getScaleNotes(note, scale, startOctave, count);
return { input: `(${note}, ${scale}, ${startOctave}, ${count})`, output: scaleNotes };
};
const updateTempoTest = () =>
InstrumentHelpers.getTracksAndMetaFromUrl(url).then((tracksAndMeta) => {
const BPM = 10;
const trackIndex = 1;
const updatedTracksAndMeta = InstrumentHelpers.updateTempo(tracksAndMeta, BPM, trackIndex);
return { input: { tracksAndMeta, BPM, trackIndex }, output: updatedTracksAndMeta };
})
;</code></pre><h3>Classes</h3></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>