Class: MicroMIDI::Instructions::Message
- Inherits:
-
Object
- Object
- MicroMIDI::Instructions::Message
- Defined in:
- lib/micromidi/instructions/message.rb,
lib/micromidi/instructions/shorthand.rb
Overview
Commands that deal with MIDI messages
Instance Method Summary collapse
-
#channel_aftertouch(value, options = {}) ⇒ MIDIMessage::ChannelAftertouch
(also: #channel_pressure, #ca)
Create a MIDI channel pressure message.
-
#control_change(id, value, options = {}) ⇒ MIDIMessage::ControlChange
(also: #c, #cc)
Create a MIDI control change message.
-
#initialize(state) ⇒ Message
constructor
A new instance of Message.
-
#note(id, options = {}) ⇒ MIDIMessage::NoteOn
(also: #n)
Create a MIDI note on message.
-
#note_off(id, options = {}) ⇒ MIDIMessage::NoteOff
(also: #no)
Create a MIDI note off message.
-
#off ⇒ MIDIMessage::NoteOff
(also: #o)
Create a MIDI note-off message from the last note-on message.
-
#parse(message) ⇒ MIDIMessage
Create a MIDI message from raw bytes.
-
#pitch_bend(low, high, options = {}) ⇒ MIDIMessage::PitchBend
(also: #bend, #pitchbend, #pb)
Create a MIDI pitch bend message.
-
#polyphonic_aftertouch(note, value, options = {}) ⇒ MIDIMessage::PolyphonicAftertouch
(also: #poly_aftertouch, #polyphonic_pressure, #poly_pressure, #pa)
Create a MIDI poly pressure message.
-
#program_change(program, options = {}) ⇒ MIDIMessage::ProgramChange
(also: #pc)
Create a MIDI program change message.
Constructor Details
#initialize(state) ⇒ Message
Returns a new instance of Message.
9 10 11 |
# File 'lib/micromidi/instructions/message.rb', line 9 def initialize(state) @state = state end |
Instance Method Details
#channel_aftertouch(value, options = {}) ⇒ MIDIMessage::ChannelAftertouch Also known as: channel_pressure, ca
Create a MIDI channel pressure message
82 83 84 85 |
# File 'lib/micromidi/instructions/message.rb', line 82 def channel_aftertouch(value, = {}) properties = @state.(, :channel) MIDIMessage::ChannelAftertouch.new(properties[:channel], value) end |
#control_change(id, value, options = {}) ⇒ MIDIMessage::ControlChange Also known as: c, cc
Create a MIDI control change message
19 20 21 22 23 24 25 26 |
# File 'lib/micromidi/instructions/message.rb', line 19 def control_change(id, value, = {}) properties = @state.(, :channel) if id.kind_of?(Fixnum) MIDIMessage::ControlChange.new(properties[:channel], id, value) else MIDIMessage::ControlChange[id].new(properties[:channel], value) end end |
#note(id, options = {}) ⇒ MIDIMessage::NoteOn Also known as: n
Create a MIDI note on message
34 35 36 37 38 39 |
# File 'lib/micromidi/instructions/message.rb', line 34 def note(id, = {}) properties = @state.(, :channel, :velocity) note = (MIDIMessage::NoteOn, id, properties) @state.last_note = note note end |
#note_off(id, options = {}) ⇒ MIDIMessage::NoteOff Also known as: no
Create a MIDI note off message
47 48 49 50 |
# File 'lib/micromidi/instructions/message.rb', line 47 def note_off(id, = {}) properties = @state.(, :channel, :velocity) (MIDIMessage::NoteOff, id, properties) end |
#off ⇒ MIDIMessage::NoteOff Also known as: o
Create a MIDI note-off message from the last note-on message
71 72 73 74 75 |
# File 'lib/micromidi/instructions/message.rb', line 71 def off note_off = @state.last_note.to_note_off unless @state.last_note.nil? @state.last_note = nil note_off end |
#parse(message) ⇒ MIDIMessage
Create a MIDI message from raw bytes
55 56 57 |
# File 'lib/micromidi/instructions/message.rb', line 55 def parse() MIDIMessage.parse() end |
#pitch_bend(low, high, options = {}) ⇒ MIDIMessage::PitchBend Also known as: bend, pitchbend, pb
Create a MIDI pitch bend message
108 109 110 111 |
# File 'lib/micromidi/instructions/message.rb', line 108 def pitch_bend(low, high, = {}) properties = @state.(, :channel) MIDIMessage::PitchBend.new(properties[:channel], low, high) end |
#polyphonic_aftertouch(note, value, options = {}) ⇒ MIDIMessage::PolyphonicAftertouch Also known as: poly_aftertouch, polyphonic_pressure, poly_pressure, pa
Create a MIDI poly pressure message
94 95 96 97 |
# File 'lib/micromidi/instructions/message.rb', line 94 def polyphonic_aftertouch(note, value, = {}) properties = @state.(, :channel) MIDIMessage::PolyphonicAftertouch.new(properties[:channel], note, value) end |
#program_change(program, options = {}) ⇒ MIDIMessage::ProgramChange Also known as: pc
Create a MIDI program change message
64 65 66 67 |
# File 'lib/micromidi/instructions/message.rb', line 64 def program_change(program, = {}) properties = @state.(, :channel) MIDIMessage::ProgramChange.new(properties[:channel], program) end |