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

leiter

v1.0.7

Published

Leiter is a TypeScript-based library designed to generate musical scales based on a given tonic, octave, and scale type. It simplifies the process of obtaining notes in the correct pitch for various scales, facilitating musical application development.

Downloads

9

Readme

Leiter

Leiter is a TypeScript-based library designed to generate musical scales based on a given tonic, octave, and scale type. It simplifies the process of obtaining notes in the correct pitch for various scales, facilitating musical application development.

Features

  • Generate Scales: Easily retrieve scales based on the tonic, octave, and desired scale type.
  • TypeScript Support: Built with TypeScript for type-safety and developer experience.
  • Expandable: Developers can extend and add more scales as needed.
  • Streamlined and Lightweight: Lean design without excess, clocking in at just 13.3kB unpacked size.

Installation

Using npm:

npm install leiter

Usage

Here's a simple example:

import { generateScale } from 'leiter';

const scale = generateScale('A', 4, 'major');
console.log(scale);  // ['A4', 'B4', 'C#5', 'D5', 'E5', 'F#5', 'G#5', 'A5']

API

generateScale(tonic: string, octave: number, scaleName: ScaleName): string[]

Parameters:

  • tonic (NoteType): The root or starting note of the scale. It should be one of the standard note names (e.g., "C", "D#"). Please note that flat notes are note supported in the current release. Instead use the aquavalent sharp note.
  • octave (Octave): The octave in which the scale is to be generated. Represented as numbers between 0 - 8, where "C4" is the Middle C.
  • scaleName (ScaleType): The name of the scale pattern you want to generate. The library supports a vast array of scales, from standard major and minor scales to unique scales from diverse global traditions.

Returns:

An array of string values, each representing a note with it's pitch in the generated scale.

Types

ScaleType

type ScaleType = "major" | "minor" | "harmonicMinor" | "melodicMinor" | "pentatonicMajor" | "pentatonicMinor" | "bluesMinor" | "bluesMajor" | "phrygian" | "locrian" | "dorian" | "mixolydian" | "lydian" | "wholeTone" | "diminishedWholeHalf" | "diminishedHalfWhole" | "augmented" | "doubleHarmonic" | "hungarianGypsy" | "hungarianMinor" | "neapolitanMinor" | "neapolitanMajor" | "persian" | "romanianMinor" | "hirajoshi" | "inSen" | "iwato" | "kumoi" | "slendro" | "pelog" | "chineseMajor" | "chineseMinor" | "ragaBhairavi" | "ragaKafi" | "balinese";

NoteType

export type NoteType = "C" | "C#" | "D" | "D#" | "E"  | "F"  | "F#" | "G"  | "G#" | "A"  | "A#" | "B";

Octave

export type Octave = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8;

Supported Scales

| Scale Name | Formula | Description | |----------------------|---------------------------------------------|----------------------------------------| | Major | 2, 2, 1, 2, 2, 2, 1 | Bright, happy sound; commonly used in Western music | | Minor | 2, 1, 2, 2, 1, 2, 2 | Sad, more emotional tone compared to major | | Harmonic Minor | 2, 1, 2, 2, 1, 3, 1 | Combines elements of minor and middle-eastern music; characterized by a raised seventh note | | Melodic Minor | 2, 1, 2, 2, 2, 2, 1 | Traditionally, raises the sixth and seventh notes when ascending and follows the natural minor when descending. | | Pentatonic Major | 2, 2, 3, 2, 3 | Five-note scale; foundational to blues music | | Pentatonic Minor | 3, 2, 2, 3, 2 | Five-note scale; foundational to blues music | | Blues Minor | 3, 2, 1, 1, 3, 2 | Used in blues music; conveys feelings of melancholy | | Blues Major | 2, 1, 1, 3, 2, 3 | Brighter blues sound | | Phrygian | 1, 2, 2, 2, 1, 2, 2 | Dark, Spanish flavor; starts on the third degree of the major scale | | Locrian | 1, 2, 2, 1, 2, 2, 2 | Unsettled, dissonant; starts on the seventh degree of the major scale | | Dorian | 2, 1, 2, 2, 2, 1, 2 | Jazzy, starts on the second degree of the major scale | | Mixolydian | 2, 2, 1, 2, 2, 1, 2 | Bright, but less so than major; starts on the fifth degree of the major scale | | Lydian | 2, 2, 2, 1, 2, 2, 1 | Dreamy, starts on the fourth degree of the major scale | | Whole Tone | 2, 2, 2, 2, 2, 2 | Dreamlike, lacking tonal center; all whole steps | | Diminished Whole Half| 2, 1, 2, 1, 2, 1, 2, 1 | Symmetrical; creates tension and suspense | | Diminished Half Whole| 1, 2, 1, 2, 1, 2, 1, 2 | Alternate form of diminished scale; intense dissonance | | Augmented | 3, 1, 3, 1, 3 | Bright, raised pattern; every other note is augmented | | Double Harmonic | 1, 3, 1, 2, 1, 3, 1 | Exotic, Middle Eastern and Gypsy flavor | | Hungarian Gypsy | 2, 1, 3, 1, 1, 2, 1 | Similar to harmonic minor with augmented fourth | | Hungarian Minor | 2, 1, 3, 1, 1, 3, 1 | Variant of harmonic minor with augmented fourth | | Neapolitan Minor | 1, 2, 2, 2, 1, 3, 1 | Mix of Phrygian and harmonic minor | | Neapolitan Major | 1, 2, 2, 2, 2, 2, 1 | Brighter variant of Neapolitan Minor | | Persian | 1, 3, 1, 1, 2, 3, 1 | Middle Eastern flavor; combines Phrygian dominant and Locrian | | Romanian Minor | 2, 1, 3, 1, 2, 1, 2 | Gypsy flavor; mix of Dorian and Phrygian | | Hirajoshi | 2, 1, 4, 1, 4 | Associated with Japanese Koto music | | In Sen | 1, 4, 2, 3, 2 | Traditional Japanese scale | | Iwato | 1, 4, 1, 4, 2 | Pentatonic scale used in Japanese court music | | Kumoi | 2, 1, 4, 2, 3 | Another scale from Japanese Koto music | | Slendro | 2, 2, 2, 2, 4 | Pentatonic scale found in Java and Bali | | Pelog | 1, 2, 4, 1, 4 | Another scale from the gamelan music of Java and Bali | | Chinese Major | 4, 2, 1, 1, 4 | Traditional Chinese pentatonic scale | | Chinese Minor | 3, 2, 3, 2, 2 | Another version of a Chinese pentatonic scale | | Raga Bhairavi | 1, 2, 2, 1, 2, 1, 3 | A morning raga | | Raga Kafi | 2, 1, 2, 2, 2, 1, 2 | Evening raga with similarities to the Dorian mode | | Balinese | 1, 3, 2, 4, 2 | Associated with Balinese gamelan music |

To Do:

  • [ ] Add support for flat notes as tonic