Class: Vissen::Input::Message::PitchBendChange
- Defined in:
- lib/vissen/input/message/pitch_bend_change.rb
Overview
From the MIDI Association:
This message is sent to indicate a change in the pitch bender (wheel or lever, typically). The pitch bender is measured by a fourteen bit value. Center (no pitch change) is 2000H. Sensitivity is a function of the receiver, but may be set using RPN 0.
Constant Summary collapse
- STATUS =
0xE0
- CENTER_VALUE =
Center value is defined as the the offset that should be removed from the 14 bit pitch bend value to center it around zero.
0x2000
Constants inherited from Base
Constants included from Vissen::Input::Message
CHANNEL_MASK, DATA_LENGTH, STATUS_MASK
Instance Attribute Summary
Attributes included from Vissen::Input::Message
Class Method Summary collapse
-
.create(value = 0.0, **args) ⇒ PitchBendChange
TODO: Check the range on value.
Instance Method Summary collapse
-
#raw ⇒ Integer
The integer pitch bend value.
-
#value ⇒ Float
The pitch bend value normalized to the range (-1..1).
Methods inherited from Base
[], factory, match, match?, matcher, #valid?
Methods included from Vissen::Input::Message
#channel, #fetch, #initialize, #status, #to_h, #valid?
Class Method Details
.create(value = 0.0, **args) ⇒ PitchBendChange
TODO: Check the range on value.
36 37 38 39 40 |
# File 'lib/vissen/input/message/pitch_bend_change.rb', line 36 def create(value = 0.0, **args) bin_value = (value.to_f * CENTER_VALUE).round + CENTER_VALUE super(bin_value & 0xFF, bin_value >> 7, **args) end |
Instance Method Details
#raw ⇒ Integer
Returns the integer pitch bend value.
21 22 23 |
# File 'lib/vissen/input/message/pitch_bend_change.rb', line 21 def raw (data[2] << 7) + data[1] - CENTER_VALUE end |
#value ⇒ Float
Returns the pitch bend value normalized to the range (-1..1).
26 27 28 |
# File 'lib/vissen/input/message/pitch_bend_change.rb', line 26 def value raw.to_f / CENTER_VALUE end |