Class: MIDI::MMC
- Inherits:
-
Object
- Object
- MIDI::MMC
- Defined in:
- lib/midi-mmc.rb
Constant Summary collapse
- DEVICE_ID_ALL =
0x7F
- TYPES =
{ command: 0x06, response: 0x07, }
- COMMANDS =
{ stop: 0x01, play: 0x02, deferred_play: 0x03, fast_forward: 0x04, rewind: 0x05, record_strobe: 0x06, record_exit: 0x07, record_pause: 0x08, pause: 0x09, eject: 0x0A, chase: 0x0B, reset: 0x0D, write: 0x40, locate: 0x44, shuttle: 0x47, }
- WRITE_MODES =
{ record_ready: 0x4F, sync_monitor: 0x52, input_monitor: 0x53, mute: 0x62, }
Instance Attribute Summary collapse
-
#device_id ⇒ Object
Returns the value of attribute device_id.
-
#output ⇒ Object
Returns the value of attribute output.
Instance Method Summary collapse
- #arm_tracks(tracks) ⇒ Object (also: #record_ready)
- #chase ⇒ Object
- #deferred_play ⇒ Object
- #eject ⇒ Object
- #fast_forward ⇒ Object
-
#initialize(output: nil, device_id: nil, debug: nil) ⇒ MMC
constructor
A new instance of MMC.
- #locate(location) ⇒ Object (also: #goto)
- #locate_zero ⇒ Object (also: #goto_zero)
- #message_to_str(msg) ⇒ Object
- #pause ⇒ Object
- #play ⇒ Object
- #record_exit ⇒ Object (also: #punch_out)
- #record_pause ⇒ Object
- #record_strobe ⇒ Object (also: #punch_in)
- #reset ⇒ Object
- #rewind ⇒ Object
- #shuffle ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(output: nil, device_id: nil, debug: nil) ⇒ MMC
Returns a new instance of MMC.
40 41 42 43 44 |
# File 'lib/midi-mmc.rb', line 40 def initialize(output: nil, device_id: nil, debug: nil) @output = output @device_id = device_id || DEVICE_ID_ALL @debug = debug end |
Instance Attribute Details
#device_id ⇒ Object
Returns the value of attribute device_id.
6 7 8 |
# File 'lib/midi-mmc.rb', line 6 def device_id @device_id end |
#output ⇒ Object
Returns the value of attribute output.
5 6 7 |
# File 'lib/midi-mmc.rb', line 5 def output @output end |
Instance Method Details
#arm_tracks(tracks) ⇒ Object Also known as: record_ready
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/midi-mmc.rb', line 96 def arm_tracks(tracks) tracks = case tracks when nil [] when Numeric [tracks] when Range tracks.to_a when Array tracks else raise end bytes = track_bitmap_bytes(tracks) track_bitmap = [bytes.length, *bytes] mode_id = WRITE_MODES[:record_ready] or raise (:write, track_bitmap.length, mode_id, *track_bitmap) end |
#chase ⇒ Object
88 89 90 |
# File 'lib/midi-mmc.rb', line 88 def chase (:chase) end |
#deferred_play ⇒ Object
54 55 56 |
# File 'lib/midi-mmc.rb', line 54 def deferred_play (:deferred_play) end |
#eject ⇒ Object
84 85 86 |
# File 'lib/midi-mmc.rb', line 84 def eject (:eject) end |
#fast_forward ⇒ Object
58 59 60 |
# File 'lib/midi-mmc.rb', line 58 def fast_forward (:fast_forward) end |
#locate(location) ⇒ Object Also known as: goto
116 117 118 |
# File 'lib/midi-mmc.rb', line 116 def locate(location) (:locate, 0x06, 0x01, *location, wait: 1) end |
#locate_zero ⇒ Object Also known as: goto_zero
121 122 123 |
# File 'lib/midi-mmc.rb', line 121 def locate_zero locate([0, 0, 0, 0, 0]) end |
#message_to_str(msg) ⇒ Object
130 131 132 |
# File 'lib/midi-mmc.rb', line 130 def (msg) msg.map { |b| '%02X' % b }.join(' ') end |
#pause ⇒ Object
80 81 82 |
# File 'lib/midi-mmc.rb', line 80 def pause (:pause) end |
#play ⇒ Object
50 51 52 |
# File 'lib/midi-mmc.rb', line 50 def play (:play) end |
#record_exit ⇒ Object Also known as: punch_out
71 72 73 |
# File 'lib/midi-mmc.rb', line 71 def record_exit (:record_exit) end |
#record_pause ⇒ Object
76 77 78 |
# File 'lib/midi-mmc.rb', line 76 def record_pause (:record_pause) end |
#record_strobe ⇒ Object Also known as: punch_in
66 67 68 |
# File 'lib/midi-mmc.rb', line 66 def record_strobe (:record_strobe) end |
#reset ⇒ Object
92 93 94 |
# File 'lib/midi-mmc.rb', line 92 def reset (:reset) end |
#rewind ⇒ Object
62 63 64 |
# File 'lib/midi-mmc.rb', line 62 def rewind (:rewind) end |
#shuffle ⇒ Object
126 127 128 |
# File 'lib/midi-mmc.rb', line 126 def shuffle (:shuffle) end |
#stop ⇒ Object
46 47 48 |
# File 'lib/midi-mmc.rb', line 46 def stop (:stop) end |