Block-level use new MIDI defaults

with_midi_defaults  

Specify new default values to be used by all calls to midi_* fns within the do/end block. After the do/end block has completed the previous MIDI defaults (if any) are restored.

Introduced in v3.0

Options

channel:

MIDI channel(s) to send event on

port:

MIDI port(s) to send to

velocity:

Note velocity as a MIDI number.

vel_f:

Velocity as a value between 0 and 1 (will be converted to a MIDI velocity between 0 and 127)

on:

If specified and false/nil/0 will stop the midi note on message from being sent out. (Ensures all opts are evaluated in this call to midi_note_on regardless of value).

Example

# Example 1

midi_note_on :e1

with_midi_defaults channel: 3, port: "foo" do
  midi_note_on :e3
end

use_midi_defaults channel: 1  

with_midi_defaults channel: 5 do
  midi_note_on :e2
                  
end

  midi_note_on :e4
                  



# Sends MIDI :e1 note on with default opts
 
 
# Sends MIDI :e3 note on to channel 3 on port "foo"
 
 
# this will be overridden by the following
 
 
# Sends MIDI :e2 note on to channel 5.
# Note that the port is back to the default
 
 
# Sends MIDI :e4 note on to channel 1
# Note that the call to use_midi_defaults is now honoured.