Class: Deftones::Core::Source::VolumeProxy
- Inherits:
-
Object
- Object
- Deftones::Core::Source::VolumeProxy
- Defined in:
- lib/deftones/core/source.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
- #assign_immediately(target_value) ⇒ Object private
- #cancel_and_hold_at_time(time) ⇒ Object (also: #cancelAndHoldAtTime)
- #cancel_scheduled_values(after_time = 0) ⇒ Object (also: #cancelScheduledValues)
- #current_gain ⇒ Object
- #exponential_ramp_to(target_value, duration = nil) ⇒ Object (also: #exponentialRampTo)
- #gains(num_frames, start_frame) ⇒ Object
-
#initialize(source, 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)
- #value ⇒ Object
- #value=(new_value) ⇒ Object
Constructor Details
#initialize(source, value: 0.0) ⇒ VolumeProxy
Returns a new instance of VolumeProxy.
9 10 11 12 13 |
# File 'lib/deftones/core/source.rb', line 9 def initialize(source, value: 0.0) @source = source @value = value.to_f @automation = Signal.new(value: @value, units: :number, context: source.context) end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
7 8 9 |
# File 'lib/deftones/core/source.rb', line 7 def source @source end |
Instance Method Details
#assign_immediately(target_value) ⇒ Object (private)
84 85 86 87 |
# File 'lib/deftones/core/source.rb', line 84 def assign_immediately(target_value) self.value = target_value self end |
#cancel_and_hold_at_time(time) ⇒ Object Also known as: cancelAndHoldAtTime
61 62 63 64 65 66 |
# File 'lib/deftones/core/source.rb', line 61 def cancel_and_hold_at_time(time) @automation.cancel_and_hold_at_time(time) @value = @automation.get_value_at_time(time) source.send(:apply_volume!) self end |
#cancel_scheduled_values(after_time = 0) ⇒ Object Also known as: cancelScheduledValues
56 57 58 59 |
# File 'lib/deftones/core/source.rb', line 56 def cancel_scheduled_values(after_time = 0) @automation.cancel_scheduled_values(after_time) self end |
#current_gain ⇒ Object
50 51 52 53 54 |
# File 'lib/deftones/core/source.rb', line 50 def current_gain return 0.0 if source.mute? Deftones.db_to_gain(@automation.get_value_at_time(source.context.current_time)) end |
#exponential_ramp_to(target_value, duration = nil) ⇒ Object Also known as: exponentialRampTo
72 73 74 |
# File 'lib/deftones/core/source.rb', line 72 def exponential_ramp_to(target_value, duration = nil) ramp_to(target_value, duration) end |
#gains(num_frames, start_frame) ⇒ Object
44 45 46 47 48 |
# File 'lib/deftones/core/source.rb', line 44 def gains(num_frames, start_frame) return Array.new(num_frames, 0.0) if source.mute? @automation.process(num_frames, start_frame).map { |db| Deftones.db_to_gain(db) } end |
#linear_ramp_to(target_value, duration = nil) ⇒ Object Also known as: linearRampTo
68 69 70 |
# File 'lib/deftones/core/source.rb', line 68 def linear_ramp_to(target_value, duration = nil) ramp_to(target_value, duration) end |
#ramp_to(target_value, duration = nil) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/deftones/core/source.rb', line 25 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 @automation.linear_ramp_to_value_at_time(@value, source.context.current_time + resolved_duration) source.send(:apply_volume!) self end |
#set_value_at_time(target_value, time) ⇒ Object Also known as: setValueAtTime
37 38 39 40 41 42 |
# File 'lib/deftones/core/source.rb', line 37 def set_value_at_time(target_value, time) @value = target_value.to_f @automation.set_value_at_time(@value, time) source.send(:apply_volume!) self end |
#value ⇒ Object
15 16 17 |
# File 'lib/deftones/core/source.rb', line 15 def value @value end |
#value=(new_value) ⇒ Object
19 20 21 22 23 |
# File 'lib/deftones/core/source.rb', line 19 def value=(new_value) @value = new_value.to_f @automation.value = @value source.send(:apply_volume!) end |