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

binary-scale

v0.1.0

Published

A musical scale implemented with binary numbers

Downloads

3

Readme

binary-scale

A (western well tempered) scale implemented with binary numbers.

IMPORTANT: This is a low-level library. Probably you'll use music-scale

You can see a demo here: http://danigb.github.io/scales

Usage

Install the module: npm install binary-scale --save and use it:

var Scale = require('binary-scale')
var major = Scale(2773)
major.binary // => '101011010101'
major.length // => 7 (7 note scale)
major.steps // => [2, 2, 1, 2, 2, 2, 1] (the distance in semitones between notes)

API: Scale(number)

The method receives an integer and returns an object with the following attributes:

  • decimal: the scale decimal equivalent to the binary representation
  • binary: a string with the binary representation
  • length: the number of notes of this scale
  • steps: an array with the distance in semitones between the notes of the scale
  • leap: the maximum distance between notes of the scale
  • modes: an array of binary strings with all the possible modes of this scale
  • rootMode: a binary string representing the root mode that generates the rest of the modes. The rootMode of all the modes of the same scale is the same

If the number is below Scale.MIN or bigger than Scale.MAX an exception is thrown.

Theory and inspiration

binary-scale is inspired by the works of Rich Cochrane, Walter Zettel and William Zeitler

Binary representations of scales

This is a implementation of binary scales as presented in the awesome book Arpeggio & Scale Resources by Rich Cochrane, chapter 18.

The following explanation is extracted from the book. (The book has a Creative Commons Usage Attribution-Noncommercial-No Derivative Works 3.0... thanks a lot Rich!)

The major scale is 1 0 1 0 1 1 0 1 0 1 0 1. This number (2773 in decimal, see previous example) uniquely represents the Major scale. The method of representation is simple: each position, reading left to right, represents a note: 1, b2, 2 and so on. A 1 in that position means the note is included in the scale and a 0 means it is not included. So we have:

1   0   1   0   1   1    0   1   0   1   0   1
1  b2   2  b3   3   4   b5   5  b6   6  b7   7

Why 2048 scales?

All the scales have root, so the smallest scale is '100000000000' (2048) and the biggest is '111111111111' (4095), so the total number is 2048 (4096 - 2048)

Most of they are not interesting enough to be used in music. For example, in the allthescales.org site they limit all the possibilities to those with leap < 5 (1490)

Scale modes

Note that modes of a scale are obtained by the technique known as 'bit rotation'. We would normally eliminate all those rows that begin with a zero, since they don't contain a root note:

101011010101 // ionian
010110101011
101101010110 // dorian
011010101101
110101011010 // phrygian
101010110101 // lydian
010101101011
101011010110 // mixolydian
010110101101
101101011010 // aeolian
011010110101
110101101010 // locrian

License

MIT License