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.66.0 to 0.69.0

test/distance.test.js

31

build/index.js

@@ -7,9 +7,24 @@ 'use strict';

/**
* Functions to calculate distances between notes
*
* @example
* // using node's require
* var distance = require('tonal-distance')
* distance.interval('C4', 'G4') // => '5P'
*
* @example
* // using ES6 import
* import { interval, semitones } from 'tonal-distance'
* semitones('C' ,'D') // => 2
*
* @module distance
*/
// 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)
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
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)

@@ -39,5 +54,5 @@ }

if (arguments.length === 1) return function (b) { return interval(a, b) }
var pa = tonalPitch.asPitch(a)
var pb = tonalPitch.asPitch(b)
var i = substr(pa, pb)
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

@@ -59,3 +74,3 @@ return a === pa && b === pb ? i : tonalPitch.strIvl(i)

function semitones (a, b) {
var i = substr(tonalPitch.asPitch(a), tonalPitch.asPitch(b))
var i = substr(tonalPitch.asPitch(a), tonalPitch.asPitch(b));
return i ? tonalPitch.height(i) : null

@@ -65,2 +80,2 @@ }

exports.interval = interval;
exports.semitones = semitones;
exports.semitones = semitones;
{
"name": "tonal-distance",
"version": "0.66.0",
"version": "0.69.0",
"description": "Find distances between musical notes",

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

"pretest": "rollup -f cjs -o build/index.js -- index.js",
"test": "tape test/*.js"
"test": "jest --coverage"
},

@@ -23,4 +23,4 @@ "main": "build/index.js",

"dependencies": {
"tonal-pitch": "^0.66.0"
"tonal-pitch": "^0.69.0"
}
}
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