Class: Webmidi::Message::Channel::NoteOff

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: 0, channel: 0, timestamp: nil) ⇒ NoteOff

Returns a new instance of NoteOff.



49
50
51
52
53
54
55
56
57
# File 'lib/webmidi/message/channel.rb', line 49

def initialize(note:, velocity: 0, 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.



47
48
49
# File 'lib/webmidi/message/channel.rb', line 47

def note
  @note
end

#velocityObject (readonly)

Returns the value of attribute velocity.



47
48
49
# File 'lib/webmidi/message/channel.rb', line 47

def velocity
  @velocity
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



63
64
65
# File 'lib/webmidi/message/channel.rb', line 63

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

#to_bytesObject



59
60
61
# File 'lib/webmidi/message/channel.rb', line 59

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