module Nibbler::Midilib

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

Public Instance Methods

channel_aftertouch(second_nibble, data_byte) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# File lib/nibbler/midilib.rb, line 42
def system_exclusive(*a)
  MIDI::SystemExclusive.new(a)
end
system_realtime(second_nibble) click to toggle source
# 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