Module: Patch::IO::MIDI::Action

Extended by:
Action
Included in:
Action
Defined in:
lib/patch/io/midi/action.rb

Overview

Find and identify MIDI Actions

Instance Method Summary collapse

Instance Method Details

#find_by_index(actions, index) ⇒ Hash

Find an action in the given patch for the given cc index

Parameters:

  • actions (Array<Hash>)
  • index (Fixnum)

Returns:

  • (Hash)


30
31
32
33
34
# File 'lib/patch/io/midi/action.rb', line 30

def find_by_index(actions, index)
  midi_actions(actions).find do |action|
    action[:midi][:index] == index
  end
end

#midi?(action) ⇒ Boolean

Is the given action MIDI?

Parameters:

  • action (Hash)

Returns:

  • (Boolean)


15
16
17
# File 'lib/patch/io/midi/action.rb', line 15

def midi?(action)
  !action[:midi].nil? && !action[:midi][:index].nil?
end

#midi_actions(actions) ⇒ Array<Hash>

Filter the given actions only to return MIDI actions

Parameters:

  • actions (Array<Hash>)

Returns:

  • (Array<Hash>)


22
23
24
# File 'lib/patch/io/midi/action.rb', line 22

def midi_actions(actions)
  actions.select { |action| midi?(action) }
end