Module: MMPlayer::Instructions::MIDI

Included in:
Context
Defined in:
lib/mmplayer/instructions/midi.rb

Overview

Instructions for dealing with MIDI

Instance Method Summary collapse

Instance Method Details

#on_cc(index = nil, &callback) ⇒ Hash Also known as: cc

Assign a callback for the given MIDI control change

Parameters:

  • index (Fixnum) (defaults to: nil)

    The MIDI control change index to assign the callback for or nil for all

  • callback (Proc)

    The callback to execute when a matching message is received

Returns:

  • (Hash)


37
38
39
# File 'lib/mmplayer/instructions/midi.rb', line 37

def on_cc(index = nil, &callback)
  @midi.add_cc_callback(index, &callback)
end

#on_note(note = nil, &callback) ⇒ Hash Also known as: note

Assign a callback for a given MIDI note

Parameters:

  • note (Fixnum, String) (defaults to: nil)

    A MIDI note eg 64 “F4” or nil for all

  • callback (Proc)

    The callback to execute when a matching message is received

Returns:

  • (Hash)


28
29
30
# File 'lib/mmplayer/instructions/midi.rb', line 28

def on_note(note = nil, &callback)
  @midi.add_note_callback(note, &callback)
end

#on_system(command, &callback) ⇒ Hash Also known as: system

Assign a callback for a given MIDI system command

Parameters:

  • note (String, Symbol)

    A MIDI system command eg :start, :continue, :stop

  • callback (Proc)

    The callback to execute when a matching message is received

Returns:

  • (Hash)


19
20
21
# File 'lib/mmplayer/instructions/midi.rb', line 19

def on_system(command, &callback)
  @midi.add_system_callback(command, &callback)
end

#receive_channel(num) ⇒ Object Also known as: rx_channel

Set the MIDI channel to receive messages on

Parameters:

  • num (Fixnum, nil)

    The channel number 0-15 or nil for all



10
11
12
# File 'lib/mmplayer/instructions/midi.rb', line 10

def receive_channel(num)
  @midi.channel = num
end