Giter VIP home page Giter VIP logo

tonal's Introduction

tonal

npm version build status minified size gzipped size

tonal is a music theory library. Contains functions to manipulate tonal elements of music (note, intervals, chords, scales, modes, keys). It deals with abstractions (not actual music or sound).

tonal is implemented in Typescript and published as a collection of Javascript npm packages.

It uses a functional programing style: all functions are pure, there is no data mutation, and entities are represented by data structures instead of objects.

Example

import { Interval, Note, Scale } from "@tonaljs/tonal";

Note.midi("A4"); // => 60
Note.freq("a4").freq; // => 440
Note.accidentals("c#2"); // => '#'
Note.transpose("C4", "5P"); // => "G4"
Interval.semitones("5P"); // => 7
Interval.distance("C4", "G4"); // => "5P"
Scale.get("C major").notes; // =>["C", "D", "E", "F", "G", "A", "B"];

Install

Install all packages at once:

npm install --save @tonaljs/tonal

Usage

Tonal is compatible with both ES5 and ES6 modules, and browser.

ES6 import:

import { Note, Scale } from "@tonaljs/tonal";

ES5 require:

const { Note, Scale } = require("@tonaljs/tonal");

Browser

You can use the browser version from jsdelivr CDN directly in your html:

<script src="https://cdn.jsdelivr.net/npm/@tonaljs/tonal/browser/tonal.min.js"></script>
<script>
  console.log(Tonal.Key.minorKey("Ab"));
</script>

Or if you prefer, grab the minified browser ready version from the repository.

Bundle size

@tonaljs/tonal includes all published modules.

Although the final bundle it is small (~10kb minified and gzipped), you can reduce bundle sizes even more by installing the modules individually, and importing only the functions you need:

npm i @tonaljs/note
import { transpose } from "@tonaljs/note";
transpose("A4", "P5");

Documentation

Generally, you just need to install:

The API documentation lives inside README.md file of each module

Notes and intervals

Scales and chords

Keys, chord progressions

Time, rhythm

Utilities

Contributing

Read contributing document for instructions

Inspiration

This library takes inspiration from other music theory libraries:

Projects using tonal

Showcase of projects that are using Tonal:

Thank you all!

Add your project here by editing this file

License

MIT License

tonal's People

Contributors

danigb avatar rakannimer avatar dependabot[bot] avatar ajrussellaudio avatar grimmdude avatar apalm avatar rowild avatar sashakhad avatar gabrocheleau avatar felixroos avatar limking24 avatar holden-caulfield avatar ashleymays avatar sashamahalia avatar shayanjavadi avatar tfeldmann avatar victorkolb avatar vpavlenko avatar jumski avatar zenberry avatar honkskillet avatar euniceong avatar hahanein avatar martijnmichel avatar mrfrac avatar thisisseb avatar wiese avatar yaph avatar szemek avatar panmichal avatar

Watchers

James Cloos avatar  avatar

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.