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

music-scale

v1.2.0

Published

Create music scales

Downloads

57

Readme

music-scale npm version

tonal

music-scale is a module to create music scales. To create scales you can use intervals and tonic, type and tonic or scale name:

var scale = require('music-scale')

// get scale from name
scale.get('A major') // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#']

// get scale from type and tonic
scale('major', 'A4') // => ['A4', 'B4', 'C#4', 'D4', 'E4', 'F#4', 'G#4']

// get scale from intervals and tonic
scale('1 2 3 4 5 6 7', 'A') // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#']

// partially applied
var major = scale('major')
major('A') // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#']
major('A4') // => ['A4', 'B4', 'C#4', 'D4', 'E4', 'F#4', 'G#4']

This is part of tonal:

var tonal = require('tonal')
tonal.scale.get('D3 bebop') // => ...

Install

Via npm: npm i --save music-scale

Usage

Scales are a pitch sets with a tonic. Scales can be created from a list of intervals and a tonic, from a scale type and tonic, or from scale name.

Create scales from name

You can use scale.get function to obtain scale notes from scale name:

scale.get('C major') // => ['C', 'D', 'E', 'F', 'G', 'A', 'B']

With scale function, you should pass the scale type and tonic as two parameters:

scale('major', 'C') // => ['C', 'D', 'E', 'F', 'G', 'A', 'B']

Or partially apply it:

var major = scale('major')
major('A') // => ['A', 'B', 'C#', 'D', 'E', 'F#', 'G#']

Get available names

The scale.names function returns available names:

scale.names() // => ['Maj7', 'm7', ...]
scale.names(true) // => ['Maj7', 'm7', ...] <= with aliases

Create scale from intervals

scale('1 2 3m 4 5 6m 7', 'D') // => ['D', 'E', 'F', 'G', 'A', 'Bb', 'C#']

This function can be partially applied:

var dorian = set('1 2 3b 4 5 6 7b')
dorian('eb') // => [ 'Eb', 'F', 'Gb', 'Ab', 'Bb', 'C', 'Db' ]

The source can be also another scale:

scale('C D E F G A B C', 'A') // => ['A', 'B', 'C#' 'D', 'E', 'F#', 'G#']

Or even a collection of notes:

scale('C2 d4 g7 a2', 'C') // => ['C', 'D', 'G', 'A']

Scale tonics

If the tonic of a scale is a pitch class (a note without octave) the notes of the scale are pitch classes:

var major = scale('C D E F G A B C')
major('A') // => ['A', 'B', 'C#' 'D', 'E', 'F#', 'G#']

If the tonic of the scale is a note with octave, the notes of the scale will have octave numbers:

major('A4') // => ['A4', 'B4', 'C#5' ,'D5', 'E5', 'F#5', 'G#5']

If the tonic is null and the source are notes, the first pitch class of the scale source will be the tonic:

major(null) // => ['C', 'D', 'E', 'F', 'G', 'A', 'B']
scale('d4 f5 g2 c6 a1', null) // => [ 'D', 'F', 'G', 'A', 'C' ]

Get scale intervals

If the tonic of a scale is false, the intervals are returned:

scale('major', false) // => ['P1', 'M2', 'M3', 'P4', 'P5', 'M6', 'M7']

License

MIT License