GithubHelp home page GithubHelp logo

camelot-wheel's Introduction

Camelot-Wheel npm downloads npm version Build Status

A package to allow for easy use of logic related the Circle of Fifths or 'Camelot Wheel'.

The Circle of Fifths shows the relationships among the twelve tones of the Chromatic Scale, their corresponding key signatures and the associated Major and Minor keys.

In lay terms: The Circle of Fifths is a music theory diagram for finding the key of a song, transposing songs to different keys, composing new songs and understanding key signatures, scales, and modes.

Usage

Install

npm i camelot-wheel

The Camelot Wheel

camelot-wheel

Now what is going on here?

  • Each number represents a key as stated above.
  • The outside of the wheel represents the Major mode and the inside of the wheel represents the Minor mode.
  • A track's key is considered compatible with another if it's positioned next to it or opposite it.
  • For example the key of C (8B) is compatible with F (7B), G (9B) and Am (8A)

API

  • getKey
  • getHarmonicKeys
  • getCamelotRoute

getKey(args)

This function will return all details about the key in question. You can pass it a key name, or the camelot position (with mode) or the pitch class (with mode)

import { getKey } from "camelot-wheel";

getKey({ name: "B" }); // ==> { name: "B", pitchClass: 11, mode: 1, camelotPosition: 1 }
import { getKey } from "camelot-wheel";

getKey({ pitchClass: 0, mode: 1 }); // ==> { name: "C", pitchClass: 0, mode: 1, camelotPosition: 8 }
import { getKey } from "camelot-wheel";

getKey({ camelotPosition: 8, mode: 1 }); // => { name: "C", pitchClass: 0, mode: 1, camelotPosition: 8 }

getHarmonicKeys

import { getHarmonicKeys } from "camelot-wheel";

getHarmonicKeys({ pitchClass: 0, mode: 1 });
// =>    [
//         { camelotPosition: 8, mode: 1, name: "C", pitchClass: 0 },
//         { camelotPosition: 7, mode: 1, name: "F", pitchClass: 5 },
//         { camelotPosition: 9, mode: 1, name: "G", pitchClass: 7 },
//         { camelotPosition: 8, mode: 0, name: "Am", pitchClass: 9 }
//       ]
import { getHarmonicKeys } from "camelot-wheel";

getHarmonicKeys({ name: "C" });
// =>    [
//         { camelotPosition: 8, mode: 1, name: "C", pitchClass: 0 },
//         { camelotPosition: 7, mode: 1, name: "F", pitchClass: 5 },
//         { camelotPosition: 9, mode: 1, name: "G", pitchClass: 7 },
//         { camelotPosition: 8, mode: 0, name: "Am", pitchClass: 9 }
//       ]
import { getHarmonicKeys } from "camelot-wheel";

getHarmonicKeys({ camelotPosition: 8, mode: 1 });
// =>    [
//         { camelotPosition: 8, mode: 1, name: "C", pitchClass: 0 },
//         { camelotPosition: 7, mode: 1, name: "F", pitchClass: 5 },
//         { camelotPosition: 9, mode: 1, name: "G", pitchClass: 7 },
//         { camelotPosition: 8, mode: 0, name: "Am", pitchClass: 9 }
//       ]

getCamelotRoute(startKey, targetKey)

This function will navigate you from the startKey to the endKey as quickly as possible.

import { getCamelotRoute } from "camelot-wheel";

getCamelotRoute({ pitchClass: 5, mode: 1 }, { pitchClass: 9, mode: 1 });
// => [
//      { name: "C", pitchClass: 0, mode: 1, camelotPosition: 8 },
//      { name: "G", pitchClass: 7, mode: 1, camelotPosition: 9 },
//      { name: "D", pitchClass: 2, mode: 1, camelotPosition: 10 }
//    ]
import { getCamelotRoute } from "camelot-wheel";

getCamelotRoute(
  { camelotPosition: 7, mode: 1 },
  { camelotPosition: 11, mode: 1 }
);
// => [
//      { name: "C", pitchClass: 0, mode: 1, camelotPosition: 8 },
//      { name: "G", pitchClass: 7, mode: 1, camelotPosition: 9 },
//      { name: "D", pitchClass: 2, mode: 1, camelotPosition: 10 }
//    ]
import { getCamelotRoute } from "camelot-wheel";

getCamelotRoute({ name: "F" }, { name: "A" });
// => [
//      { name: "C", pitchClass: 0, mode: 1, camelotPosition: 8 },
//      { name: "G", pitchClass: 7, mode: 1, camelotPosition: 9 },
//      { name: "D", pitchClass: 2, mode: 1, camelotPosition: 10 }
//    ]
import { getCamelotRoute } from "camelot-wheel";

getCamelotRoute({ name: "F" }, { camelotPosition: 11, mode: 1 });
// => [
//      { name: "C", pitchClass: 0, mode: 1, camelotPosition: 8 },
//      { name: "G", pitchClass: 7, mode: 1, camelotPosition: 9 },
//      { name: "D", pitchClass: 2, mode: 1, camelotPosition: 10 }
//    ]

Run the Tests

npm test

camelot-wheel's People

Contributors

jackbittiner avatar tobywinter avatar

Stargazers

Олег К. avatar xdave avatar smithart avatar Michael Arrington avatar Jonas avatar Nicholas Coles avatar Nao Y. avatar Ishan Marikar avatar Miko Kiiski avatar Christian St. Clair avatar  avatar

Watchers

James Cloos avatar  avatar  avatar Jonas avatar

Forkers

ishan-marikar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.