Class: MIDIMessage::Context
- Inherits:
-
Object
- Object
- MIDIMessage::Context
- Defined in:
- lib/midi-message/context.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#velocity ⇒ Object
Returns the value of attribute velocity.
Instance Method Summary collapse
- #channel_aftertouch(value, options = {}) ⇒ Object (also: #ChannelAftertouch, #ChannelPressure, #channel_pressure)
- #control_change(index, value, options = {}) ⇒ Object (also: #ControlChange, #Controller, #controller)
-
#initialize(options = {}) ⇒ Context
constructor
A new instance of Context.
- #note_off(note, options = {}) ⇒ Object (also: #NoteOff)
- #note_on(note, options = {}) ⇒ Object (also: #NoteOn)
- #pitch_bend(low, high, options = {}) ⇒ Object (also: #PitchBend)
- #polyphonic_aftertouch(note, value, options = {}) ⇒ Object (also: #PolyphonicAftertouch, #PolyAftertouch, #PolyphonicPressure, #PolyPressure, #poly_aftertouch, #poly_pressure)
- #program_change(program, options = {}) ⇒ Object (also: #ProgramChange)
Constructor Details
#initialize(options = {}) ⇒ Context
Returns a new instance of Context.
12 13 14 15 |
# File 'lib/midi-message/context.rb', line 12 def initialize( = {}) @channel = [:channel] @velocity = [:velocity] end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
9 10 11 |
# File 'lib/midi-message/context.rb', line 9 def channel @channel end |
#velocity ⇒ Object
Returns the value of attribute velocity.
9 10 11 |
# File 'lib/midi-message/context.rb', line 9 def velocity @velocity end |
Instance Method Details
#channel_aftertouch(value, options = {}) ⇒ Object Also known as: ChannelAftertouch, ChannelPressure, channel_pressure
81 82 83 84 85 |
# File 'lib/midi-message/context.rb', line 81 def channel_aftertouch(value, = {}) channel = [:channel] || @channel raise 'channel_aftertouch requires a channel' if channel.nil? ChannelAftertouch.new(channel, value, ) end |
#control_change(index, value, options = {}) ⇒ Object Also known as: ControlChange, Controller, controller
52 53 54 55 56 57 58 59 60 |
# File 'lib/midi-message/context.rb', line 52 def control_change(index, value, = {}) channel = [:channel] || @channel raise 'control_change requires channel' if channel.nil? if index.kind_of?(String) ControlChange[index].new(channel, value, ) else ControlChange.new(channel, index, value, ) end end |
#note_off(note, options = {}) ⇒ Object Also known as: NoteOff
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/midi-message/context.rb', line 17 def note_off(note, = {}) channel = [:channel] || @channel velocity = [:velocity] || @velocity raise 'note_off requires both channel and velocity' if channel.nil? || velocity.nil? if note.kind_of?(String) NoteOff[note].new(channel, velocity, ) else NoteOff.new(channel, note, velocity, ) end end |
#note_on(note, options = {}) ⇒ Object Also known as: NoteOn
29 30 31 32 33 34 35 36 37 38 |
# File 'lib/midi-message/context.rb', line 29 def note_on(note, = {}) channel = [:channel] || @channel velocity = [:velocity] || @velocity raise 'note_on requires both channel and velocity' if channel.nil? || velocity.nil? if note.kind_of?(String) NoteOn[note].new(channel, velocity, ) else NoteOn.new(channel, note, velocity, ) end end |
#pitch_bend(low, high, options = {}) ⇒ Object Also known as: PitchBend
90 91 92 93 94 |
# File 'lib/midi-message/context.rb', line 90 def pitch_bend(low, high, = {}) channel = [:channel] || @channel raise 'channel_aftertouch requires a channel' if channel.nil? PitchBend.new(channel, low, high, ) end |
#polyphonic_aftertouch(note, value, options = {}) ⇒ Object Also known as: PolyphonicAftertouch, PolyAftertouch, PolyphonicPressure, PolyPressure, poly_aftertouch, poly_pressure
65 66 67 68 69 70 71 72 73 |
# File 'lib/midi-message/context.rb', line 65 def polyphonic_aftertouch(note, value, = {}) channel = [:channel] || @channel raise 'channel_aftertouch requires a channel' if channel.nil? if note.kind_of?(String) PolyphonicAftertouch[note].new(channel, value, ) else PolyphonicAftertouch.new(channel, note, value, ) end end |
#program_change(program, options = {}) ⇒ Object Also known as: ProgramChange
41 42 43 44 45 46 47 48 49 |
# File 'lib/midi-message/context.rb', line 41 def program_change(program, = {}) channel = [:channel] || @channel raise 'program_change requires channel' if channel.nil? if program.kind_of?(String) ProgramChange[program].new(channel, ) else ProgramChange.new(channel, program, ) end end |