UNPKG

react-orchestra

Version:

A toolbox to build interactive and smart instruments on the web and mobile.

89 lines (69 loc) 3.47 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: Note.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: Note.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>import _ from 'lodash'; /** Note class. Must be used to create and play notes. */ class Note { constructor(note = {}) { this.payload = _.defaultsDeep(note, { name: 'A3', noteNumber: -1, gain: 1, instrumentName: 'acoustic_grand_piano', startTimeInMS: 0, durationInMS: 100, endTimeInMS: 100, fadeDurationInMS: 1000, deltaTime: 0, msPerTick: 0, }); this.payload.id = note.id ? note.id : `${this.payload.instrumentName}_${this.payload.name}`; } /** * Updates note instrument * @param instrumentName. List of all instrument names in src/constants/INSTRUMENTS */ setInstrument(instrumentName) { this.payload.instrumentName = instrumentName; } /** * Update note * @param updatedPayloadFields. Object containing all or part of the payload fields. * @returns {object} this */ update(updatedPayloadFields) { this.payload = Object.assign({}, this.payload, updatedPayloadFields); return this; } } export default Note; </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>