Class: Webmidi::Message::Channel::NoteOn
- Defined in:
- lib/webmidi/message/channel.rb
Instance Attribute Summary collapse
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#velocity ⇒ Object
readonly
Returns the value of attribute velocity.
Attributes inherited from Base
Attributes inherited from Base
Instance Method Summary collapse
- #deconstruct_keys(keys) ⇒ Object
-
#initialize(note:, velocity: 100, channel: 0, timestamp: nil) ⇒ NoteOn
constructor
A new instance of NoteOn.
- #to_bytes ⇒ Object
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: ) end |
Instance Attribute Details
#note ⇒ Object (readonly)
Returns the value of attribute note.
25 26 27 |
# File 'lib/webmidi/message/channel.rb', line 25 def note @note end |
#velocity ⇒ Object (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_bytes ⇒ Object
37 38 39 |
# File 'lib/webmidi/message/channel.rb', line 37 def to_bytes [0x90 | @channel, @note, @velocity] end |