tonal-note
Advanced tools
Comparing version 0.68.0 to 0.68.1
@@ -12,2 +12,18 @@ 'use strict'; | ||
/** | ||
* `tonal-note` is a collection of functions to get properties from musical notes. | ||
* | ||
* @module note | ||
* @example | ||
* var note = require('tonal-note') | ||
* note.name('bb2') // => 'Bb2' | ||
* note.chroma('bb2') // => 10 | ||
* note.enharmonics('C#6') // => [ 'B##5', 'C#6', 'Db6' ] | ||
* note.simplify('B#3') // => 'C4' | ||
* | ||
* @example | ||
* // using ES6 import syntax | ||
* import { name } from 'tonal-note' | ||
* ['c', 'db3', '2', 'g+', 'gx4'].map(name) // => ['C', 'Db3', null, null, 'G##4'] | ||
*/ | ||
/** | ||
* Get the note midi number | ||
@@ -23,3 +39,3 @@ * (an alias of tonal-midi `toMidi` function) | ||
*/ | ||
var midi = tonalMidi.toMidi | ||
var midi = tonalMidi.toMidi; | ||
@@ -38,3 +54,3 @@ /** | ||
*/ | ||
var fromMidi = tonalMidi.note | ||
var fromMidi = tonalMidi.note; | ||
@@ -52,3 +68,3 @@ /** | ||
*/ | ||
var freq = tonalFreq.toFreq | ||
var freq = tonalFreq.toFreq; | ||
@@ -67,3 +83,3 @@ /** | ||
function chroma (n) { | ||
var p = tonalPitch.asNotePitch(n) | ||
var p = tonalPitch.asNotePitch(n); | ||
return p ? tonalPitch.chr(p) : null | ||
@@ -87,3 +103,3 @@ } | ||
function note$1 (n) { | ||
var p = tonalPitch.asNotePitch(n) | ||
var p = tonalPitch.asNotePitch(n); | ||
return p ? tonalPitch.strNote(p) : null | ||
@@ -93,2 +109,10 @@ } | ||
/** | ||
* An alias for note. Get the name of a note in scientific notation | ||
* @example | ||
* note.name('fx') // => 'F##' | ||
* note.name('bbb3') // => 'Bbb3' | ||
*/ | ||
const name = note$1; | ||
/** | ||
* Get note properties. It returns an object with the following properties: | ||
@@ -107,5 +131,5 @@ * | ||
function props (n) { | ||
var p = tonalPitch.asNotePitch(n) | ||
var p = tonalPitch.asNotePitch(n); | ||
if (!p) return null | ||
var d = tonalPitch.decode(p) | ||
var d = tonalPitch.decode(p); | ||
return { step: d[0], alt: d[1], oct: d[2] } | ||
@@ -149,3 +173,3 @@ } | ||
*/ | ||
var oct = getProp('oct') | ||
var oct = getProp('oct'); | ||
@@ -165,3 +189,3 @@ /** | ||
*/ | ||
var step = getProp('step') | ||
var step = getProp('step'); | ||
@@ -175,4 +199,4 @@ /** | ||
*/ | ||
function pcFifths (note) { | ||
var p = tonalPitch.asNotePitch(note) | ||
function pcFifths (note$$1) { | ||
var p = tonalPitch.asNotePitch(note$$1); | ||
return p ? tonalPitch.fifths(p) : null | ||
@@ -193,3 +217,3 @@ } | ||
*/ | ||
var alt = getProp('alt') | ||
var alt = getProp('alt'); | ||
@@ -207,8 +231,8 @@ /** | ||
function pc (n) { | ||
var p = tonalPitch.asNotePitch(n) | ||
var p = tonalPitch.asNotePitch(n); | ||
return p ? tonalPitch.strNote([ p[0], [ tonalPitch.fifths(p) ] ]) : null | ||
} | ||
var ASC = tonalPitch.parseIvl('2d') | ||
var DESC = tonalPitch.parseIvl('-2d') | ||
var ASC = tonalPitch.parseIvl('2d'); | ||
var DESC = tonalPitch.parseIvl('-2d'); | ||
@@ -230,7 +254,7 @@ /** | ||
function enharmonics (pitch) { | ||
var notes = [] | ||
notes.push(tonalTranspose.transpose(DESC, pitch)) | ||
var notes = []; | ||
notes.push(tonalTranspose.transpose(DESC, pitch)); | ||
if (notes[0] === null) return null | ||
notes.push(pitch) | ||
notes.push(tonalTranspose.transpose(ASC, pitch)) | ||
notes.push(pitch); | ||
notes.push(tonalTranspose.transpose(ASC, pitch)); | ||
return notes | ||
@@ -261,2 +285,3 @@ } | ||
exports.note = note$1; | ||
exports.name = name; | ||
exports.props = props; | ||
@@ -270,2 +295,2 @@ exports.fromProps = fromProps; | ||
exports.enharmonics = enharmonics; | ||
exports.simplify = simplify; | ||
exports.simplify = simplify; |
@@ -99,2 +99,10 @@ /** | ||
/** | ||
* An alias for note. Get the name of a note in scientific notation | ||
* @example | ||
* note.name('fx') // => 'F##' | ||
* note.name('bbb3') // => 'Bbb3' | ||
*/ | ||
export const name = note | ||
/** | ||
* Get note properties. It returns an object with the following properties: | ||
@@ -101,0 +109,0 @@ * |
{ | ||
"name": "tonal-note", | ||
"version": "0.68.0", | ||
"version": "0.68.1", | ||
"repository": "https://github.com/danigb/tonal/packages/note", | ||
@@ -18,4 +18,4 @@ "description": "Encode pitches using fifths/octaves", | ||
"note-parser": "^2.0.0", | ||
"tonal-freq": "^0.68.0", | ||
"tonal-midi": "^0.68.0", | ||
"tonal-freq": "^0.68.1", | ||
"tonal-midi": "^0.68.1", | ||
"tonal-pitch": "^0.66.0", | ||
@@ -22,0 +22,0 @@ "tonal-transpose": "^0.66.0" |
23357
580
Updatedtonal-freq@^0.68.1
Updatedtonal-midi@^0.68.1