Code Monkey home page Code Monkey logo

tambourine's Introduction

Tambourine

Tambourine is a framework for writing musical theory software. My main goal is to have a library capable of computing musical theory so that I can write a Harmonizer Engine on top of it. Because this library still doesn't have a the Harmonizer Engine I call it a music theory framework.

Installing It

You can simply install Tambourine using npm

npm install --save tambourine

It works with both web and node.js. So you can use it in web like:

<script src="node_modules/tambourine/bin/tambourine.js"></script>

Or importing it in node.js via any style you like:

import * as Tambourine from 'tambourine'
const Tambourine = require('tambourine')

Tambourine also comes with TypeScript type declarations. If your compiler can't find the type you can simply include it via:

/// <reference path="node_modules/tambourine/bin/tambourine.d.ts" />

API

Tambourine's full documentation can be found at tambourine.docs.kary.us.

Notes

Creating Notes

import { Note } from 'tambourine'

// Middle C (C5)
const C5 = new Note('C5')

// E#6
const ESharp6 = new Note('E#6')

// Creating a note 4 half steps after C5 which results in creating E5
const E5 = C5.createNewNoteWithIntervalOf( 4 )

// Creating note using MIDI number, For example A5 in midi is 69
const A5 = Note.createNoteByMIDI( 69 )

Note Functions

import { Note } from 'tambourine'

const A5 = new Note('A5')

// Note Attributes
A5.frequency    // returns 440  (number)
A5.fullName     // returns 'A5' (string)
A5.name         // returns 'A'  (string)
A5.octave       // returns 5    (number)
A5.MIDI         // returns 69   (string)

// Note Methods
A5.getDistanceTo( new Note('B5') ) // returns 2 (number) (as half steps)

Scales

Creating Scales

import { Note, Scale, ScaleCollection } from 'tambourine'

// You can create a new Scale by specifying the first note and then
// distance (intervals) between the notes, For example C major has:
// C, D, E, F, G, A, B. first note is 'C' and then distance between
// C and D is 2 half steps, then D and E is 2 half steps, E and F is
// 1 half step and so on. So the notation to create this scale will be:

const C4 = new Note('C4')
const C4MajorScale = new Scale( C4, 2, 2, 1, 2, 2, 2 )

// However to ease your job we provide a collection for scales
const C5 = new Note('C5')
const C5MajorScale = new ScaleCollection.Major( C5 )

// And Minor scales as well:
const C5minorScale = new ScaleCollection.Minor( C5 )

Working with Scales

import { Note, Scale, ScaleCollection } from 'tambourine'

const E5MajorScale = new ScaleCollection.Major( new Note('E5') )

// Properties
E5MajorScale.noteNames      // returns [ 'E', 'F#', 'G#', 'A', 'B', 'C#', 'D#' ]
                            // (string[ ]) - The name of the notes in string
E5MajorScale.notes          // returns an array of Note class instances (Note[])
E5MajorScale.keySignatures  // returns [ 'F#', 'G#', 'C#', 'D#' ] (string[])

tambourine's People

Contributors

mahmoud-sagharjoughi avatar pouyakary avatar

Stargazers

 avatar  avatar

Watchers

 avatar

tambourine's Issues

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.