Class: Webmidi::Message::UMP::ChannelVoice64

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

Instance Attribute Summary collapse

Attributes inherited from Base

#group, #message_type

Attributes inherited from Base

#timestamp

Instance Method Summary collapse

Methods inherited from Base

#with

Methods inherited from Base

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

Constructor Details

#initialize(status:, channel: 0, note: 0, velocity: 0, attribute_type: 0, attribute: 0, group: 0, timestamp: nil) ⇒ ChannelVoice64

Returns a new instance of ChannelVoice64.



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/webmidi/message/ump.rb', line 371

def initialize(status:, channel: 0, note: 0, velocity: 0, attribute_type: 0, attribute: 0, group: 0,
  timestamp: nil)
  validate_status!(status)
  validate_range!(channel, "Channel", 0, 15)
  validate_range!(note, "Note/controller", 0, 127)
  validate_range!(attribute_type, "Attribute type", 0, 255)
  validate_range!(attribute, "Attribute", 0, 0xFFFF)
  validate_velocity!(status, velocity)

  @status = status
  @channel = channel
  @note = note
  @velocity = velocity
  @attribute_type = attribute_type
  @attribute = attribute
  super(message_type: :channel_voice_64, group: group, timestamp: timestamp)
end

Instance Attribute Details

#attributeObject (readonly)

Returns the value of attribute attribute.



369
370
371
# File 'lib/webmidi/message/ump.rb', line 369

def attribute
  @attribute
end

#attribute_typeObject (readonly)

Returns the value of attribute attribute_type.



369
370
371
# File 'lib/webmidi/message/ump.rb', line 369

def attribute_type
  @attribute_type
end

#channelObject (readonly)

Returns the value of attribute channel.



369
370
371
# File 'lib/webmidi/message/ump.rb', line 369

def channel
  @channel
end

#noteObject (readonly)

Returns the value of attribute note.



369
370
371
# File 'lib/webmidi/message/ump.rb', line 369

def note
  @note
end

#statusObject (readonly)

Returns the value of attribute status.



369
370
371
# File 'lib/webmidi/message/ump.rb', line 369

def status
  @status
end

#velocityObject (readonly)

Returns the value of attribute velocity.



369
370
371
# File 'lib/webmidi/message/ump.rb', line 369

def velocity
  @velocity
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



402
403
404
405
406
407
# File 'lib/webmidi/message/ump.rb', line 402

def deconstruct_keys(keys)
  super.merge(
    status: @status, channel: @channel, note: @note, velocity: @velocity,
    attribute_type: @attribute_type, attribute: @attribute
  )
end

#to_bytesObject



389
390
391
392
393
394
395
396
397
398
399
400
# File 'lib/webmidi/message/ump.rb', line 389

def to_bytes
  word1 = (MESSAGE_TYPES[:channel_voice_64] << 28) |
    (@group << 24) |
    (status_nibble << 20) |
    (@channel << 16) |
    (@note << 8) |
    data2
  word2 = word2_value

  [(word1 >> 24) & 0xFF, (word1 >> 16) & 0xFF, (word1 >> 8) & 0xFF, word1 & 0xFF,
    (word2 >> 24) & 0xFF, (word2 >> 16) & 0xFF, (word2 >> 8) & 0xFF, word2 & 0xFF]
end