Giter VIP home page Giter VIP logo

tonal.transpose's Introduction

tonal.transpose

Build Status Code Climate js-standard-style npm version license tonal

tonal.transpose is a compact function to transpose notes:

var transpose = require('tonal.transpose')
transpose('C3', '3m') // => 'Eb3'

It's part of tonal

Install

Via npm: npm i --save tonal.transpose and require the function. Use browserify or webpack to create a browser ready distribution.

Or use the distribution file (adds transpose function to window globals):

<script src="tonal.transpose.min.js"></script>
<script>console.log(transpose('C3', '3m'))</script>

Usage

Note transposition

The simplest usage is with a note name (pitch) and interval (the order doesn't matter):

transpose('C2', '4A') // => 'F#2'
transpose('4A', 'C2') // => 'F#2'

Pitch class transposition

You can transpose pitch classes (note names without octaves), and the returned value will be a pitch class:

tranpose('A', '3M') // => 'C#'
tranpose('A5', '3M') // => 'C#5'

Add intervals

If you need it you can transpose an interval:

transpose('3M', '3M') // => '5A'

Transposers

Also, you can partially apply the function to get a transposer:

var major3th = transpose('3M')
major3th('D') // => 'F#'

Map arrays

Partially applied transposers allows to work with arrays seamlessly:

['C', 'D', 'E', 'F', 'G'].map(transpose('3M')) // => ['E', 'F#', 'G#', 'A', 'B']
['1P', '3m', '5P'].map(transpose('C')) // => ['C', 'Eb', 'G']

More...

See tonal

License

MIT License

tonal.transpose's People

Contributors

danigb avatar

Watchers

 avatar 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.