Class: MIDIator::Driver::ALSA

Inherits:
MIDIator::Driver show all
Defined in:
lib/midiator/drivers/alsa.rb

Overview

:nodoc:

Defined Under Namespace

Modules: C

Constant Summary

Constants inherited from MIDIator::Driver

CA, CC, OFF, ON, PA, PB, PC

Instance Method Summary collapse

Methods inherited from MIDIator::Driver

#aftertouch, #channel_aftertouch, #control_change, inherited, #initialize, #note_off, #note_on, #pitch_bend, #program_change

Constructor Details

This class inherits a constructor from MIDIator::Driver

Instance Method Details

#closeObject



53
54
55
# File 'lib/midiator/drivers/alsa.rb', line 53

def close
  C.snd_rawmidi_close(@output)
end

#instruct_user!Object

tell the user they need to connect to their output



28
29
30
31
32
33
34
35
# File 'lib/midiator/drivers/alsa.rb', line 28

def instruct_user!
  $stderr.puts "[MIDIator] Please connect the MIDIator output port to your input"
  $stderr.puts "[MIDIator] of choice.  You can use qjackctl or aconnect to do so."
  $stderr.puts "[MIDIator]"
  $stderr.puts "[MIDIator] Press enter when you're done."

  gets # wait for the enter
end

#message(*args) ⇒ Object



57
58
59
60
61
62
# File 'lib/midiator/drivers/alsa.rb', line 57

def message(*args)
  format = "C" * args.size
  bytes = args.pack(format).to_ptr
  C.snd_rawmidi_write(@output, bytes, args.size)
  C.snd_rawmidi_drain(@output)
end

#openObject



48
49
50
51
# File 'lib/midiator/drivers/alsa.rb', line 48

def open
  @output = DL::PtrData.new(nil)
  C.snd_rawmidi_open(nil, @output.ref, "virtual", 0)
end