1.1.6 • Published 7 years ago

chordplayer v1.1.6

Weekly downloads
3
License
MIT
Repository
github
Last release
7 years ago

CHORDPLAYER.JS

Installation:

You may import the code into an existing node.js project or import it directly into your HTML code

  • Node module import
# local install to your project
npm install --save-dev chordplayer
// import module into your js code
var cp = require('chordplayer') 
  • plain JS import
<!-- minified version, not human friendly, 56kb-->
<script type="text/javascript" src="chordPlayer.min.js"></script>
<!-- uncompressed version, human friendly, 418kb -->
<script type="text/javascript" src="chordPlayer.js"></script>

The module is instanciated in the object cp, which you can use right away

cp.buildChordPlayer("Cmin7b5").play()

Constructors

There are several ways to instanciate the class:

  • buildChordPlayer(chordName,[audioContext])

    Builds a chordPlayer from a specific name. audioContext is created if not provided.

    c = cp.buildChordPlayer("Cmin7b5");     //will return a chord with 4 notes ("C", "D#", "F#", "A#")
    c = cp.buildChordPlayer("Cdim");        //will return a chord with 3 notes ("C", "D#", "F#")
    c = cp.buildChordPlayer("A#maj");       //will return a chord with 3 notes ("A#", "D", "F")
    c = cp.buildChordPlayer("Bbmaj");       //will return a chord with 3 notes ("A#", "D", "F")

Methods

  • play([callback])

    Plays the chord

    c = cp.buildChordPlayer("Amaj")
    c.play(function(){
      console.log("end play")
    })
  • getChordInfo()

    Returns the notes present in the chord

    cp.buildChordPlayer("Bbmaj").getChordInfo()

Setters:

  • setAudioContext(audioContext)
  • setDestinationNode(node)
  • setDuration(duration)
  • setOctave(octaveNb)
  • setVolume(volume)