Class: MicroMIDI::Instructions::Sticky

Inherits:
Object
  • Object
show all
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

Constructor Details

#initialize(state) ⇒ Sticky

Returns a new instance of Sticky.

Parameters:


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

Parameters:

  • args (*Fixnum)

    args is an optional parameter to set the channel: [Fixnum, nil]

Returns:

  • (Fixnum)

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

Parameters:

  • args (*Fixnum)

    args is an optional parameter to set the octave: [Fixnum, nil]

Returns:

  • (Fixnum)

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_stickyBoolean 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” “`

Returns:

  • (Boolean)

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

Parameters:

  • args (*Object)

Returns:

  • (MIDIMessage::SystemExclusive::Node)

41
42
43
44
45
46
# File 'lib/micromidi/instructions/sticky.rb', line 41

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

#velocity(*args) ⇒ Fixnum Also known as: v

Gets/sets the sticky velocity for the current block

Parameters:

  • args (*Fixnum)

    args is an optional parameter to set the velocity: [Fixnum, nil]

Returns:

  • (Fixnum)

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