Class: Deftones::Component::LFO
Constant Summary
Source::Oscillator::GENERATORS, Source::Oscillator::TYPES
Instance Attribute Summary collapse
#detune, #frequency, #type
#mute, #onstop, #volume
Instance Method Summary
collapse
-
#coerce_range_value(value) ⇒ Object
private
-
#get_defaults ⇒ Object
(also: #getDefaults)
-
#initialize(frequency: 1.0, min: 0.0, max: 1.0, amplitude: 1.0, units: :number, convert: true, type: :sine, context: Deftones.context) ⇒ LFO
constructor
-
#max ⇒ Object
-
#max=(value) ⇒ Object
-
#min ⇒ Object
-
#min=(value) ⇒ Object
-
#process(_input_buffer, num_frames, start_frame, cache) ⇒ Object
-
#values(num_frames, start_frame = 0, cache = {}) ⇒ Object
bandlimited_sawtooth, bandlimited_square, bandlimited_triangle, #detune_ratio, naive_triangle, #normalize_type, #phase, #phase=, poly_blep, poly_blep_end, poly_blep_start, sample, #sample_for
#active_at?, #apply_volume!, #cancel_stop, #clear_transport_event, #dispose, #mute?, #notify_stop_in_window, #number_of_inputs, #render, #render_block, #resolve_time, #resolve_transport_time, #restart, #schedule_transport_event, #source_type, #start, #state, #stop, #sync, #synced?, #unsync, #uses_legacy_render_for_block?
Constructor Details
#initialize(frequency: 1.0, min: 0.0, max: 1.0, amplitude: 1.0, units: :number, convert: true, type: :sine, context: Deftones.context) ⇒ LFO
Returns a new instance of LFO.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/deftones/component/lfo.rb', line 9
def initialize(
frequency: 1.0,
min: 0.0,
max: 1.0,
amplitude: 1.0,
units: :number,
convert: true,
type: :sine,
context: Deftones.context
)
super(type: type, frequency: frequency, context: context)
@units = units.to_sym
@convert = !!convert
@amplitude = Core::Param.new(value: amplitude, units: :number, context: context)
self.min = min
self.max = max
end
|
Instance Attribute Details
#amplitude ⇒ Object
Returns the value of attribute amplitude.
6
7
8
|
# File 'lib/deftones/component/lfo.rb', line 6
def amplitude
@amplitude
end
|
#convert ⇒ Object
Returns the value of attribute convert.
7
8
9
|
# File 'lib/deftones/component/lfo.rb', line 7
def convert
@convert
end
|
#units ⇒ Object
Returns the value of attribute units.
6
7
8
|
# File 'lib/deftones/component/lfo.rb', line 6
def units
@units
end
|
Instance Method Details
#coerce_range_value(value) ⇒ Object
79
80
81
82
83
84
85
|
# File 'lib/deftones/component/lfo.rb', line 79
def coerce_range_value(value)
return value.value_of if value.respond_to?(:value_of) && !convert
signal = Core::Signal.new(value: 0.0, units: units, context: context)
signal.convert = convert
signal.send(:coerce_value, value)
end
|
#get_defaults ⇒ Object
Also known as:
getDefaults
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/deftones/component/lfo.rb', line 47
def get_defaults
{
frequency: 1.0,
min: 0.0,
max: 1.0,
amplitude: 1.0,
units: :number,
convert: true,
type: :sine
}
end
|
#max ⇒ Object
35
36
37
|
# File 'lib/deftones/component/lfo.rb', line 35
def max
@max
end
|
#max=(value) ⇒ Object
39
40
41
|
# File 'lib/deftones/component/lfo.rb', line 39
def max=(value)
@max = coerce_range_value(value)
end
|
#min ⇒ Object
27
28
29
|
# File 'lib/deftones/component/lfo.rb', line 27
def min
@min
end
|
#min=(value) ⇒ Object
31
32
33
|
# File 'lib/deftones/component/lfo.rb', line 31
def min=(value)
@min = coerce_range_value(value)
end
|
#process(_input_buffer, num_frames, start_frame, cache) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/deftones/component/lfo.rb', line 59
def process(_input_buffer, num_frames, start_frame, cache)
waveform = super
amplitudes = @amplitude.process(num_frames, start_frame)
midpoint = (@min + @max) * 0.5
half_range = (@max - @min) * 0.5
Array.new(num_frames) do |index|
depth = amplitudes[index].clamp(0.0, 1.0)
midpoint + (waveform[index] * half_range * depth)
end
end
|
#values(num_frames, start_frame = 0, cache = {}) ⇒ Object
71
72
73
|
# File 'lib/deftones/component/lfo.rb', line 71
def values(num_frames, start_frame = 0, cache = {})
render(num_frames, start_frame, cache)
end
|