new Note( value [, options ] )

Description

The Note class represents a single note to be played. The Note can be played on a single channel by using OutputChannel.playNote() or on multiple channels at once by using Output.playNote().

If the note's duration property is set, the note will be stopped at the end of the duration. If no duration is set, it will play until it is explicitly stopped using OutputChannel.stopNote() or Output.stopNote().

Parameters
Name Type Attributes Default Description
value string | number

The name or note number of the note to create. If a number is used, it must be an integer between 0 and 127. If a string is used, it must be the note name followed by the octave ("C3", "G#4", "F-1", "Db7", etc.). The octave range must be between -1 and 9. The lowest note is C-1 (MIDI note number 0) and the highest note is G9 (MIDI note number 127).

options Object <optional>
{}
Name Type Attributes Default Description
duration number <optional>
Infinity

The number of milliseconds before the note should be explicitly stopped.

attack number <optional>
0.5

The note's attack velocity as a decimal number between 0 and 1.

release number <optional>
0.5

The note's release velocity as a decimal number between 0 and 1.

rawAttack number <optional>
64

The note's attack velocity as an integer between 0 and 127.

rawRelease number <optional>
64

The note's release velocity as an integer between 0 and 127.

Throws

Invalid note name.

Invalid note number.

Invalid duration.

Invalid attack value.

Invalid rawAttack value.

Invalid release value.

Invalid rawRelease value.

Details

3.0.0

Classes


new Note( value [, options ] )

Members


attack :number

Description

The attack velocity of the note as a decimal number between 0 and 1.

Details
number

duration :number

Description

The duration of the note as a positive decimal number representing the number of milliseconds that the note should play for.

Details
number

name :string

Description

The name of the note with the octave number ("C3", "G#4", "F-1", "Db7", etc.)

Details
string

number :number

Description

The MIDI note number as an integer between 0 and 127

Details
number

octave :number

Description

The octave of the note as an integer between -1 and 9.

Details
number

rawAttack :number

Description

The raw attack velocity of the note as an integer between 0 and 127.

Details
number

rawRelease :number

Description

The raw release velocity of the note as an integer between 0 and 127.

Details
number

release :number

Description

The release velocity of the note as a decimal number between 0 and 1.

Details
number