Class: Webmidi::Message::Channel::ProgramChange

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

Returns a new instance of ProgramChange.



159
160
161
162
163
164
165
# File 'lib/webmidi/message/channel.rb', line 159

def initialize(program:, channel: 0, timestamp: nil)
  validate_channel!(channel)
  validate_byte!(program, "Program")
  @program = program
  @channel = channel
  super(timestamp: timestamp)
end

Instance Attribute Details

#programObject (readonly)

Returns the value of attribute program.



157
158
159
# File 'lib/webmidi/message/channel.rb', line 157

def program
  @program
end

Instance Method Details

#deconstruct_keys(keys) ⇒ Object



171
172
173
# File 'lib/webmidi/message/channel.rb', line 171

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

#to_bytesObject



167
168
169
# File 'lib/webmidi/message/channel.rb', line 167

def to_bytes
  [0xC0 | @channel, @program]
end