Class: MIDIInstrument::NoteEvent

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/midi-instrument/note_event.rb

Overview

An NoteEvent is a pairing of a MIDI NoteOn and NoteOff message. Its duration can correspond to sequencer ticks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(start_message, duration, options = {}) ⇒ NoteEvent

Returns a new instance of NoteEvent.

Parameters:

  • start_message (MIDIMessage::NoteOn)
  • duration (Fixnum)
  • options (Hash) (defaults to: {})

Options Hash (options):

  • :finish (MIDIMessage::NoteOff)


20
21
22
23
24
25
# File 'lib/midi-instrument/note_event.rb', line 20

def initialize(start_message, duration, options = {})
  @start = start_message
  @length = duration

  @finish = options[:finish] || start_message.to_note_off
end

Instance Attribute Details

#finishObject (readonly)

Returns the value of attribute finish.



8
9
10
# File 'lib/midi-instrument/note_event.rb', line 8

def finish
  @finish
end

#lengthObject (readonly) Also known as: duration

Returns the value of attribute length.



8
9
10
# File 'lib/midi-instrument/note_event.rb', line 8

def length
  @length
end

#startObject (readonly)

Returns the value of attribute start.



8
9
10
# File 'lib/midi-instrument/note_event.rb', line 8

def start
  @start
end