Global

Methods

buildFromFrequency(noteFreq, audioContextopt)

builds a notePlayer from a specific frequence
Parameters:
Name Type Attributes Description
noteFreq number sound frequency, in Hertz
audioContext Object <optional>
The audioContext to render the sound. Created if not provided
Source:
Example
buildFromFrequency(440)

buildFromKeyNb(noteKeyNb, audioContextopt)

builds a notePlayer from a specific piano key number
Parameters:
Name Type Attributes Description
noteKeyNb number corresponding number on a piano keyboard
audioContext Object <optional>
The audioContext to render the sound. Created if not provided
Source:
Example
buildFromKeyNb(49)

buildFromKeyNb(noteKeyNb, audioContextopt)

builds a notePlayer from a specific piano key number
Parameters:
Name Type Attributes Description
noteKeyNb number corresponding number on a piano keyboard
audioContext Object <optional>
The audioContext to render the sound. Created if not provided
Source:
Example
buildFromKeyNb(49)

buildFromName(noteName, audioContextopt)

builds a notePlayer from a specific musical note name
Parameters:
Name Type Attributes Description
noteName string Concatenation of note + octave [1-8]
audioContext Object <optional>
The audioContext to render the sound. Created if not provided
Source:
Example
buildFromName("C4")

play(callbackopt) → {Object}

plays the note
Parameters:
Name Type Attributes Description
callback function <optional>
callback function
Source:
Returns:
Oscillator
Type
Object
Example
play(function(){console.log("end play")})

setAttack(n)

Updates value of the note's attack
Parameters:
Name Type Description
n Number [0-1] the closer to 0 the longer the attack
Source:
Example
setAttack(0.3)

setAudioContext(ac)

assigns a specific audiocontext to the note
Parameters:
Name Type Description
ac Object Web Audio audioContext
Source:
Example
setAudioContext(ac)

setDestinationNode(dn)

assigns a specific destination node to the note (any connectable audioNode)
Parameters:
Name Type Description
dn Object Web Audio destinationNode
Source:
Example
setDestinationNode(audioContext.destination)

setDuration(d)

changes the time the note has to be played for
Parameters:
Name Type Description
d Number Time to play the note for, in second
Source:
Example
setDuration(2.3)

setRelease(n)

Updates value of the note's release
Parameters:
Name Type Description
n Number [0-1] the closer to 0 the longer the release
Source:
Example
setRelease(0.3)

setVerbose(vopt)

switches verbose mode on/ff
Parameters:
Name Type Attributes Description
v Number <optional>
True or false, default is true
Source:
Example
setVerbose(); setVerbose(false)

setVolume(v)

changes the volume
Parameters:
Name Type Description
v Number Volume level
Source:
Example
setVolume(0.5)