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-theory-toolkit

v0.12.3

Published

Note/chord/set parsing, transposition, and enumeration tools

Downloads

15

Readme

Music Theory Toolkit

codecov Actions Status

This is a toolkit for note/chord/set parsing, transposition, and enumeration.

Consider interfaces to be unstable - I'm not strictly following semver until this library hits v1.0.0, but the following might help guide adoption/usage until then:

Stable interfaces:

  • Note (Class)
  • Chord (Class)

Not yet implemented interfaces:

  • Set (Class)
  • Scale (Class)

Installation and Setup

In your node or JavaScript project using NPM ( run npm init in a new directory, and follow the prompts ):

npm i music-theory-toolkit

Usage

Note

Object Usage

import { Note } from 'music-theory-toolkit';

// Generates a random note if not passed an arg,
// calculates numeric, absolute numeric, and frequency values as properties
const randomNote = new Note();

// Parses note, calculates all properties
const parsedNote = new Note('C#5');

// Transpose a number of half-steps (re-calculates all relevant values)
parsedNote.transpose(-12);

// This class uses the builder pattern, so you can do some pretty crazy things
const buildNote = new Note('C#').transpose(12).transpose(-25).frequency; // => 130.8127826502993 (Hz)

Static Helpers

import { Note } from 'music-theory-toolkit';

// Generate an alpha note filtered to only the # value if there is an enharmonic
// For example, if 'C#/Db' (or numeric 1) would have been the output, it will filter to 'C#'
const alphaNote = Note.random({ alpha: true, flatSharpFilter: '#' }); // => 'C#'

// Generate a numeric note between 0 and 11
const numericNote = Note.random(); // => 5

// Transpose a note to the 0-11 range, and adjust octave accordingly
// If no octave is passed, it assumes octave 4 is the baseline
const baselinedNote = Note.baseline(24); // => { numeric: 0, octave: 6 }

Chord

Object Usage

import { Chord } from 'music-theory-toolkit';

const chord = new Chord(); // Not yet implemented - this throws an error

Static Helpers

import { Chord } from 'music-theory-toolkit';

// Generate a random chord
const chordOne = Chord.random(); // => 'C#Maj7'
const chordTwo = Chord.random({ flatSharpFilter: false, maxDifficulty: 1 }); // => 'C#/DbMaj'
const chordThree = Chord.random({ maxDifficulty: 5 }); // => 'C#/Dbø7'

// Get a random chord quality object
const qualityOne = Chord.randomQuality({ maxDifficulty: 5 }); // => { difficulty: 1, name: 'Major', symbol: 'Maj', structure: [0, 4, 7] }
const qualityTwo = Chord.randomQuality({ targetDifficulty: 2 }); // => { difficulty: 2, name: 'Augmented', symbol: '+', structure: [0, 4, 8] }

Testing and Development

Testing libraries: Mocha & Chai

npm test