Best methods of sending continuous MIDI data

What methods are people using to send continuous MIDI data? For a straight slide, I can do something like the following:

define :midi_cc_slide do |code,values=[0,127],time=1.0|
  
  if values.length == 1
    midi_cc code, values[0]
  end
  
  if values.length > 1
    
    in_thread do
      values.length.times do |i|
        midi_cc code, values[i]
        sleep time / (values.length-1.0)
      end
      
    end
  end
end



use_midi_defaults port: "to_max_1", channel: 1

midi_cc_slide 17, (line 0, 127, steps: 128, inclusive: true), 4.0

But, to do something like use pitch_bend to make a remote MIDI voice have vibrato, particularly non-mechanistic vibrato, that’s more tricky.

i just had a play around and came up with this:

use_midi_defaults port: "iac_driver_iac_bus_1", channel: 1
midi :e, sustain: 3

envelope = (line 0, 0.3, steps: 100, inclusive: true).mirror
200.times do |i|
  midi_pitch_bend 0.5 + envelope[i] * Math.sin(0.35*i)
  sleep 0.01
end

It’s a bit rough around the edges (it could do with parameterising and putting into a function), but it’s a start.
The envelope fades the vibrato effect in and out so you don’t get an abrupt change. It would be nice to modulate the rate too, so it starts slowly and speeds up, but that’s a bit more tricky, and it’s getting late…

1 Like