Class: MicroMIDI::Instructions::Sticky

Inherits:
Object
  • Object
show all
Defined in:
lib/micromidi/instructions/sticky.rb,
lib/micromidi/instructions/shorthand.rb

Instance Method Summary collapse

Constructor Details

#initialize(state) ⇒ Sticky

Returns a new instance of Sticky.



9
10
11
# File 'lib/micromidi/instructions/sticky.rb', line 9

def initialize(state)
  @state = state
end

Instance Method Details

#channel(val = nil) ⇒ Object Also known as: ch

sets the sticky channel for the current block



14
15
16
# File 'lib/micromidi/instructions/sticky.rb', line 14

def channel(val = nil)
  val.nil? ? @state.channel : @state.channel = val
end

#octave(val = nil) ⇒ Object

sets the octave for the current block



19
20
21
# File 'lib/micromidi/instructions/sticky.rb', line 19

def octave(val = nil)
  val.nil? ? @state.octave : @state.octave = val
end

#super_stickyObject Also known as: ss

toggles super_sticky mode, a mode where any explicit values used to create MIDI messages automatically become sticky – whereas normally the explicit value would only be used for the current message.

e.g.

note “C4”, :channel => 5

will have the exact same effect as

channel 5 note “C4”

while in super sticky mode



51
52
53
# File 'lib/micromidi/instructions/sticky.rb', line 51

def super_sticky
  @state.toggle_super_sticky
end

#sysex_node(*args) ⇒ Object Also known as: node

sets the sysex node for the current block



24
25
26
27
# File 'lib/micromidi/instructions/sticky.rb', line 24

def sysex_node(*args)
  options = args.last.kind_of?(Hash) ? args.last : {}
  args.empty? ? @state.sysex_node : @state.sysex_node = MIDIMessage::SystemExclusive::Node.new(args.first, options)
end

#velocity(val = nil) ⇒ Object Also known as: v

sets the sticky velocity for the current block



31
32
33
# File 'lib/micromidi/instructions/sticky.rb', line 31

def velocity(val = nil)
  val.nil? ? @state.velocity : @state.velocity = val
end