1.0.7 • Published 2 years ago

leiter v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

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 NameFormulaDescription
Major2, 2, 1, 2, 2, 2, 1Bright, happy sound; commonly used in Western music
Minor2, 1, 2, 2, 1, 2, 2Sad, more emotional tone compared to major
Harmonic Minor2, 1, 2, 2, 1, 3, 1Combines elements of minor and middle-eastern music; characterized by a raised seventh note
Melodic Minor2, 1, 2, 2, 2, 2, 1Traditionally, raises the sixth and seventh notes when ascending and follows the natural minor when descending.
Pentatonic Major2, 2, 3, 2, 3Five-note scale; foundational to blues music
Pentatonic Minor3, 2, 2, 3, 2Five-note scale; foundational to blues music
Blues Minor3, 2, 1, 1, 3, 2Used in blues music; conveys feelings of melancholy
Blues Major2, 1, 1, 3, 2, 3Brighter blues sound
Phrygian1, 2, 2, 2, 1, 2, 2Dark, Spanish flavor; starts on the third degree of the major scale
Locrian1, 2, 2, 1, 2, 2, 2Unsettled, dissonant; starts on the seventh degree of the major scale
Dorian2, 1, 2, 2, 2, 1, 2Jazzy, starts on the second degree of the major scale
Mixolydian2, 2, 1, 2, 2, 1, 2Bright, but less so than major; starts on the fifth degree of the major scale
Lydian2, 2, 2, 1, 2, 2, 1Dreamy, starts on the fourth degree of the major scale
Whole Tone2, 2, 2, 2, 2, 2Dreamlike, lacking tonal center; all whole steps
Diminished Whole Half2, 1, 2, 1, 2, 1, 2, 1Symmetrical; creates tension and suspense
Diminished Half Whole1, 2, 1, 2, 1, 2, 1, 2Alternate form of diminished scale; intense dissonance
Augmented3, 1, 3, 1, 3Bright, raised pattern; every other note is augmented
Double Harmonic1, 3, 1, 2, 1, 3, 1Exotic, Middle Eastern and Gypsy flavor
Hungarian Gypsy2, 1, 3, 1, 1, 2, 1Similar to harmonic minor with augmented fourth
Hungarian Minor2, 1, 3, 1, 1, 3, 1Variant of harmonic minor with augmented fourth
Neapolitan Minor1, 2, 2, 2, 1, 3, 1Mix of Phrygian and harmonic minor
Neapolitan Major1, 2, 2, 2, 2, 2, 1Brighter variant of Neapolitan Minor
Persian1, 3, 1, 1, 2, 3, 1Middle Eastern flavor; combines Phrygian dominant and Locrian
Romanian Minor2, 1, 3, 1, 2, 1, 2Gypsy flavor; mix of Dorian and Phrygian
Hirajoshi2, 1, 4, 1, 4Associated with Japanese Koto music
In Sen1, 4, 2, 3, 2Traditional Japanese scale
Iwato1, 4, 1, 4, 2Pentatonic scale used in Japanese court music
Kumoi2, 1, 4, 2, 3Another scale from Japanese Koto music
Slendro2, 2, 2, 2, 4Pentatonic scale found in Java and Bali
Pelog1, 2, 4, 1, 4Another scale from the gamelan music of Java and Bali
Chinese Major4, 2, 1, 1, 4Traditional Chinese pentatonic scale
Chinese Minor3, 2, 3, 2, 2Another version of a Chinese pentatonic scale
Raga Bhairavi1, 2, 2, 1, 2, 1, 3A morning raga
Raga Kafi2, 1, 2, 2, 2, 1, 2Evening raga with similarities to the Dorian mode
Balinese1, 3, 2, 4, 2Associated with Balinese gamelan music

To Do:

  • Add support for flat notes as tonic
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.0

11 years ago