Class: MicroMIDI::Instructions::Message
- Inherits:
-
Object
- Object
- MicroMIDI::Instructions::Message
- Includes:
- MIDIMessage
- Defined in:
- lib/micromidi/instructions/message.rb,
lib/micromidi/instructions/shorthand.rb
Instance Method Summary collapse
-
#channel_aftertouch(value, opts = {}) ⇒ Object
(also: #channel_pressure, #ca)
create a channel pressure message.
-
#control_change(id, value, opts = {}) ⇒ Object
(also: #c, #cc)
create a control change message.
-
#initialize(state) ⇒ Message
constructor
A new instance of Message.
-
#note(id, opts = {}) ⇒ Object
(also: #n)
create a note message.
-
#note_off(id, opts = {}) ⇒ Object
(also: #no)
create a note off message.
-
#off ⇒ Object
(also: #o)
create a note-off message from the last note-on message.
-
#parse(message) ⇒ Object
create a MIDI message from a byte string, array of bytes, or list of bytes.
- #pitch_bend(low, high, opts = {}) ⇒ Object (also: #bend, #pitchbend, #pb)
-
#polyphonic_aftertouch(note, value, opts = {}) ⇒ Object
(also: #poly_aftertouch, #polyphonic_pressure, #poly_pressure, #pa)
create a poly pressure message.
-
#program_change(program, opts = {}) ⇒ Object
(also: #pc)
create a program change message.
Constructor Details
#initialize(state) ⇒ Message
Returns a new instance of Message.
11 12 13 |
# File 'lib/micromidi/instructions/message.rb', line 11 def initialize(state) @state = state end |
Instance Method Details
#channel_aftertouch(value, opts = {}) ⇒ Object Also known as: channel_pressure, ca
create a channel pressure message
64 65 66 67 |
# File 'lib/micromidi/instructions/message.rb', line 64 def channel_aftertouch(value, opts = {}) props = @state.(opts, :channel) MIDIMessage::ChannelAftertouch.new(props[:channel], value) end |
#control_change(id, value, opts = {}) ⇒ Object Also known as: c, cc
create a control change message
16 17 18 19 |
# File 'lib/micromidi/instructions/message.rb', line 16 def control_change(id, value, opts = {}) props = @state.(opts, :channel) id.kind_of?(Numeric) ? ControlChange.new(props[:channel], id, value) : ControlChange[id].new(props[:channel], value) end |
#note(id, opts = {}) ⇒ Object Also known as: n
create a note message
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/micromidi/instructions/message.rb', line 22 def note(id, opts = {}) props = @state.(opts, :channel, :velocity) note = if id.kind_of?(Numeric) NoteOn.new(props[:channel], id, props[:velocity]) elsif id.kind_of?(String) || id.kind_of?(Symbol) note_string = parse_note_name(id) NoteOn[note_string].new(props[:channel], props[:velocity]) end @state.last_note = note note end |
#note_off(id, opts = {}) ⇒ Object Also known as: no
create a note off message
35 36 37 38 39 40 41 42 43 |
# File 'lib/micromidi/instructions/message.rb', line 35 def note_off(id, opts = {}) props = @state.(opts, :channel, :velocity) if id.kind_of?(Numeric) NoteOff.new(props[:channel], id, props[:velocity]) elsif id.kind_of?(String) || id.kind_of?(Symbol) note_string = parse_note_name(id) NoteOff[parse_note_name(id)].new(props[:channel], props[:velocity]) end end |
#off ⇒ Object Also known as: o
create a note-off message from the last note-on message
57 58 59 60 61 |
# File 'lib/micromidi/instructions/message.rb', line 57 def off o = @state.last_note.to_note_off unless @state.last_note.nil? @state.last_note = nil o end |
#parse(message) ⇒ Object
create a MIDI message from a byte string, array of bytes, or list of bytes
46 47 48 |
# File 'lib/micromidi/instructions/message.rb', line 46 def parse() MIDIMessage.parse() end |
#pitch_bend(low, high, opts = {}) ⇒ Object Also known as: bend, pitchbend, pb
79 80 81 82 |
# File 'lib/micromidi/instructions/message.rb', line 79 def pitch_bend(low, high, opts = {}) props = @state.(opts, :channel) MIDIMessage::PitchBend.new(props[:channel], low, high) end |
#polyphonic_aftertouch(note, value, opts = {}) ⇒ Object Also known as: poly_aftertouch, polyphonic_pressure, poly_pressure, pa
create a poly pressure message
71 72 73 74 |
# File 'lib/micromidi/instructions/message.rb', line 71 def polyphonic_aftertouch(note, value, opts = {}) props = @state.(opts, :channel) MIDIMessage::PolyphonicAftertouch.new(props[:channel], note, value) end |
#program_change(program, opts = {}) ⇒ Object Also known as: pc
create a program change message
51 52 53 54 |
# File 'lib/micromidi/instructions/message.rb', line 51 def program_change(program, opts = {}) props = @state.(opts, :channel) MIDIMessage::ProgramChange.new(props[:channel], program) end |