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

scalesapi

v1.1.3

Published

A library to easily get information from musical scales

Downloads

11

Readme

SCALESAPI.JS

Purpose

This library / module is your javascript swiss knife to easily work around musical scales even if you are not a musician. Clearly, it will allow you to "sound good" and more importantly "sound in key" when you want to randomly play sounds.

  • use cases
    • Find the scale you're in, from a set of chords or notes (Ideal for composers)
    • Find all existing chords and notes in a scale you're interested in working with
  • related libraries

Installation:

You may import the code into an existing node.js project or import it directly into your HTML code

  • Node module import
# local install to your project
npm install --save-dev scalesapi
// import module into your js code
var sc = require('scalesapi') 
  • plain JS import
<!-- minified version, not human friendly, 56kb-->
<script type="text/javascript" src="scalesAPI.min.js"></script>
<!-- uncompressed version, human friendly, 422kb -->
<script type="text/javascript" src="scalesAPI.js"></script>

The module is instanciated in the object sc, which you can use right away

getScales("info")

Constructors

No constructor, the library consists of methods only. It consists of three main functions :

  • getScales: information about chords and notes existing in a scale
  • getChords: information about chords existing in a scale
  • getNotes: information about notes existing in a scale

Methods

getScales(action, [value])
  • getScales("names")
getScales("names")        //returns a list like ["Major", "Natural Minor", ...]

Get the list of names from all scales available in the config

  • getScales("info", [scaleName])
getScales("info")         //returns data for all scales
getScales("info","Major") //returns data for the Major scale only

Get scales meta-data information (object) from the config: - chord sequence for 3 notes chords - chord sequence for 4 notes chords - interval sequence If is not provided, return data for all scales

  • getScales("object")
getScales("object")       //returns object

Get scales content from the config, for all keys in all scales:

scaleName
  \__ keyName
      \__ Chords3: [list of chords with 3 notes] 
      \__ Chords4: [list of chords with 4 notes] 
      \__ Notes:   [list of notes present in the scale]
  • getScales("fromChords", chordsArray)
getScales("fromChords",[])                          //returns all keys in all scales
getScales("fromChords",["Amin","Cmaj","Dmin"])      //returns keys in two scales

The most popular method. It allows you to know which keys in various scales a set of chords belongs to. Returns an object containing this info:

 scaleName
   \__ keyName
  • getScales("fromNotes", notesArray)
getScales("fromNotes",[])                  //returns all keys in all scales
getScales("fromNotes",["A","C","Db"])      //returns keys in two scales

The most popular method. It allows you to know which keys in various scales a set of notes belongs to. Returns an object containing this info:

 scaleName
   \__ keyName
getChords(scaleName, [key], [nbNotes])
  • getChords("*")
getChords("*")        //returns a list of chords

Get the full list of unique chords in all scales

  • getChords("byRoot")
getChords("byRoot")   //returns a list of chords

Get the full list of unique chords in all scales, grouped by key

  • getChords(scaleName)
getChords("Major")   //returns a list of all chords present in the Major scale, all keys included

Get the full list of unique chords in a specific scale . The list of available scales can be obtained from getScales("names")

  • getChords(scaleName, keyName)
getChords("Major","E")   //returns a list of all chords present in the key of E in the Major scale

Get the full list of unique chords in a specific scale for a specific key

  • getChords(scaleName, keyName, nbNotes)
getChords("Major","E", 3)   //returns a list of all 3 notes chords present in the key of E in the Major scale
getChords("Major","E", 4)   //returns a list of all 4 notes chords present in the key of E in the Major scale

Get the full list of unique chords in a specific scale, for a specific key and a specific nb of notes in the chords

getNotes(scaleName, [key])
  • getNotes("*")
getNotes("*")        //returns a list of notes

Get the full list of unique notes in all scales and all keys. This is the equivalent of the chromatic scale.

  • getNotes(scaleName)
getNotes("Harmonic Minor")        //returns a list of notes in the harmonic minor scale

Get the full list of unique notes in a specicif scale for all keys

  • getNotes(scaleName, keyName)
getNotes("Harmonic Minor","Eb")        //returns a list of notes in the harmonic minor scale, key of Eb

Get the full list of unique notes in a specicif scale for a specific key