Class: Stretto::MusicElements::ChannelPressure
- Inherits:
-
MusicElement
- Object
- MusicElement
- Stretto::MusicElements::ChannelPressure
- Defined in:
- lib/stretto/music_elements/channel_pressure.rb
Overview
ChannelPressure sends a MIDI message similar to applying pressure to an electronic keyboard. This event applies pressure to the whole channel, and its value can rango from 0 to 127
Constant Summary collapse
- MAX_CHANNEL_PRESSURE_VALUE =
127
Instance Attribute Summary
Attributes inherited from MusicElement
Attributes included from Node
Instance Method Summary collapse
-
#initialize(string_or_options, pattern = nil) ⇒ ChannelPressure
constructor
A new instance of ChannelPressure.
- #value ⇒ Object
-
#value=(value) ⇒ Object
Sets value and validates in range.
Methods inherited from MusicElement
#build_music_string, #duration, #end_of_tie?, #start_of_tie?, #to_s
Constructor Details
#initialize(string_or_options, pattern = nil) ⇒ ChannelPressure
Returns a new instance of ChannelPressure.
13 14 15 16 17 18 19 20 |
# File 'lib/stretto/music_elements/channel_pressure.rb', line 13 def initialize(, pattern = nil) token = case when String then Stretto::Parser.parse_channel_pressure!() else end super(token[:text_value], pattern) @original_value = token[:value] end |
Instance Method Details
#value ⇒ Object
30 31 32 |
# File 'lib/stretto/music_elements/channel_pressure.rb', line 30 def value @value || @original_value.to_i(@pattern) end |
#value=(value) ⇒ Object
Sets value and validates in range
23 24 25 26 27 28 |
# File 'lib/stretto/music_elements/channel_pressure.rb', line 23 def value=(value) if value < 0 or value > MAX_CHANNEL_PRESSURE_VALUE raise Exceptions::ValueOutOfBoundsException.new("Channel pressure should be in range 0..#{MAX_CHANNEL_PRESSURE_VALUE}") end @value = value end |