Class: Deftones::Music::Midi::OutputSession
- Inherits:
-
Object
- Object
- Deftones::Music::Midi::OutputSession
- Defined in:
- lib/deftones/music/midi.rb
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #closed? ⇒ Boolean
-
#initialize(output) ⇒ OutputSession
constructor
A new instance of OutputSession.
- #note_off(note, velocity: 0, channel: 1) ⇒ Object
- #note_on(note, velocity: 100, channel: 1) ⇒ Object
- #send(message) ⇒ Object
Constructor Details
#initialize(output) ⇒ OutputSession
Returns a new instance of OutputSession.
289 290 291 292 |
# File 'lib/deftones/music/midi.rb', line 289 def initialize(output) @output = output @closed = false end |
Class Method Details
.parent_status_byte(base, channel) ⇒ Object
323 324 325 |
# File 'lib/deftones/music/midi.rb', line 323 def self.parent_status_byte(base, channel) Midi.send(:status_byte, base, channel) end |
Instance Method Details
#close ⇒ Object
311 312 313 314 315 316 317 |
# File 'lib/deftones/music/midi.rb', line 311 def close return self if @closed @output.close if @output.respond_to?(:close) @closed = true self end |
#closed? ⇒ Boolean
319 320 321 |
# File 'lib/deftones/music/midi.rb', line 319 def closed? @closed end |
#note_off(note, velocity: 0, channel: 1) ⇒ Object
306 307 308 309 |
# File 'lib/deftones/music/midi.rb', line 306 def note_off(note, velocity: 0, channel: 1) send([self.class.parent_status_byte(0x80, channel), Midi.send(:normalize_note, note), Midi.send(:normalize_data_byte, velocity)]) end |
#note_on(note, velocity: 100, channel: 1) ⇒ Object
301 302 303 304 |
# File 'lib/deftones/music/midi.rb', line 301 def note_on(note, velocity: 100, channel: 1) send([self.class.parent_status_byte(0x90, channel), Midi.send(:normalize_note, note), Midi.send(:normalize_data_byte, velocity)]) end |
#send(message) ⇒ Object
294 295 296 297 298 299 |
# File 'lib/deftones/music/midi.rb', line 294 def send() raise IOError, "MIDI output session is closed" if @closed @output.puts() self end |