Sha256: 3ca64d437cd64f36796d94758f98a167038cf1be929b6d2fdfe683c4b214107b
Contents?: true
Size: 1.26 KB
Versions: 1
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true module Vissen module Input module Message # From the MIDI Association: # Note On event. # This message is sent when a note is depressed (start). # # Note Off event. # This message is sent when a note is released (ended). class Note < Base STATUS_MASK = 0xE0 STATUS = 0x80 NOTE_ON = 0x10 NOTE_OFF = 0x00 # @return [Integer] the note value. def note data[1] end # @return [Integer] the velocity value. def velocity data[2] end # @return [true, false] true if the note was released. def off? (data[0] & NOTE_ON).zero? end # @return [true, false] true if the note was depressed. def on? !off? end class << self # @param bytes (see Base.create) # @param on [true, false] true if the note should be depressed, # otherwise false. # @param args (see Base.create) # @return [Note] def create(*bytes, on: true, **args) super(*bytes, status: STATUS + (on ? NOTE_ON : NOTE_OFF), **args) end end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vissen-input-0.2.2 | lib/vissen/input/message/note.rb |