npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tonal-interval

v2.2.2

Published

Music interval creation and manipulation

Downloads

12,348

Readme

Interval

Interval.semitones("4P") // => 5 Interval.invert("3m") // => "6M" Interval.simplify("9m") // => "2m"Install

Interval.num(interval) ⇒ string

Kind: static method of Interval
Returns: string - the interval name or null if not valid interval

| Param | Type | Description | | --- | --- | --- | | interval | string | the interval string or array |

Example

Interval.name("m-3") // => "-3m"
Interval.name("3") // => null

Interval.name(ivl) ⇒ Integer

Kind: static method of Interval
Returns: Integer - the number of semitones or null if not an interval

| Param | Type | | --- | --- | | ivl | string |

Example

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

Interval.semitones(str) ⇒ Number

Kind: static method of Interval

| Param | Type | | --- | --- | | str | string |

Interval.chroma(interval) ⇒ Integer

Kind: static method of Interval
Returns: Integer - A value between 0 and 6

| Param | Type | Description | | --- | --- | --- | | interval | String | Integer | the interval or the number of semitones |

Example

Interval.ic("P8") // => 0
Interval.ic("m6") // => 4
Interval.ic(10) // => 2
["P1", "M2", "M3", "P4", "P5", "M6", "M7"].map(ic) // => [0, 2, 4, 5, 5, 3, 1]

Interval.ic(props) ⇒ string

Kind: static method of Interval
Returns: string - the interval name

| Param | Type | Description | | --- | --- | --- | | props | Object | the interval property object |

Example

Interval.build({ step: 1, alt: -1, oct: 0, dir: 1 }) // => "1d"
Interval.build({ num: 9, alt: -1 }) // => "9m"

Interval.build(interval) ⇒ string

Kind: static method of Interval
Returns: string - the simplified interval

| Param | Type | Description | | --- | --- | --- | | interval | string | the interval to simplify |

Example

Interval.simplify("9M") // => "2M"
["8P", "9M", "10M", "11P", "12P", "13M", "14M", "15P"].map(Interval.simplify)
// => [ "8P", "2M", "3M", "4P", "5P", "6M", "7M", "8P" ]
Interval.simplify("2M") // => "2M"
Interval.simplify("-2M") // => "7m"

Interval.simplify(interval) ⇒ string

Kind: static method of Interval
Returns: string - the inverted interval

| Param | Type | Description | | --- | --- | --- | | interval | string | the interval to invert in interval shorthand notation or interval array notation |

Example

Interval.invert("3m") // => "6M"
Interval.invert("2M") // => "7m"

Interval~names(qualities) ⇒ Array

Kind: inner method of Interval
Returns: Array - the interval names

| Param | Type | Description | | --- | --- | --- | | qualities | string | (Optional, default "PMm") the valid types |

Example

Interval.names() // => [ "1P", "2m", "2M", "3m", "3M", "4P", "5P", "6m", "6M", "7m", "7M", "8P" ]
Interval.names("P") // => [ "1P", "4P", "5P", "8P" ]
Interval.names("PM") // => [ "1P", "2M", "3M", "4P", "5P", "6M", "7M", "8P" ]
Interval.names("Pm") // => [ "1P", "2m", "3m", "4P", "5P", "6m", "7m", "8P" ]
Interval.names("d") // => []

Interval~props(interval) ⇒ Object

Kind: inner method of Interval
Returns: Object - the interval in the form [number, alt]

| Param | Type | Description | | --- | --- | --- | | interval | string | the interval |

Interval~num(interval) ⇒ Integer

Kind: inner method of Interval

| Param | Type | Description | | --- | --- | --- | | interval | string | the interval |

Example

Interval.num("m2") // => 2
Interval.num("P9") // => 9
Interval.num("P-4") // => -4

Interval~fromSemitones(num) ⇒ string

Kind: inner method of Interval
Returns: string - the interval name

| Param | Type | Description | | --- | --- | --- | | num | Integer | the number of semitones (can be negative) |

Example

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