Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including twelvetet-fretboard with all npm packages installed. Try it out:

var twelvetetFretboard = require("twelvetet-fretboard")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

twelvetet-fretboard v0.1.2

A small fretboard utility library for Javascript. It helps you manipulate pitches on a fretboard.

TwelveTetFretboard

TwelveTetFretboard is a small fretboard utility library for Javascript. It helps you manipulate pitches on a fretboard.

Please, refer to the Installation, Usage and API sections for more information.

Installation

Install the latest stable version of TwelveTetFretboard using npm:

npm install twelvetet-fretboard twelvetet

You can also access the files on unpkg.com.

You can use TwelveTetFretboard with module bundlers.

The npm package includes precompiled production and development UMD builds in the dist/ folder. They can be used without a bundler.

The UMD builds make TwelveTetFretboard available as window.TwelveTetFretboard global variable.

TwelveTetFretboard works in any modern browser and Node.js.

Usage

import Fretboard from 'twelvetet-fretboard'

const tuning = ['E2', 'A2', 'D3', 'G3', 'B3', 'E4'] // standard guitar tuning
const numFrets = 12
const fretboard = new Fretboard(tuning, numFrets)

console.log(fretboard.at(0, 0).toString())          // E4

API

Classes

TwelveTetFretboard

Typedefs

Position

TwelveTetFretboard

Kind: global class

new TwelveTetFretboard(tuning, numFrets, [tuningFrequency])

ParamTypeDescription
tuningArrayAn array of values representing fretboard tuning.
numFretsNumberA positive integer indicating the number of frets.
[tuningFrequency]NumberAn optional positive number indicating the tuning frequency.

Example

import Fretboard from 'twelvetet-fretboard'

const tuning = ['E2', 'A2', 'D3', 'G3', 'B3', 'E4'] // standard guitar tuning
const numFrets = 12
const fretboard = new Fretboard(tuning, numFrets)

console.log(fretboard.at(0, 0).toString())          // E4

twelveTetFretboard.positions

Kind: instance property of TwelveTetFretboard
Properties

NameTypeDescription
positionsArray.<Position>An array of all the positions on the fretboard

twelveTetFretboard.at(aStringIndex, aFretIndex) ⇒ Pitch

Returns the pitch at (stringIndex, fretIndex)

Kind: instance method of TwelveTetFretboard

ParamTypeDescription
aStringIndexNumberA zero-based integer indicating the string
aFretIndexNumberA zero-based integer indicating the fret

Position

Kind: global typedef
Properties

NameTypeDescription
pitchPitchThe pitch at (stringIndex, fretIndex).
stringIndexNumberA zero-based integer indicating the string
fretIndexNumberA zero-based integer indicating the fret

License

This project is MIT-licensed

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free