Module: Stretto::MusicElements::AttackDecay
Overview
This module encapsulates behavior for all elements that specify attack and decay values
Attack represents the "warm up" of the note, and decay its "cool down", that is, the times it takes to the note to reach its main volume form 0 when building, and the inverse when going into silence. The default value for both is 0
Constant Summary
- DEFAULT_ATTACK =
64- DEFAULT_DECAY =
64
Instance Attribute Summary (collapse)
-
- (Object) original_attack
readonly
Returns the value of attribute original_attack.
-
- (Object) original_decay
readonly
Returns the value of attribute original_decay.
Instance Method Summary (collapse)
-
- (Number) attack
Numeric value for attack, or the default one.
-
- (Object) attack=(attack)
Sets the instance variable `@attack` and performs validation in range.
-
- (Object) build_attack_and_decay(original_attack, original_decay)
Sets up the original attack and decay tokens.
-
- (Number) decay
Numeric value for delay, or the default one.
-
- (Object) decay=(decay)
Sets the instance variable `@decay` and performs validation in range.
Instance Attribute Details
- (Object) original_attack (readonly)
Returns the value of attribute original_attack
14 15 16 |
# File 'lib/stretto/music_elements/modifiers/attack_decay.rb', line 14 def original_attack @original_attack end |
- (Object) original_decay (readonly)
Returns the value of attribute original_decay
14 15 16 |
# File 'lib/stretto/music_elements/modifiers/attack_decay.rb', line 14 def original_decay @original_decay end |
Instance Method Details
- (Number) attack
Numeric value for attack, or the default one
43 44 45 |
# File 'lib/stretto/music_elements/modifiers/attack_decay.rb', line 43 def attack @original_attack.to_i(@pattern) || DEFAULT_ATTACK end |
- (Object) attack=(attack)
Sets the instance variable `@attack` and performs validation in range
25 26 27 28 29 30 |
# File 'lib/stretto/music_elements/modifiers/attack_decay.rb', line 25 def attack=(attack) @attack = attack || DEFAULT_ATTACK if @attack < 0 or @attack > 127 raise Exceptions::InvalidValueException.new("Attack should be in the range 0..127") end end |
- (Object) build_attack_and_decay(original_attack, original_decay)
Sets up the original attack and decay tokens
17 18 19 20 |
# File 'lib/stretto/music_elements/modifiers/attack_decay.rb', line 17 def build_attack_and_decay(original_attack, original_decay) @original_attack = original_attack @original_decay = original_decay end |
- (Number) decay
Numeric value for delay, or the default one
48 49 50 |
# File 'lib/stretto/music_elements/modifiers/attack_decay.rb', line 48 def decay @original_decay.to_i(@pattern) || DEFAULT_DECAY end |
- (Object) decay=(decay)
Sets the instance variable `@decay` and performs validation in range
35 36 37 38 39 40 |
# File 'lib/stretto/music_elements/modifiers/attack_decay.rb', line 35 def decay=(decay) @decay = decay || DEFAULT_DECAY if @decay < 0 or @decay > 127 raise Exceptions::InvalidValueException.new("Decay should be in the range 0..127") end end |