react-orchestra
Version:
A toolbox to build interactive and smart instruments on the web and mobile.
81 lines (60 loc) • 3.34 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: helpers/getUniqueNoteNames.js</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">Source: helpers/getUniqueNoteNames.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/* mod */
/**
* Get unique note names from array of note objects or note names
* @function
* @name getUniqueNoteNames
* @param {array} notes - Can contain note objects with payload property or strings of note names
* @example
* getUniqueNoteNames(['A3', 'B3', 'A3']) // returns ['A3', 'B3']
* getUniqueNoteNames(['A', 'B', 'A']) // returns ['A', 'B']
* const noteOne = new Note({name: 'A3'});
* const noteTwo = new Note({name: 'B3'});
* const noteThree = new Note({name: 'A3'});
* getUniqueNoteNames([noteOne, noteTwo, noteThree]) // returns ['A3', 'B3']
* @return {array} notenames
*/
const getUniqueNoteNames = (notes) => {
const set = new Set();
notes.forEach((note) => {
if (note.payload) {
set.add(note.payload.name);
return;
}
set.add(note);
});
return Array.from(set);
};
export default getUniqueNoteNames;
</code></pre>
</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>