Class: Deftones::Destination::VolumeProxy
- Inherits:
-
Object
- Object
- Deftones::Destination::VolumeProxy
- Defined in:
- lib/deftones/destination.rb
Instance Attribute Summary collapse
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #assign_immediately(target_value) ⇒ Object private
- #exponential_ramp_to(target_value, duration = nil) ⇒ Object (also: #exponentialRampTo)
-
#initialize(destination, value: 0.0) ⇒ VolumeProxy
constructor
A new instance of VolumeProxy.
- #linear_ramp_to(target_value, duration = nil) ⇒ Object (also: #linearRampTo)
- #ramp_to(target_value, duration = nil) ⇒ Object
- #set_value_at_time(target_value, _time) ⇒ Object (also: #setValueAtTime)
Constructor Details
#initialize(destination, value: 0.0) ⇒ VolumeProxy
Returns a new instance of VolumeProxy.
11 12 13 14 |
# File 'lib/deftones/destination.rb', line 11 def initialize(destination, value: 0.0) @destination = destination @value = value.to_f end |
Instance Attribute Details
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
8 9 10 |
# File 'lib/deftones/destination.rb', line 8 def destination @destination end |
#value ⇒ Object
Returns the value of attribute value.
9 10 11 |
# File 'lib/deftones/destination.rb', line 9 def value @value end |
Instance Method Details
#assign_immediately(target_value) ⇒ Object (private)
55 56 57 58 |
# File 'lib/deftones/destination.rb', line 55 def assign_immediately(target_value) self.value = target_value self end |
#exponential_ramp_to(target_value, duration = nil) ⇒ Object Also known as: exponentialRampTo
39 40 41 |
# File 'lib/deftones/destination.rb', line 39 def exponential_ramp_to(target_value, duration = nil) ramp_to(target_value, duration) end |
#linear_ramp_to(target_value, duration = nil) ⇒ Object Also known as: linearRampTo
35 36 37 |
# File 'lib/deftones/destination.rb', line 35 def linear_ramp_to(target_value, duration = nil) ramp_to(target_value, duration) end |
#ramp_to(target_value, duration = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/deftones/destination.rb', line 21 def ramp_to(target_value, duration = nil) return assign_immediately(target_value) if duration.nil? resolved_duration = Deftones::Music::Time.parse(duration) return assign_immediately(target_value) if resolved_duration <= 0.0 @value = target_value.to_f destination.node.gain.linear_ramp_to_value_at_time( destination.mute? ? 0.0 : Deftones.db_to_gain(@value), destination.context.current_time + resolved_duration ) self end |
#set_value_at_time(target_value, _time) ⇒ Object Also known as: setValueAtTime
43 44 45 46 47 |
# File 'lib/deftones/destination.rb', line 43 def set_value_at_time(target_value, _time) @value = target_value.to_f destination.node.gain.set_value_at_time(destination.mute? ? 0.0 : Deftones.db_to_gain(@value), _time) self end |