Block-level merge midi defaults

with_merged_midi_defaults  

Specify opt values to be used by any following call to the midi_* fns within the specified do/end block. Merges the specified values with any previous midi defaults, rather than replacing them. After the do/end block has completed, previous 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

use_midi_defaults channel: 3, port: "foo"

midi_note_on :e3

with_merged_midi_defaults channel: 1 do

  midi_note_on :e2
                  
                  
end

midi_note_on :e2
                
                



# Sends MIDI :e1 note_on with default opts
 
 
 
# Sends MIDI :e3 note_on to channel 3 on port "foo"
 
 
 
# Sends MIDI :e2 note_on to channel 1 on port "foo".
# This is because the call to use_merged_midi_defaults overrode the
# channel but not the port which got merged in.
 
 
# Sends MIDI :e2 note_on to channel 3 on port "foo".
# This is because the previous defaults were restored after
# the call to with_merged_midi_defaults.