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

microtonal

v1.0.0

Published

A micro library for music composition

Downloads

260

Readme

microtonal

Build Status

The enterprise of “musical set theory” aspires to catalogue all the chords available to contemporary composers. Unfortunately, this project turns out to be more complicated than one might imagine

Microtonal is a micro (3kb) library to create music compositions

npm install microtonal

microtonal.name ⇒ string

Get the note name of a pitch

Kind: static constant of microtonal
Returns: string - the note name if any

| Param | Type | | --- | --- | | pitch | number |

microtonal.names ⇒ array.<string>

Get the note names of a musical object.

Kind: static constant of microtonal
Returns: array.<string> - the musical object note names

| Param | Type | | --- | --- | | list | array.<number> |

Example

names([60, 61, 62]) => // ['C4', 'C#4', 'D4']

microtonal.scaleGen ⇒ function

Creates a scale generator. A scale generator is a function that returns an scale. An scale is a function that, given a degree number, it returns the scale note.

Kind: static constant of microtonal

| Param | Type | Description | | --- | --- | --- | | intervals | arr | the scale intervals during an octave |

Example

const major = scaleGen([0, 2, 4, 5, 7, 9, 11]);
const Cmajor = major(60)
Cmajor(0) // => 60
Cmajor(1) // => 62

microtonal.scales

A collection of named scales. It includes: chromatic, major, minor

Kind: static constant of microtonal

microtonal.pitch(source) ⇒ number

Creates a pitch. A pitch is a float number representing the height of the note. The pitch is the same as the midi number but with float precission.

Basicaly it tries to parse a float

Kind: static method of microtonal
Returns: number - the pitch

| Param | Type | | --- | --- | | source | number | string |

microtonal.midi(pitch) ⇒ integer

Get the midi value of a pitch. The midi value is the pitch without the float

Kind: static method of microtonal
Returns: integer - the midi number

| Param | Type | | --- | --- | | pitch | number |

microtonal.toFreq(pitch, [tuning]) ⇒ number

Convert a pitch into a frequency

Kind: static method of microtonal
Returns: number - the frequency

| Param | Type | Default | | --- | --- | --- | | pitch | number | | | [tuning] | number | 440 |

microtonal.fromFreq(freq, [tuning]) ⇒ number

Convert a frequency into a pitch

Kind: static method of microtonal
Returns: number - the pitch

| Param | Type | Default | | --- | --- | --- | | freq | number | | | [tuning] | number | 440 |

microtonal.tr(pitch, interval) ⇒ number

Transpose a pitch by an interval

Kind: static method of microtonal
Returns: number - the resulting pitch

| Param | Type | | --- | --- | | pitch | number | | interval | number |

Example

tr(4, 3) => 7

microtonal.trBy(interval) ⇒ function

Creates a function that transposes a pitch by an interval

Kind: static method of microtonal
Returns: function - the transpose function

| Param | Type | | --- | --- | | interval | number |

Example

[60, 61, 82].map(trBy(3));

microtonal.dist(from, to)

Finds the distance between two pitches

Kind: static method of microtonal

| Param | Type | | --- | --- | | from | number | | to | number |

microtonal.distFrom(root) ⇒ function

Creates a function that finds a distance from a root

Kind: static method of microtonal
Returns: function - the distance function

| Param | Type | | --- | --- | | root | number |

microtonal.inv(pitch, center) ⇒ number

Invert a pitch along a center

Kind: static method of microtonal
Returns: number - the inverted pitch

| Param | Type | | --- | --- | | pitch | number | | center | number |

microtonal.invFrom(center) ⇒ function

Creates a function that inverts a note from a center

Kind: static method of microtonal
Returns: function - the invert function

| Param | Type | | --- | --- | | center | pitch |

microtonal.center(from, to) ⇒ number

Find the center between two pitches

Kind: static method of microtonal
Returns: number - center

| Param | Type | | --- | --- | | from | number | | to | number |

microtonal.pc(pitch) ⇒ number

Get the pitch class of a pitch

Kind: static method of microtonal
Returns: number - the pitch class number (0 = C, 1 = D, ... 6 = B with numbers in-between)

| Param | Type | | --- | --- | | pitch | number |

microtonal.pctr(pitchClass, interval) ⇒ number

Transpose a pitch class

Kind: static method of microtonal
Returns: number - the pitch class of the transposition

| Param | Type | | --- | --- | | pitchClass | number | | interval | number |

microtonal.pcdist(fromPitchClass, toPitchClass) ⇒ number

Find the distance between pitch classes

Kind: static method of microtonal
Returns: number - the distance (less or equal to 12)

| Param | Type | | --- | --- | | fromPitchClass | number | | toPitchClass | number |

microtonal.pcinv(pitchClass, center) ⇒ number

Invert a pitch class from a center

Kind: static method of microtonal
Returns: number - the pitch class

| Param | Type | | --- | --- | | pitchClass | number | | center | number |

microtonal.mu(pitches) ⇒ array.<number>

Create a musical object. A musical object is as an ordered series of pitches, uncategorized and uninterpreted.

Kind: static method of microtonal
Returns: array.<number> - the musical object

| Param | Type | | --- | --- | | pitches | array.<number> |

Example

mu('C D E') => [0, 2, 4]

microtonal.sort(mu, [ascending]) ⇒ array.<number>

Sort a musical object

Kind: static method of microtonal
Returns: array.<number> - the sorted musical object

| Param | Type | Default | | --- | --- | --- | | mu | array.<number> | | | [ascending] | boolean | true |

microtonal.uniq(mu) ⇒ array.<number>

Sort and remove duplicates from a musical object

Kind: static method of microtonal
Returns: array.<number> - a new musical object without the duplications

| Param | Type | | --- | --- | | mu | array.<number> |

microtonal.pitchset(pitches) ⇒ array.<number>

Create a pitch set: an unordered sets of pitches

Kind: static method of microtonal
Returns: array.<number> - the pitch set
See: Geometry of Music, p. 40

| Param | Type | | --- | --- | | pitches | array.<number> |

microtonal.pclist(mu) ⇒ array.<number>

Creates a pclist: an unordered collection of pitch class sets

Kind: static method of microtonal
Returns: array.<number> - a new multiset object with the pitch classes

| Param | Type | Description | | --- | --- | --- | | mu | array.<number> | the musical object |

microtonal.pcset(mu) ⇒ array.<number>

Creates a pitch class set: an ordered set of pitch classes

Kind: static method of microtonal
Returns: array.<number> - a new pitch set array with the pitch classes

| Param | Type | Description | | --- | --- | --- | | mu | array.<number> | the musical object |

microtonal.chromatic(tonic) ⇒ function

Creates a chromatic scale.

Kind: static method of microtonal
Returns: function - the scale

| Param | Type | | --- | --- | | tonic | number |

microtonal.major(tonic) ⇒ function

Creates a major scale

Kind: static method of microtonal
Returns: function - the scale

| Param | Type | | --- | --- | | tonic | number |

microtonal.minor(tonic) ⇒ function

Creates a minor scale

Kind: static method of microtonal
Returns: function - the scale

| Param | Type | | --- | --- | | tonic | number |

microtonal.pentatonic(tonic) ⇒ function

Creates a minor scale

Kind: static method of microtonal
Returns: function - the scale

| Param | Type | | --- | --- | | tonic | number |

microtonal.degrees(scale, elements)

Generate a number of degrees of a given scale

Kind: static method of microtonal

| Param | Type | | --- | --- | | scale | function | | elements | number |

Example

const scale = degrees(major(60));
scale(8) // => [60, 62, 64, 65, 67, 69, 71, 72]
scale(-8) // =>