Class: Webmidi::Message::Channel::NoteOn

Inherits:
Base
  • Object
show all
Defined in:
lib/webmidi/message/channel.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#channel

Attributes inherited from Base

#timestamp

Instance Method Summary collapse

Methods inherited from Base

#==, #channel, #deconstruct, #eql?, #hash, #same_bytes?, #same_event?, #to_binary, #to_hex, #with

Constructor Details

#initialize(note:, velocity: 100, channel: 0, timestamp: nil) ⇒ NoteOn

Returns a new instance of NoteOn.



27
28
29
30
31
32
33
34
35
# File 'lib/webmidi/message/channel.rb', line 27

def initialize(note:, velocity: 100, channel: 0, timestamp: nil)
  validate_channel!(channel)
  validate_byte!(note, "Note")
  validate_byte!(velocity, "Velocity")
  @note = note
  @velocity = velocity
  @channel = channel
  super(timestamp: timestamp)
end

Instance Attribute Details

#noteObject (readonly)

Returns the value of attribute note.



25
26
27
# File 'lib/webmidi/message/channel.rb', line 25

def note
  @note
end

#velocityObject (readonly)

Returns the value of attribute velocity.



25
26
27
# File 'lib/webmidi/message/channel.rb', line 25

def velocity
  @velocity
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



41
42
43
# File 'lib/webmidi/message/channel.rb', line 41

def deconstruct_keys(keys)
  {note: @note, velocity: @velocity, channel: @channel}
end

#to_bytesObject



37
38
39
# File 'lib/webmidi/message/channel.rb', line 37

def to_bytes
  [0x90 | @channel, @note, @velocity]
end