Module: Nibbler::Midilib

Extended by:
Midilib
Included in:
Midilib
Defined in:
lib/nibbler/midilib.rb

Overview

Construct messages with midilib in a generic way github.com/jimm/midilib midilib is copyright © 2003-2010 Jim Menard

Instance Method Summary collapse

Instance Method Details

#channel_aftertouch(second_nibble, data_byte) ⇒ Object



32
33
34
# File 'lib/nibbler/midilib.rb', line 32

def channel_aftertouch(second_nibble, data_byte)
  MIDI::ChannelPressure.new(second_nibble, data_byte)
end

#control_change(second_nibble, data_byte_1, data_byte_2) ⇒ Object



24
25
26
# File 'lib/nibbler/midilib.rb', line 24

def control_change(second_nibble, data_byte_1, data_byte_2)
  MIDI::Controller.new(second_nibble, data_byte_1, data_byte_2)
end

#note_off(second_nibble, data_byte_1, data_byte_2) ⇒ Object



12
13
14
# File 'lib/nibbler/midilib.rb', line 12

def note_off(second_nibble, data_byte_1, data_byte_2)
  MIDI::NoteOff.new(second_nibble, data_byte_1, data_byte_2)
end

#note_on(second_nibble, data_byte_1, data_byte_2) ⇒ Object



16
17
18
# File 'lib/nibbler/midilib.rb', line 16

def note_on(second_nibble, data_byte_1, data_byte_2)
  MIDI::NoteOn.new(second_nibble, data_byte_1, data_byte_2)
end

#pitch_bend(second_nibble, data_byte_1, data_byte_2) ⇒ Object



36
37
38
39
40
# File 'lib/nibbler/midilib.rb', line 36

def pitch_bend(second_nibble, data_byte_1, data_byte_2)
  # to-do handle the midilib lsb/msb
  # right now the second data byte is being thrown away
  MIDI:: PitchBend.new(second_nibble, data_byte_1, data_byte_2)
end

#polyphonic_aftertouch(second_nibble, data_byte_1, data_byte_2) ⇒ Object



20
21
22
# File 'lib/nibbler/midilib.rb', line 20

def polyphonic_aftertouch(second_nibble, data_byte_1, data_byte_2)
  MIDI::PolyPressure.new(second_nibble, data_byte_1, data_byte_2)
end

#program_change(second_nibble, data_byte) ⇒ Object



28
29
30
# File 'lib/nibbler/midilib.rb', line 28

def program_change(second_nibble, data_byte)
  MIDI::ProgramChange.new(second_nibble, data_byte)
end

#system_common(second_nibble, data_byte_1 = nil, data_byte_2 = nil) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/nibbler/midilib.rb', line 46

def system_common(second_nibble, data_byte_1 = nil, data_byte_2 = nil)
  case second_nibble
    when 0x2 then MIDI::SongPointer.new(data_byte_1) # similar issue to pitch bend here
    when 0x3 then MIDI::SongSelect.new(data_byte_1)
    when 0x6 then MIDI::TuneRequest.new
  end      
end

#system_exclusive(*a) ⇒ Object



42
43
44
# File 'lib/nibbler/midilib.rb', line 42

def system_exclusive(*a)
  MIDI::SystemExclusive.new(a)
end

#system_realtime(second_nibble) ⇒ Object



54
55
56
57
58
59
60
61
62
63
# File 'lib/nibbler/midilib.rb', line 54

def system_realtime(second_nibble)
  case second_nibble
    when 0x8 then MIDI::Clock.new
    when 0xA then MIDI::Start.new
    when 0xB then MIDI::Continue.new
    when 0xC then MIDI::Stop.new
    when 0xE then MIDI::ActiveSense.new
    when 0xF then MIDI::SystemReset.new
  end      
end