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

glenn

v0.0.37

Published

Module for working with music theory concepts

Downloads

105

Readme

Glenn

Typescript module for working with music theory.

Still a work in progress.

Status and ratings

GitHub

Build Status CodeQL GitHub commit activity GitHub last commit GitHub code size in bytes GitHub top language GitHub

Sonar

Quality Gate Status CoverageMaintainability Rating Reliability Rating Security Rating Vulnerabilities Code Smells Bugs Duplicated Lines (%) Technical Debt Lines of Code

CodeScene

CodeScene Code Health CodeScene System Mastery

Code climate

Maintainability Test Coverage

Coveralls

Coverage Status

Mutation testing

Mutation testing badge


Documentation

Working with pitches

const c = Pitch.C;

console.log("Pitch detail of 'C':\n", c);
console.log("\n");
console.log("Pitch summary of 'c.sharp()':\n", c.sharp().To);
console.log("\n");
console.log("Pitch summary of 'c.flat()':\n", c.flat().To);
console.log("\n");
console.log("Absulute distance from 'C' to 'D':", c.absoluteDistance(Pitch.D));
console.log("\n");
console.log("Interval from 'C' to 'F':\n", c.intervalTo(Pitch.F).To);
console.log("\n");
console.log("Transpose 'C' by a 'minor third':\n", c.transpose(Interval.MinorThird).To);

Pitch Output

Pitch detail of 'C':
 _Pitch {
  name: 'C',
  value: 0,
  accidental: 1,
  sharp: [Function (anonymous)],
  flat: [Function (anonymous)],
  natural: [Function (anonymous)],
  intervals: [Function (anonymous)],
  PITCHES: 12
}

Pitch detail of 'c.sharp()':
 { name: 'C#', value: 1 }

Pitch detail of 'c.flat()':
 { name: 'B', value: 11 }

Absulute distance from 'C' to 'D': 2

Interval from 'C' to 'F':
 {
  name: 'Perfect Fourth',
  abreviature: 'P4',
  distance: 5,
  quality: 'Perfect'
}

Transpose 'C' by a 'minor third':
 { name: 'Eb', value: 3 }

Working with intervals

const interval = Interval.MinorThird;
const otherInterval = Interval.MinorSeventh;

console.log("Interval name:", interval.Name);
console.log("\n");
console.log("Invert 'minor third' interval:\n", interval.invert());
console.log("\n");
console.log("'m7' interval is larger than 'm3' interval:\n", otherInterval.isLargarThan(interval));

Intervals Output

Interval name: Minor Third

Invert 'minor third' interval:
 _Interval {
  name: 'Major Sixth',
  abreviature: 'M6',
  distance: 9,
  quality: _IntervalQuality { name: 'Major' },
  invert: [Function (anonymous)],
  raiseOctave: [Function (anonymous)]
}

'minor seventh' interval is larger than 'minor third' interval: true

Working with keys

const key = Key.CMajor;

console.log("Key notes:", Array.from(key).map((n) => n.Name));
console.log("\n");
console.log("Major keys:", Key.majorKeys.map((k) => k.Abbreviation));
console.log("\n");
console.log("Minor keys: ", Key.minorKeys.map((k) => k.Abbreviation));

Keys Output

Key notes: [
  'C', 'D', 'E',
  'F', 'G', 'A',
  'B'
]

Major keys: [
  'C', 'Db', 'D',  'Eb',
  'E', 'F',  'F#', 'Gb',
  'G', 'Ab', 'A',  'Bb',
  'B'
]

Minor keys:  [
  'Cm',  'C#m', 'Dm',
  'Ebm', 'Em',  'Fm',
  'F#m', 'Gm',  'G#m',
  'Am',  'Bbm', 'Bm'
]

Working with scales

const scale = ScalePattern.Ionian.createScale(Pitch.C);
const pitches = ScalePattern.Ionian.createScalePitches(Pitch.C);
const line = ScalePattern.Ionian.createMelodicLineScale(Pitch.C);
const descendingLline = ScalePattern.Ionian.createDescendingMelodicLineScale(Pitch.C);

console.log("Scale pitches:", Array.from(scale).map((n) => n.Name));
console.log("\n");
console.log("Scale pitches:", pitches.map((n) => n.Name));
console.log("\n");
console.log("Scale melodic line:", Array.from(line).map((n) => n.Name));
console.log("\n");
console.log("Scale descending melodic line:", Array.from(descendingLline).map((n) => n.Name));
console.log("\n");

const triadHarmonizer = new TriadHarmonizer(scale);
const triad = triadHarmonizer.chordFor(ScaleDegree.I)
const seventhHarmonizer = new SeventhHarmonizer(scale);
const seventhChord = seventhHarmonizer.chordFor(ScaleDegree.II)

console.log("Chord for scale degree I: ", triad.Name);
console.log("Chord for scale degree II: ", seventhChord.Name);

Scales Output

Scale pitches: [
  'C', 'D', 'E',
  'F', 'G', 'A',
  'B'
]

Scale pitches: [
  'C', 'D', 'E',
  'F', 'G', 'A',
  'B'
]

Scale melodic line: [
  'C', 'D', 'E',
  'F', 'G', 'A',
  'B'
]

Scale descending melodic line: [
  'C', 'D', 'E',
  'F', 'G', 'A',
  'B'
]

Chord for scale degree I: CMajor
Chord for scale degree II: DMinor 7

Working with chords

const chord = new ClosedChord(Pitch.C, ChordPattern.Major);

const chord = new ClosedChord(Pitch.C, ChordPattern.Major);

let chord = new ClosedChord(Pitch.C, ChordPattern.Major);

console.log("Chord name: ", chord.Name);
console.log("Pich for chord root: ", chord.pitchForFunction(ChordFunction.Root).Name);
console.log("Chord pitches", Array.from(chord).map((p: Pitch) => p.Name));
console.log("Chord bass pitch", chord.Bass.Name);
console.log("Chord lead pitch", chord.Lead.Name);
console.log("Chord no fifth", Array.from(chord.remove(ChordFunction.Fifth)).map((p: Pitch) => p.Name));
console.log("Chord inverted", Array.from(chord.invert()).map((p: Pitch) => p.Name));

chord = new ClosedChord(Pitch.C, ChordPattern.Major7);

console.log("Chord ", Array.from(chord).map((p: Pitch) => p.Name));
console.log("Chord drop 2", Array.from(chord.drop2()).map((p: Pitch) => p.Name));
console.log("Chord drop 3", Array.from(chord.drop3()).map((p: Pitch) => p.Name));

Chords Output

Chord name: CMajor
Pich for chord root: C
Chord pitches: [ 'C', 'E', 'G' ]
Chord bass pitch: C
Chord lead pitch: G
Chord no fifth: [ 'C', 'E' ]
Chord inverted: [ 'E', 'G', 'C' ]
Chord: [ 'C', 'E', 'G', 'B' ]
Chord drop 2: [ 'C', 'G', 'B', 'E' ]
Chord drop 3: [ 'C', 'E', 'G', 'B' ]

Working with guitar tab

console.log("Empty tab:\n", Tab.render());
console.log("\n");

const melodicLine = ScalePattern.Ionian.createMelodicLineScale(Pitch.C);
const guitarLine = new GuitarMelodicLine(melodicLine, Position.C);
const guitarLine1 = new GuitarMelodicLine(line, Position.Open);

console.log("Guitar melodic line (C position):\n", Tab.render(guitarLine.toTab()));
console.log("\n");
console.log("Guitar melodic line (Open position ):\n", Tab.render(guitarLine1.toTab()));
console.log("\n");

const cChord = new ClosedChord(Pitch.C, ChordPattern.Major);
const guitarChord = GuitarChord.inPosition(cChord, Position.Open);
const chordTab = Tab.render(new Tab(guitarChord.toTab()));

console.log("Chord as tab:\n", chordTab);
console.log("\n");

const cMaj7 = new ClosedChord(Pitch.C, ChordPattern.Major7);
const dMin7 = new ClosedChord(Pitch.D, ChordPattern.Minor7);
const eMin7 = new ClosedChord(Pitch.E, ChordPattern.Minor7);
const fMaj7 = new ClosedChord(Pitch.F, ChordPattern.Major7);
const g7 = new ClosedChord(Pitch.G, ChordPattern.Dominant7);
const chords = [cMaj7, dMin7, eMin7, fMaj7, g7].map((c) => c.drop2());

const harmonicLine = new GuitarHarmonicLine(GuitarString.Sixth, chords);

const chordsTab = Tab.render(harmonicLine.toTab());
console.log("Chords as tab:\n", chordsTab);
console.log("\n");

Guitar Tab Output

Empty tab:
e|--|
B|--|
G|--|
D|--|
A|--|
E|--|


Guitar melodic line (C position):
e|---------------|
B|---------------|
G|-----------2-4-|
D|-----2-3-5-----|
A|-3-5-----------|
E|---------------|


Guitar melodic line (Open position ):
e|---------------|
B|---------------|
G|---------0-2-4-|
D|---0-2-3-------|
A|-3-------------|
E|---------------|


Chord as tab:
e|-0-|
B|-1-|
G|-0-|
D|-2-|
A|-3-|
E|-0-|


Chords as tab:
e|-------------|
B|-------------|
G|--9-10-0-2-4-|
D|--9-10-0-2-3-|
A|-10-12-2-3-5-|
E|--8-10-0-1-3-|