Class: MicroMIDI::Instructions::Sticky
- Inherits:
-
Object
- Object
- MicroMIDI::Instructions::Sticky
- Defined in:
- lib/micromidi/instructions/sticky.rb,
lib/micromidi/instructions/shorthand.rb
Overview
Commands that deal with sticky default properties.
For example, setting a default MIDI channel that persists for the messages to follow it:
“‘ruby channel 5 note “C4” note “C3” “`
Instance Method Summary collapse
-
#channel(*args) ⇒ Fixnum
(also: #ch)
Gets/sets the sticky channel for the current block.
-
#initialize(state) ⇒ Sticky
constructor
A new instance of Sticky.
-
#octave(*args) ⇒ Fixnum
Gets/sets the octave for the current block.
-
#super_sticky ⇒ Boolean
(also: #ss)
Toggles super_sticky mode, a mode where any explicit values used to create MIDI messages automatically become sticky.
-
#sysex_node(*args) ⇒ MIDIMessage::SystemExclusive::Node
(also: #node)
Gets/sets the sysex node for the current block.
-
#velocity(*args) ⇒ Fixnum
(also: #v)
Gets/sets the sticky velocity for the current block.
Constructor Details
#initialize(state) ⇒ Sticky
Returns a new instance of Sticky.
18 19 20 |
# File 'lib/micromidi/instructions/sticky.rb', line 18 def initialize(state) @state = state end |
Instance Method Details
#channel(*args) ⇒ Fixnum Also known as: ch
Gets/sets the sticky channel for the current block
25 26 27 28 |
# File 'lib/micromidi/instructions/sticky.rb', line 25 def channel(*args) @state.channel = args.first unless args.empty? @state.channel end |
#octave(*args) ⇒ Fixnum
Gets/sets the octave for the current block
33 34 35 36 |
# File 'lib/micromidi/instructions/sticky.rb', line 33 def octave(*args) @state.octave = args.first unless args.empty? @state.octave end |
#super_sticky ⇒ Boolean Also known as: ss
Toggles super_sticky mode, a mode where any explicit values used to create MIDI messages automatically become sticky. Normally the explicit value would only be used for the current message.
For example, while in super sticky mode
“‘ruby note “C4”, :channel => 5 note “C3” “`
will have the same results as
“‘ruby channel 5 note “C4” note “C3” “`
78 79 80 |
# File 'lib/micromidi/instructions/sticky.rb', line 78 def super_sticky @state.toggle_super_sticky end |
#sysex_node(*args) ⇒ MIDIMessage::SystemExclusive::Node Also known as: node
Gets/sets the sysex node for the current block
41 42 43 44 45 46 |
# File 'lib/micromidi/instructions/sticky.rb', line 41 def sysex_node(*args) args = args.dup = args.last.kind_of?(Hash) ? args.last : {} @state.sysex_node = MIDIMessage::SystemExclusive::Node.new(args.first, ) unless args.empty? @state.sysex_node end |
#velocity(*args) ⇒ Fixnum Also known as: v
Gets/sets the sticky velocity for the current block
52 53 54 55 |
# File 'lib/micromidi/instructions/sticky.rb', line 52 def velocity(*args) @state.velocity = args.first unless args.empty? @state.velocity end |