Module: Diamond::API::MIDI

Included in:
Diamond::Arpeggiator
Defined in:
lib/diamond/api.rb

Overview

MIDI convenience methods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/diamond/api.rb', line 9

def self.included(base)
  base.send(:extend, Forwardable)
  base.send(:def_delegators, 
            :@midi,
            :<<,
            :add,
            :mute,
            :mute=,
            :omni_on, 
            :remove,
            :rx_channel, 
            :receive_channel,
            :rx_channel=,
            :receive_channel=,
            :toggle_mute,
            :tx_channel, 
            :transmit_channel,
            :tx_channel=,
            :transmit_channel=
           )
end

Instance Method Details

#add_midi_source(source) ⇒ Array<UniMIDI::Input>

Add a MIDI input

Parameters:

  • source (UniMIDI::Input)

Returns:

  • (Array<UniMIDI::Input>)

34
35
36
# File 'lib/diamond/api.rb', line 34

def add_midi_source(source)
  @midi.inputs << source
end

#midi_sourcesArray<UniMIDI::Input>

MIDI inputs associated with this instrument

Returns:

  • (Array<UniMIDI::Input>)

47
48
49
# File 'lib/diamond/api.rb', line 47

def midi_sources
  @midi.inputs
end

#mute?Boolean Also known as: muted?

Is the instrument MIDI output muted?

Returns:

  • (Boolean)

53
54
55
# File 'lib/diamond/api.rb', line 53

def mute?
  @midi.output.mute?
end

#remove_midi_source(source) ⇒ Array<UniMIDI::Input>

Remove a MIDI input

Parameters:

  • source (UniMIDI::Input)

Returns:

  • (Array<UniMIDI::Input>)

41
42
43
# File 'lib/diamond/api.rb', line 41

def remove_midi_source(source)
  @midi.inputs.delete(source)
end