Giter VIP home page Giter VIP logo

guitartools.js's Introduction

guitarTools.js

Javascript library of functions for creating diagrams of guitar chords and scales.

Here are three examples of this library in use.

Basic Setup

Download and include the guitarTools.js script somewhere in between your head tags. You should include the stylesheet as well in the head of your document.

Using guitarTools.js

There are two main functions you should be aware of at present. buildChord() and buildScale().

buildChord() Usage

buildChord(chord, show) Returns an HTML chord diagram.

buildChord() Parameters

chord (object)(required) The object for the chord you would like to build.

show (string)(required) Currently accepts two options. fingering or degrees. fingering will output the chord fingerings, degrees will output the chordal degrees.

Usage

This function only returns the chord and does not automatically display the chord. So, if you'd like to display an Em chord in the element with the id "chord" you'd do the following.
var elem = document.getElementById('chord');

elem.innerHTML = buildChord(
    {
        fingering: [0,1,2,0,0,0],
        chord: [0,2,2,0,0,0],
        degrees: [1,5,1,'b3',5,1],
    }, 'fingering'
);

The object needs three properties defined which are fingering, chord and degrees.

chord = the actual placement of the notes on the guitar fretboard. fingering = the fingers used to fret the notes. degrees = scale degrees the chord is built from.

Each of these properties values should be an array with six values in the array. There are six values in the array representing six strings on a guitar. So the first value will be the sixth string, second value the fifth string, third value the fourth string and so on.

If you'd like to build a chord where not every string is played, use "x" as the note value for that string. For example:

var elem = document.getElementById('chord');

elem.innerHTML = buildChord(
    {
        fingering: ['x',0,2,3,2,0],
        chord: ['x',0,2,2,1,0],
        degrees: ['x',1,5,1,'b3',5],
    }, 'fingering'
);

buildScale() Usage

buildScale(scale, show) Returns an HTML scale diagram.

buildScale() Parameters

scale (object)(required) The object for the scale you would like to build.

show (string)(required) Takes either "fingering" or "degrees" depending upon which you would like to show.

Usage

Usage is very similar to buildChord(). The structure of the scale object is slightly different in order to accommodate more than one note per string.

To show a C Major guitar scale diagram in the element with the id of "scale" you would do the following.

var elem = document.getElementById('scale');

elem.innerHTML = buildScale(
	{
		root: [['x'],[3],['x'],['x'],['x'],['x']],
		fingering: [[],[3],[0,2,3],[0,2],[0,1],[]],
		scale: [[],[3],[0,2,3],[0,2],[0,1],[]],
	}, 'fingering'
);

You can see there are now multi-dimensional arrays for root, fingering and scale in order to support multiple fretted notes per string.

This will make the most sense if you copy the example above, change some values then look at the html output of the function.

root = the starting note of the scale. Fill in the rest of the strings without root notes with "x". fingering = the fingering of the scale. scale = the actual placement of the notes in the scale on the fretboard.

guitartools.js's People

Contributors

bijingus avatar

Watchers

James Cloos 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.