Wednesday, August 31, 2011

MicroMIDI: Custom Events

While MicroMIDI has built-in functions such as transpose to process MIDI input, these functions may not always suit your purpose musically.

In those situations, you can bind your own input events.

Here is an example similar to the one in the last post except that only the notes C, E, and G are transposed
require "micromidi"

@input = UniMIDI::Input.use(:first)
@output = UniMIDI::Output.use(:first)

MIDI.using(@input, @output) do

  thru_except :note

  receive :note do |message|
    message.octave += 1 if %w{C E G}.include?(message.note_name)
    output message



For the sake of expressiveness, there are many permutations of each of these methods. I recommend reading the rdoc for the MicroMIDI Instructions classes to get a handle on what's possible.

Next: Shorthand with MicroMIDI


  1. Sigh.

    [2] pry(main)> @input = UniMIDI::Input.use(:first)
    RuntimeError: midiInOpen: No Memory
    from C:/Ruby193/lib/ruby/gems/1.9.1/gems/midi-winmm-0.1.10/lib/midi-winmm/map.rb:217:in `winmm_func'

    Is your library working in Windows? I think its power is enourmous, I'd love to get it working! :)
    Thank you!

  2. @farro - I'm going to fix some bugs in the Windows version today. I'll see if I can reproduce this and let you know

  3. Man, thanks! Were you able to reproduce the issue and have it sorted? I'd love to fiddle with MIDI here but unfortunately I have to run Win! Thanks!

  4. By the way if I can help in any way please tell me.