Class: MMPlayer::MIDI::Wrapper
- Inherits:
-
Object
- Object
- MMPlayer::MIDI::Wrapper
- Defined in:
- lib/mmplayer/midi/wrapper.rb
Overview
Wrapper for MIDI functionality
Instance Attribute Summary collapse
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#listener ⇒ Object
readonly
Returns the value of attribute listener.
-
#message_handler ⇒ Object
readonly
Returns the value of attribute message_handler.
Instance Method Summary collapse
-
#add_cc_callback(index, &callback) ⇒ Hash
Add a callback for a given MIDI control change.
-
#add_note_callback(note, &callback) ⇒ Hash
Add a callback for a given MIDI note.
-
#add_system_callback(command, &callback) ⇒ Hash
Add a callback for a given MIDI system message.
-
#initialize(input, options = {}) ⇒ Wrapper
constructor
A new instance of Wrapper.
-
#omni? ⇒ Boolean
Whether the player is subscribed to all channels.
-
#start ⇒ Boolean
Start the MIDI listener.
-
#stop ⇒ Boolean
Stop the MIDI listener.
Constructor Details
#initialize(input, options = {}) ⇒ Wrapper
Returns a new instance of Wrapper.
14 15 16 17 18 19 20 |
# File 'lib/mmplayer/midi/wrapper.rb', line 14 def initialize(input, = {}) @buffer_length = [:buffer_length] @channel = [:receive_channel] = MessageHandler.new @listener = MIDIEye::Listener.new(input) end |
Instance Attribute Details
#channel ⇒ Object
Returns the value of attribute channel.
8 9 10 |
# File 'lib/mmplayer/midi/wrapper.rb', line 8 def channel @channel end |
#listener ⇒ Object (readonly)
Returns the value of attribute listener.
8 9 10 |
# File 'lib/mmplayer/midi/wrapper.rb', line 8 def listener @listener end |
#message_handler ⇒ Object (readonly)
Returns the value of attribute message_handler.
8 9 10 |
# File 'lib/mmplayer/midi/wrapper.rb', line 8 def end |
Instance Method Details
#add_cc_callback(index, &callback) ⇒ Hash
Add a callback for a given MIDI control change
42 43 44 |
# File 'lib/mmplayer/midi/wrapper.rb', line 42 def add_cc_callback(index, &callback) .add_callback(:cc, index, &callback) end |
#add_note_callback(note, &callback) ⇒ Hash
Add a callback for a given MIDI note
34 35 36 |
# File 'lib/mmplayer/midi/wrapper.rb', line 34 def add_note_callback(note, &callback) .add_note_callback(note, &callback) end |
#add_system_callback(command, &callback) ⇒ Hash
Add a callback for a given MIDI system message
26 27 28 |
# File 'lib/mmplayer/midi/wrapper.rb', line 26 def add_system_callback(command, &callback) .add_callback(:system, command, &callback) end |
#omni? ⇒ Boolean
Whether the player is subscribed to all channels
73 74 75 |
# File 'lib/mmplayer/midi/wrapper.rb', line 73 def omni? @channel.nil? end |
#start ⇒ Boolean
Start the MIDI listener
64 65 66 67 68 69 |
# File 'lib/mmplayer/midi/wrapper.rb', line 64 def start initialize_listener @start_time = Time.now.to_i @listener.start(:background => true) true end |
#stop ⇒ Boolean
Stop the MIDI listener
48 49 50 |
# File 'lib/mmplayer/midi/wrapper.rb', line 48 def stop @listener.stop end |