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

tonal-interval

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-interval

Music interval creation and manipulation

  • 0.69.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
676
decreased by-27%
Maintainers
1
Weekly downloads
 
Created
Source

tonal-interval npm version

tonal

tonal-interval is a collection of functions to create and manipulate music intervals.

This is part of tonal music theory library.

You can install via npm: npm i --save tonal-interval

API Reference

ivlName(ivl, the)

Get interval name. Can be used to test if it's an interval. It accepts intervals as pitch or string in shorthand notation or tonal notation. It returns always intervals in tonal notation.

semitones(ivl)Integer

Get size in semitones of an interval

fromSemitones(num)String

Get interval name from semitones number. Since there are several interval names for the same number, the name it's arbitraty, but deterministic.

ic(interval)Integer

Get the interval class number of a given interval.

In musical set theory, an interval class is the shortest distance in pitch class space between two unordered pitch classes

As paramter you can pass an interval in shorthand notation, an interval in array notation or the number of semitones of the interval

itype(interval)String

Get interval type. Can be perfectable (1, 4, 5) or majorable (2, 3, 6, 7)

invert(interval)String | Pitch

Get the inversion#Intervals) of an interval.

simplify(interval)String | Array

Get the simplified version of an interval.

ivlName(ivl, the)

Get interval name. Can be used to test if it's an interval. It accepts intervals as pitch or string in shorthand notation or tonal notation. It returns always intervals in tonal notation.

Kind: global function

ParamTypeDescription
ivlString | Pitch
theStringinterval name or null if not valid interval

Example

import { ivlName } from 'tonal-interval'
ivlName('m-3') // => '-3m'
ivlName('3') // => null
// part of tonal
tonal.ivlName('blah') // => null

semitones(ivl) ⇒ Integer

Get size in semitones of an interval

Kind: global function
Returns: Integer - the number of semitones or null if not an interval

ParamType
ivlString | Pitch

Example

import { semitones } from 'tonal-interval'
semitones('P4') // => 5
// or using tonal
tonal.semitones('P5') // => 7

fromSemitones(num) ⇒ String

Get interval name from semitones number. Since there are several interval names for the same number, the name it's arbitraty, but deterministic.

Kind: global function
Returns: String - the interval name

ParamTypeDescription
numIntegerthe number of semitones (can be negative)

Example

import { fromSemitones } from 'tonal-interval'
fromSemitones(7) // => '5P'
// or using tonal
tonal.fromSemitones(-7) // => '-5P'

ic(interval) ⇒ Integer

Get the interval class number of a given interval.

In musical set theory, an interval class is the shortest distance in pitch class space between two unordered pitch classes

As paramter you can pass an interval in shorthand notation, an interval in array notation or the number of semitones of the interval

Kind: global function
Returns: Integer - A value between 0 and 6

ParamTypeDescription
intervalString | Integerthe interval or the number of semitones

Example

const ic = require('interval-class')
ic('P8') // => 0
ic('m6') // => 4
['P1', 'M2', 'M3', 'P4', 'P5', 'M6', 'M7'].map(ic) // => [0, 2, 4, 5, 5, 3, 1]

itype(interval) ⇒ String

Get interval type. Can be perfectable (1, 4, 5) or majorable (2, 3, 6, 7)

Kind: global function
Returns: String - 'P' for perfectables, 'M' for majorables or null if not valid interval

ParamType
intervalString | Pitch

Example

tonal.itype('5A') // => 'P'

invert(interval) ⇒ String | Pitch

Get the inversion of an interval.

Kind: global function
Returns: String | Pitch - the inverted interval

ParamTypeDescription
intervalString | Pitchthe interval to invert in interval shorthand notation or interval array notation

Example

import { invert } from 'tonal-interval'
invert('3m') // => '6M'
// or using tonal
tonal.invert('2M') // => '7m'

simplify(interval) ⇒ String | Array

Get the simplified version of an interval.

Kind: global function
Returns: String | Array - the simplified interval

ParamTypeDescription
intervalString | Arraythe interval to simplify

Example

import { simplify } from 'tonal-interval'
simplify('9M') // => '2M'
['8P', '9M', '10M', '11P', '12P', '13M', '14M', '15P'].map(simplify)
// => [ '8P', '2M', '3M', '4P', '5P', '6M', '7M', '8P' ]
simplify('2M') // => '2M'
simplify('-2M') // => '7m'
// part of tonal
tonal.simplify('9m') // => '2m'

Keywords

FAQs

Package last updated on 04 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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