Class: MIDIator::Driver::CoreMIDI

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

Overview

:nodoc:

Defined Under Namespace

Modules: C, CF

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



67
68
69
# File 'lib/midiator/drivers/core_midi.rb', line 67

def close
  C.mIDIClientDispose( @client )
end

#message(*args) ⇒ Object



71
72
73
74
75
76
77
78
79
80
81
# File 'lib/midiator/drivers/core_midi.rb', line 71

def message( *args )
  format = "C" * args.size
  bytes = args.pack( format ).to_ptr
  packet_list = DL.malloc( 256 )
  packet_ptr = C.mIDIPacketListInit( packet_list )

  # Pass in two 32-bit 0s for the 64 bit time
  packet_ptr = C.mIDIPacketListAdd( packet_list, 256, packet_ptr, 0, 0, args.size, bytes )

  C.mIDISend( @outport, @destination, packet_list )
end

#openObject

D R I V E R A P I



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/midiator/drivers/core_midi.rb', line 53

def open
  client_name = CF.cFStringCreateWithCString( nil, "MIDIator", 0 )
  @client = DL::PtrData.new( nil )
  C.mIDIClientCreate( client_name, nil, nil, @client.ref )

  port_name = CF.cFStringCreateWithCString( nil, "Output", 0 )
  @outport = DL::PtrData.new( nil )
  C.mIDIOutputPortCreate( @client, port_name, @outport.ref )

  number_of_destinations = C.mIDIGetNumberOfDestinations
  raise MIDIator::NoMIDIDestinations if number_of_destinations < 1
  @destination = C.mIDIGetDestination( 0 )
end