New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonal-distance

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-distance - npm Package Compare versions

Comparing version 0.50.0 to 0.50.1

84

build/tonal-distance.js

@@ -1,49 +0,45 @@

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('tonal-pitch')) :
typeof define === 'function' && define.amd ? define(['exports', 'tonal-pitch'], factory) :
(factory((global.distance = global.distance || {}),global.tonalPitch));
}(this, function (exports,tonalPitch) { 'use strict';
'use strict';
// substract two pitches
function substr (a, b) {
if (!a || !b || a[1].length !== b[1].length) return null
var f = tonalPitch.fifths(b) - tonalPitch.fifths(a)
if (tonalPitch.isPC(a)) return tonalPitch.pitch(f, -Math.floor(f * 7 / 12), 1)
var o = tonalPitch.focts(b) - tonalPitch.focts(a)
var d = tonalPitch.height(b) - tonalPitch.height(a) < 0 ? -1 : 1
return tonalPitch.pitch(d * f, d * o, d)
}
var tonalPitch = require('tonal-pitch');
/**
* Find distance between two pitches. Both pitches MUST be of the same type.
* Distances between pitch classes always returns ascending intervals.
* Distances between intervals substract one from the other.
*
* @param {Pitch|String} from - distance from
* @param {Pitch|String} to - distance to
* @return {Interval} the distance between pitches
* @example
* var tonal = require('tonal')
* tonal.distance('C2', 'C3') // => 'P8'
* tonal.distance('G', 'B') // => 'M3'
* tonal.distance('M2', 'P5') // => 'P4'
*/
function interval (a, b) {
if (arguments.length === 1) return (b) => distance(a, b)
const pa = tonalPitch.asPitch(a)
const pb = tonalPitch.asPitch(b)
const i = substr(pa, pb)
// if a and b are in array notation, no conversion back
return a === pa && b === pb ? i : tonalPitch.strIvl(i)
}
// substract two pitches
function substr (a, b) {
if (!a || !b || a[1].length !== b[1].length) return null
var f = tonalPitch.fifths(b) - tonalPitch.fifths(a)
if (tonalPitch.isPC(a)) return tonalPitch.pitch(f, -Math.floor(f * 7 / 12), 1)
var o = tonalPitch.focts(b) - tonalPitch.focts(a)
var d = tonalPitch.height(b) - tonalPitch.height(a) < 0 ? -1 : 1
return tonalPitch.pitch(d * f, d * o, d)
}
/**
* An alias for `distance`
* @function
*/
const distance = interval
/**
* Find distance between two pitches. Both pitches MUST be of the same type.
* Distances between pitch classes always returns ascending intervals.
* Distances between intervals substract one from the other.
*
* @param {Pitch|String} from - distance from
* @param {Pitch|String} to - distance to
* @return {Interval} the distance between pitches
* @example
* var tonal = require('tonal')
* tonal.distance('C2', 'C3') // => 'P8'
* tonal.distance('G', 'B') // => 'M3'
* tonal.distance('M2', 'P5') // => 'P4'
*/
function interval (a, b) {
if (arguments.length === 1) return function (b) { return distance(a, b) }
var pa = tonalPitch.asPitch(a)
var pb = tonalPitch.asPitch(b)
var i = substr(pa, pb)
// if a and b are in array notation, no conversion back
return a === pa && b === pb ? i : tonalPitch.strIvl(i)
}
exports.interval = interval;
exports.distance = distance;
/**
* An alias for `distance`
* @function
*/
var distance = interval
}));
exports.interval = interval;
exports.distance = distance;

@@ -28,6 +28,6 @@ import { isPC, fifths, focts, pitch, height, asPitch, strIvl } from 'tonal-pitch'

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 (arguments.length === 1) return function (b) { return distance(a, b) }
var pa = asPitch(a)
var pb = asPitch(b)
var i = substr(pa, pb)
// if a and b are in array notation, no conversion back

@@ -41,2 +41,2 @@ return a === pa && b === pb ? i : strIvl(i)

*/
export const distance = interval
export var distance = interval
{
"name": "tonal-distance",
"version": "0.50.0",
"version": "0.50.1",
"description": "Find distances between musical notes",

@@ -12,3 +12,3 @@ "keywords": [

"scripts": {
"pretest": "rm -rf build && mkdir build && rollup -f umd -n distance -o build/tonal-distance.js -- index.js",
"pretest": "rm -rf build && mkdir build && rollup -f cjs -n distance -o build/tonal-distance.js -- index.js",
"test": "tape 'test/*.js'",

@@ -15,0 +15,0 @@ "prepublish": "npm test"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc