Class: Deftones::Core::ComputedSignal
- Inherits:
-
Signal
- Object
- Signal
- Deftones::Core::ComputedSignal
show all
- Defined in:
- lib/deftones/core/computed_signal.rb
Constant Summary
Constants inherited
from Signal
Signal::EXPONENTIAL_UNITS
Instance Attribute Summary collapse
Attributes inherited from Signal
#clamp_values, #context, #convert_values, #default_value, #max_value, #min_value, #output, #units
Instance Method Summary
collapse
Methods inherited from Signal
#add_event, #apply, #automation_anchor_time, #automation_event_count, #automation_events?, #bounded_value, #cancel_and_hold_at_time, #coerce_value, #connect, #convert, #convert=, #convert_frequency, #convert_generic, #convert_without_units, #curve_value, #db_to_gain, #disconnect, #dispose, #disposed?, #event_sort_key, #exponential_approach_value_at_time, #exponential_ramp_to_value_at_time, #get, #get_defaults, #get_value_at_time, #immediate, #insert_event, #interpolate, #linear_ramp_to_value_at_time, #name, #now, #overridden?, #resolve_automation_start_time, #resolve_time, #safe_exponential_value, #sample_time, #schedule_automation, #set, #set_ramp_point, #set_target_at_time, #set_value_curve_at_time, #target_ramp_to, #target_value, #to_frequency, #to_s, #to_seconds, #to_ticks, #value_at
#abs, #add, #equal_power_gain, #greater_than, #greater_than_zero, #modulo, #multiply, #negate, #normalize, #pow, #scale, #scale_exp, #subtract, #to_audio, #to_gain, #wave_shaper
Constructor Details
#initialize(input:, units: nil, context: nil) ⇒ ComputedSignal
Returns a new instance of ComputedSignal.
8
9
10
11
12
13
14
|
# File 'lib/deftones/core/computed_signal.rb', line 8
def initialize(input:, units: nil, context: nil)
resolved_context = resolve_context(input, fallback: context)
resolved_units = units || default_units(input)
super(value: 0.0, units: resolved_units, context: resolved_context)
@input = coerce_signal(input || 0.0, units: resolved_units)
end
|
Instance Attribute Details
Returns the value of attribute input.
6
7
8
|
# File 'lib/deftones/core/computed_signal.rb', line 6
def input
@input
end
|
Instance Method Details
#coerce_signal(value, units:) ⇒ Object
52
53
54
55
56
|
# File 'lib/deftones/core/computed_signal.rb', line 52
def coerce_signal(value, units:)
return value if value.respond_to?(:value_at)
Signal.new(value: value, units: units, context: context)
end
|
#default_units(candidate) ⇒ Object
41
42
43
|
# File 'lib/deftones/core/computed_signal.rb', line 41
def default_units(candidate)
candidate.respond_to?(:units) ? candidate.units : :number
end
|
#exponentiate(value, exponent) ⇒ Object
58
59
60
61
62
|
# File 'lib/deftones/core/computed_signal.rb', line 58
def exponentiate(value, exponent)
return value**exponent if value >= 0.0 || integer_like?(exponent)
-((-value)**exponent)
end
|
#integer_like?(value) ⇒ Boolean
64
65
66
|
# File 'lib/deftones/core/computed_signal.rb', line 64
def integer_like?(value)
value.finite? && value.round == value
end
|
#process(num_frames, start_frame = 0) ⇒ Object
33
34
35
36
37
|
# File 'lib/deftones/core/computed_signal.rb', line 33
def process(num_frames, start_frame = 0)
Array.new(num_frames) do |offset|
value_at(sample_time(start_frame + offset))
end
end
|
#ramp_to ⇒ Object
Also known as:
linear_ramp_to, exponential_ramp_to, set_value_at_time, cancel_scheduled_values
24
25
26
|
# File 'lib/deftones/core/computed_signal.rb', line 24
def ramp_to(*)
raise Deftones::Error, "#{self.class.name} is derived and cannot be automated directly"
end
|
#resolve_context(candidate, fallback:) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/deftones/core/computed_signal.rb', line 45
def resolve_context(candidate, fallback:)
return candidate.context if candidate.respond_to?(:context)
return fallback if fallback
Deftones.context
end
|
#value ⇒ Object
16
17
18
|
# File 'lib/deftones/core/computed_signal.rb', line 16
def value
value_at(context.current_time)
end
|
#value=(_new_value) ⇒ Object
20
21
22
|
# File 'lib/deftones/core/computed_signal.rb', line 20
def value=(_new_value)
raise Deftones::Error, "#{self.class.name} is derived and cannot be assigned"
end
|