class Mass::Note
Represents a single note in the pattern.
Constants
- OFF
Hex value for sending to
UniMIDI
that signals when this note should cease playing.@type [Fixnum]
- ON
Hex value for sending to
UniMIDI
that signals when this note should begin playing.@type [Fixnum]
- VELOCITIES
Dictionary of velocity values from a given
expression
.@type [Hash<Symbol>]
Attributes
BPM passed in from the sequence.
@attr_reader [Integer]
Duration value of the note.
@attr_reader [Integer]
Expression value of the note, e.g. ‘:ff’. This can optionally be given as an Integer for maximum velocity control and is simply output as the velocity.
The following expression values are supported:
-
:ff
-
:mf
-
:f
-
:mp
-
:p
-
:pp
@attr_reader [Symbol | Integer]
MIDI output object.
@attr_reader [UniMIDI::Output]
Pitch
object used for figuring out the MIDI pitch value.
@attr_reader [Mass::Pitch]
Rhythmic duration value for this note.
@attr_reader [Integer]
Public Class Methods
@param [Integer] value @param [String] pitch @param [Symbol | Integer] exp - Can be expressed as either @param [UniMIDI::Output] midi
# File lib/mass/note.rb, line 79 def initialize(value: 1, pitch: nil, exp: :mp, midi: nil, bpm: 100) @value = value @name = pitch @pitch = Pitch.find pitch @expression = exp @midi = midi @bpm = bpm end
Public Instance Methods
Play the current note through the UniMIDI
output.
# File lib/mass/note.rb, line 107 def play midi.puts ON, to_midi, to_velocity unless pitch.nil? sleep duration midi.puts OFF, to_midi, to_velocity unless pitch.nil? end
This note as expressed in a MIDI velocity value.
@return [Integer]
# File lib/mass/note.rb, line 96 def to_velocity VELOCITIES[expression] || expression end
Private Instance Methods
# File lib/mass/note.rb, line 115 def vpm bpm / value end