Class: CoreMIDI::Entity

Inherits:
Object
  • Object
show all
Defined in:
lib/coremidi/entity.rb

Overview

A MIDI entity can have any number of MIDI endpoints, each of which is a source or destination of a 16-channel MIDI stream. By grouping a device's endpoints into entities, the system has enough information for an application to make reasonable default assumptions about how to communicate in a bi-directional manner with each entity, as is necessary in MIDI librarian applications.

developer.apple.com/library/ios/documentation/CoreMidi/Reference/MIDIServices_Reference/Reference/reference.html

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource, options = {}) ⇒ Entity

Returns a new instance of Entity

Options Hash (options):

  • :include_offline (Boolean)

    Include offline endpoints in the list



21
22
23
24
25
26
27
28
# File 'lib/coremidi/entity.rb', line 21

def initialize(resource, options = {})
  @endpoints = { 
    :source => [], 
    :destination => [] 
  }
  @resource = resource
  populate(options)
end

Instance Attribute Details

#endpointsObject (readonly)

Returns the value of attribute endpoints



12
13
14
# File 'lib/coremidi/entity.rb', line 12

def endpoints
  @endpoints
end

#manufacturerObject (readonly)

Returns the value of attribute manufacturer



12
13
14
# File 'lib/coremidi/entity.rb', line 12

def manufacturer
  @manufacturer
end

#modelObject (readonly)

Returns the value of attribute model



12
13
14
# File 'lib/coremidi/entity.rb', line 12

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name



12
13
14
# File 'lib/coremidi/entity.rb', line 12

def name
  @name
end

#resourceObject (readonly)

Returns the value of attribute resource



12
13
14
# File 'lib/coremidi/entity.rb', line 12

def resource
  @resource
end

Instance Method Details

#online?Boolean

Is the entity online?



44
45
46
# File 'lib/coremidi/entity.rb', line 44

def online?
  get_int(:offline) == 0
end

#populate_endpoint_ids(starting_id) ⇒ Fixnum

Assign all of this Entity's endpoints an consecutive local id



33
34
35
36
37
38
39
40
# File 'lib/coremidi/entity.rb', line 33

def populate_endpoint_ids(starting_id)
  counter = 0
  @endpoints.values.flatten.each do |endpoint|
    endpoint.id = counter + starting_id
    counter += 1
  end
  counter
end