Sha256: 0dfb9c943a74cf42ee523f33f2e3976a57283e59cdd749bf175b88ef1e9d361a

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module Vissen
  module Input
    module Message
      # From the MIDI Association:
      #   This message is sent when a controller value changes. Controllers
      #   include devices such as pedals and levers. Controller numbers 120-127
      #   are reserved as "Channel Mode Messages".
      class ControlChange < Base
        STATUS = 0xB0

        # @return [Integer] the control number.
        def number
          data[1]
        end

        # @return [Integer] the control value.
        def value
          data[2]
        end

        class << self
          protected

          # The control change message is special in that it is only valid when
          # the second byte takes values lower than 120. We therefore need to
          # override `Base.klass_matcher`.
          #
          # FIXME: other matchers created may not be correct.
          def klass_matcher
            super do |d|
              (d[0] & STATUS_MASK) == STATUS && d[1] < 120
            end
          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/control_change.rb