chordplayer

1.1.6 • Public • Published

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.

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

Methods

  • play([callback])

    Plays the chord

= 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)

Package Sidebar

Install

npm i chordplayer

Weekly Downloads

1

Version

1.1.6

License

MIT

Last publish

Collaborators

  • laopunk