Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function interval(a, b) {
if (arguments.length === 1) return function (b) {
return distance(a, b);
};
var pa = tonalPitches.asPitch(a);
var pb = tonalPitches.asPitch(b);
var i = substr(pa, pb);
// if a and b are in array notation, no conversion back
return a === pa && b === pb ? i : tonalPitches.toIvlStr(i);
}
export function interval (a, b) {
if (arguments.length === 1) return (b) => distance(a, b)
const pa = asPitch(a)
const pb = asPitch(b)
const i = substr(pa, pb)
// if a and b are in array notation, no conversion back
return a === pa && b === pb ? i : toIvlStr(i)
}
export function interval (a, b) {
if (arguments.length === 1) return (b) => distance(a, b)
const pa = asPitch(a)
const pb = asPitch(b)
const i = substr(pa, pb)
// if a and b are in array notation, no conversion back
return a === pa && b === pb ? i : toIvlStr(i)
}
* if not valid note
*
* @function
* @param {Pitch|String}
* @return {String}
* @example
* import { noteName } from 'tonal-notes'
* ['c', 'db3', '2', 'g+', 'gx4'].map(noteName)
* // => ['C', 'Db3', null, null, 'G##4']
*
* @example
* var tonal = require('tonal')
* tonal.noteName('cb2') // => 'Cb2'
* tonal.map(tonal.noteName, 'c db3 2 g+ gx4')
*/
var noteName = tonalPitches.noteFn(tonalPitches.id);
/**
* Get pitch class of a note. The note can be a string or a pitch array.
*
* @function
* @param {String|Pitch}
* @return {String} the pitch class
* @example
* tonal.pc('Db3') // => 'Db'
*/
var pc = tonalPitches.noteFn(function (p) {
return ['tnl', p[1]];
});
var ASC = ['tnl', -12, 7, 1]; // dimished second
var DESC = ['tnl', 12, -7, -1]; // descending dimished second
* var tonal = require('tonal')
* tonal.noteName('cb2') // => 'Cb2'
* tonal.map(tonal.noteName, 'c db3 2 g+ gx4')
*/
var noteName = tonalPitches.noteFn(tonalPitches.id);
/**
* Get pitch class of a note. The note can be a string or a pitch array.
*
* @function
* @param {String|Pitch}
* @return {String} the pitch class
* @example
* tonal.pc('Db3') // => 'Db'
*/
var pc = tonalPitches.noteFn(function (p) {
return ['tnl', p[1]];
});
var ASC = ['tnl', -12, 7, 1]; // dimished second
var DESC = ['tnl', 12, -7, -1]; // descending dimished second
/**
* Get the enharmonics of a note. It returns an array of three elements: the
* below enharmonic, the note, and the upper enharmonic
*
* @param {String} note - the note to get the enharmonics from
* @return {Array} an array of pitches ordered by distance to the given one
*
* @example
* enharmonics = require('enharmonics')
* enharmonics('C') // => ['B#', 'C', 'Dbb']
* var tonal = require('tonal')
* tonal.noteName('cb2') // => 'Cb2'
* tonal.map(tonal.noteName, 'c db3 2 g+ gx4')
*/
export const noteName = noteFn(id)
/**
* Get pitch class of a note. The note can be a string or a pitch array.
*
* @function
* @param {String|Pitch}
* @return {String} the pitch class
* @example
* tonal.pc('Db3') // => 'Db'
*/
export const pc = noteFn((p) => [ 'tnl', p[1] ])
var ASC = ['tnl', -12, 7, 1] // dimished second
var DESC = ['tnl', 12, -7, -1] // descending dimished second
/**
* Get the enharmonics of a note. It returns an array of three elements: the
* below enharmonic, the note, and the upper enharmonic
*
* @param {String} note - the note to get the enharmonics from
* @return {Array} an array of pitches ordered by distance to the given one
*
* @example
* enharmonics = require('enharmonics')
* enharmonics('C') // => ['B#', 'C', 'Dbb']
* enharmonics('A') // => ['G##', 'A', 'Bbb']
* enharmonics('C#4') // => ['B##3', 'C#4' 'Db4']
* if not valid note
*
* @function
* @param {Pitch|String}
* @return {String}
* @example
* import { noteName } from 'tonal-notes'
* ['c', 'db3', '2', 'g+', 'gx4'].map(noteName)
* // => ['C', 'Db3', null, null, 'G##4']
*
* @example
* var tonal = require('tonal')
* tonal.noteName('cb2') // => 'Cb2'
* tonal.map(tonal.noteName, 'c db3 2 g+ gx4')
*/
export const noteName = noteFn(id)
/**
* Get pitch class of a note. The note can be a string or a pitch array.
*
* @function
* @param {String|Pitch}
* @return {String} the pitch class
* @example
* tonal.pc('Db3') // => 'Db'
*/
export const pc = noteFn((p) => [ 'tnl', p[1] ])
var ASC = ['tnl', -12, 7, 1] // dimished second
var DESC = ['tnl', 12, -7, -1] // descending dimished second
/**
function interval(a, b) {
if (arguments.length === 1) return function (b) {
return distance(a, b);
};
var pa = tonalPitches.asPitch(a);
var pb = tonalPitches.asPitch(b);
var i = substr(pa, pb);
// if a and b are in array notation, no conversion back
return a === pa && b === pb ? i : tonalPitches.toIvlStr(i);
}
export function interval (a, b) {
if (arguments.length === 1) return (b) => distance(a, b)
const pa = asPitch(a)
const pb = asPitch(b)
const i = substr(pa, pb)
// if a and b are in array notation, no conversion back
return a === pa && b === pb ? i : toIvlStr(i)
}
function asArr(src) {
return tonalPitches.isArr(src) ? src : typeof src === 'string' ? src.trim().split(SEP) : src === null || typeof src === 'undefined' ? [] : [src];
}