react-orchestra
Version:
A toolbox to build interactive and smart instruments on the web and mobile.
77 lines (58 loc) • 3.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: helpers/getNoteNamesFromChordName.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/getNoteNamesFromChordName.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>/* mod */
import CHORDS from '../constants/CHORDS';
import getNoteNamesFromIntervals from './getNoteNamesFromIntervals';
/**
* Get unique note names from array of note objects or note names
* @function
* @name getNoteNamesFromChordName
* @param {string} firstNoteNameWithOctave - note name with octave e.g. 'A3'
* @param {string} chordName - Chord name full list of supported chords in src/constants/CHORDS.js
* @example
* getNoteNamesFromChordName('A3', 'min') // returns ['A3', 'C3', 'E3']
* getNoteNamesFromChordName('C3', 'maj') // returns ['C3', 'E3', 'G3']
* // Full list of supported chords in src/constants/CHORDS.js
* @return {array} notenames
*/
const getNoteNamesFromChordName = (firstNoteName, chordName) => {
if (!(chordName in CHORDS)) {
throw new Error({ code: 'CHORD_DOESNT_EXIST' });
}
const octave = firstNoteName.substring(firstNoteName.length - 1, firstNoteName.length);
const intervals = CHORDS[chordName].sequence;
const noteNames = getNoteNamesFromIntervals(firstNoteName, intervals, octave);
return noteNames;
};
export default getNoteNamesFromChordName;
</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>