'use strict'
// map from pitch number to number of fifths and octaves
var BASES = [ [0, 0], [2, -1], [4, -2], [-1, 1], [1, 0], [3, -1], [5, -2] ]
/**
* Get a pitch in [array notation]() from pitch properties
*
* @name array.fromProps
* @function
* @param {Integer} step - the step index
* @param {Integer} alterations - (Optional) the alterations number
* @param {Integer} octave - (Optional) the octave
* @param {Integer} duration - (Optional) duration
* @return {Array} the pitch in array format
*
* @example
* var fromProps = require('music-notation/array/from-props')
* fromProps([0, 1, 4, 0])
*/
module.exports = function (step, alt, oct, dur) {
var base = BASES[step]
alt = alt || 0
var f = base[0] + 7 * alt
if (typeof oct === 'undefined') return [f]
var o = oct + base[1] - 4 * alt
if (typeof dur === 'undefined') return [f, o]
else return [f, o, dur]
}
|