Class: Mpd32Api::Library
- Inherits:
-
Object
- Object
- Mpd32Api::Library
- Defined in:
- lib/mpd32api.rb
Instance Method Summary collapse
-
#initialize(input_device, output_device) ⇒ Library
constructor
A new instance of Library.
- #note_repeat(x) ⇒ Object
- #send_msg(message) ⇒ Object
- #showcase ⇒ Object
- #start_read_input ⇒ Object
- #switch_to_control_bank(x) ⇒ Object
- #switch_to_pad_bank(x) ⇒ Object
- #time_division(x) ⇒ Object
Constructor Details
#initialize(input_device, output_device) ⇒ Library
Returns a new instance of Library.
15 16 17 18 19 20 21 22 |
# File 'lib/mpd32api.rb', line 15 def initialize(input_device, output_device) input_device.instance_of?(UniMIDI::CoreMIDIAdapter::Input) ? @input = input_device : @input = UniMIDI::Input.use(input_device) output_device.instance_of?(UniMIDI::CoreMIDIAdapter::Output) ? @output = output_device : @output = UniMIDI::Output.use(output_device) end |
Instance Method Details
#note_repeat(x) ⇒ Object
46 47 48 |
# File 'lib/mpd32api.rb', line 46 def note_repeat(x) self.send_msg Mpd32Api::MIDI_MAPPING[:note_repeat][x] end |
#send_msg(message) ⇒ Object
32 33 34 35 36 |
# File 'lib/mpd32api.rb', line 32 def send_msg() @output.open { |output| output.puts() } end |
#showcase ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/mpd32api.rb', line 54 def showcase Mpd32Api::MIDI_MAPPING.each do |kx,vx| vx.each do |ky,vy| self.send_msg vy sleep 1 end end end |
#start_read_input ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/mpd32api.rb', line 24 def start_read_input @input.open loop { = @input.gets p } end |
#switch_to_control_bank(x) ⇒ Object
38 39 40 |
# File 'lib/mpd32api.rb', line 38 def switch_to_control_bank(x) self.send_msg Mpd32Api::MIDI_MAPPING[:control_bank][x] end |
#switch_to_pad_bank(x) ⇒ Object
42 43 44 |
# File 'lib/mpd32api.rb', line 42 def switch_to_pad_bank(x) self.send_msg Mpd32Api::MIDI_MAPPING[:pad_bank][x] end |
#time_division(x) ⇒ Object
50 51 52 |
# File 'lib/mpd32api.rb', line 50 def time_division(x) self.send_msg Mpd32Api::MIDI_MAPPING[:time_division][x] end |