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

temperaments

v0.5.3

Published

Musical tunings/temperaments for Javascript

Downloads

104

Readme

temperaments

Musical tunings/temperaments for Javascript

Installation

npm i temperaments

Documentation

Below are some examples. The main API documentation is hosted on the project Github pages.

To generate documentation locally run:

npm run doc

Equal temperaments

import Temperament from 'temperaments';

// Twelve-tone equal temperament for 5-limit = 2.3.5
const edo12 = Temperament.fromVals([12], '2.3.5');

// How many steps represents a major seventh
edo12.steps('15/8'); // 11

// How many cents is a major seventh in 12edo
edo12.tune('15/8'); // 1100.0

Rank-2 temperaments

import Temperament from 'temperaments';

// Meantone as the val-join of 12edo and 19edo
const meantone = Temperament.fromVals([12, 19], '2.3.5');

// How many cents is the fifth in POTE meantone
meantone.tune('3/2'); // 696.239

// How about with tempered octaves
meantone.tune('3/2', {temperEquaves: true}); // 697.049

// How big is that octave
meantone.tune('2/1', {temperEquaves: true}); // 1201.397

POTE Mapping vector

import {toMonzo, dot} from 'xen-dev-utils';
import {Temperament} from 'temperaments';

// Porcupine temperament from the porcupine comma
// The subgroup 2.3.5 is automatically inferred
const porcupine = Temperament.fromCommas(['250/243']);

const POTE = porcupine.getMapping();

const minorThird = toMonzo('6/5');
const perfectFourth = toMonzo('4/3');

const m3Cents = dot(minorThird, POTE); // 327.901
const P4Cents = dot(perfectFourth, POTE); // 491.851

// These are the same because we're in porcupine
2 * P4Cents; // 983.702
3 * m3Cents; // 983.702

Fractional just intonation subgroups

import {Temperament} from 'temperaments';

const pinkan = Temperament.fromCommas(
  ['676/675', '1216/1215'],
  '2.3.13/5.19/5'
);

// CTE optimized
pinkan.tune('15/13', {constraints: ['2/1']}); // 248.846

Named temperaments

const passion = Temperament.fromName('passion');

Color temperaments

import {colorTemperament} from 'temperaments';
const mavila = colorTemperament('Layobi');

const superkleismic = colorTemperament('Tritriyo & Zotriyo');

Color commas

import {colorComma} from 'temperaments';

const comma = colorComma('Loru');

Large subgroups

Temperament instances get computationally expensive beyond subgroups larger than ~8. If you just need the TE mapping you can get it through optimized numeric methods.

import {tenneyVals, Subgroup, vanishCommas} from 'temperaments';

const magicMapping = tenneyVals([19, 22], new Subgroup(5));

// Not an exact TE mapping, but pretty close.
const miracleMapping = vanishCommas(["225/224", "1029/1024"]);

Gotchas

Subgroup needs to be explicit if the commas do not involve all of the primes in the limit.

// Specifying 5-limit is required if you do not want 2.5
const augmented = Temperament.fromCommas(['128/125'], 5);

If you want a mapping vector that covers a full prime limit, must pass {primeMapping: true} to Temperament.getMapping for subgroups that aren't full prime limits.

const slendric = Temperament.fromCommas(['1029/1024']);
const POTE = slendric.getMapping({primeMapping: true});

Additional resources

To work with named temperaments like Meantone or Marvel see named-temperaments.