Module: MicroMIDI::Instructions::Composite
- Included in:
- Context
- Defined in:
- lib/micromidi/instructions/composite.rb,
lib/micromidi/instructions/shorthand.rb
Overview
Commands that are composites of other commands
Instance Method Summary collapse
-
#all_off ⇒ Boolean
(also: #quiet!, #q!, #x)
Send a note off message for every note on every channel.
-
#play(*args) ⇒ Array<MIDIMessage::NoteOn>, MIDIMessage::NoteOn
(also: #p)
Play a note or notes, for the given duration.
Instance Method Details
#all_off ⇒ Boolean Also known as: quiet!, q!, x
Send a note off message for every note on every channel
33 34 35 36 37 38 39 40 |
# File 'lib/micromidi/instructions/composite.rb', line 33 def all_off (0..15).each do |channel| (0..127).each do |note_num| note_off(note_num, :channel => channel) end end true end |
#play(*args) ⇒ Array<MIDIMessage::NoteOn>, MIDIMessage::NoteOn Also known as: p
Play a note or notes, for the given duration.
The first argument must be: [Array<String>, Array<MIDIMessage::NoteOn>, String, MIDIMessage::NoteOn] The last argument must be [Numeric] representing the duration
Additional arguments can be [Array<String>, Array<MIDIMessage::NoteOn>, String, MIDIMessage::NoteOn] and will be played as a chord simultaneously with the first argument.
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/micromidi/instructions/composite.rb', line 19 def play(*args) raise "Last argument must be a Numeric duration" unless args.last.kind_of?(Numeric) args = args.dup duration = args.pop note_or_notes = [args].flatten = (note_or_notes) sleep(duration) send_note_offs() .count > 1 ? : .first end |