Class: Deftones::Component::FrequencyEnvelope

Inherits:
Envelope show all
Defined in:
lib/deftones/component/frequency_envelope.rb

Constant Summary

Constants inherited from Envelope

Envelope::STATES

Instance Attribute Summary collapse

Attributes inherited from Envelope

#attack, #decay, #release, #state, #sustain

Attributes inherited from Deftones::Core::AudioNode

#context, #input

Instance Method Summary collapse

Methods inherited from Envelope

#active?, #attack_value, #consume_events, #decay_value, #envelope_value_at, #idle?, #lerp, #multichannel_process?, #process, #release_value, #resolve_time, #sample_time, #schedule_event, #transition_to, #trigger_attack, #trigger_attack_release, #trigger_release

Methods inherited from Deftones::Core::AudioNode

#>>, #attach_destination, #attach_source, #block_time, #chain, #channel_count, #channel_count_mode, #channel_interpretation, #connect, #connected?, #default_input_channels, #default_output_channels, #destination_for_connection, #detach_all_destinations, #detach_destination, #detach_source, #disconnect, #dispose, #disposed?, #fan, #get, #immediate, #input_for_index, #inputs, #mix_source_blocks, #multichannel_process?, #name, #normalize_connection_index, #normalize_output_block, #now, #number_of_inputs, #number_of_outputs, #output, #output_for_connection, #output_for_index, #outputs, #process, #raise_connection_index_error!, #reaches_node?, #render, #render_block, #sample_time, #set, #to_destination, #to_frequency, #to_master, #to_midi, #to_output, #to_s, #to_seconds, #to_ticks, #uses_legacy_render_for_block?, #validate_connectable!, #validate_connection_index!

Constructor Details

#initialize(base_frequency: 440.0, octaves: 2.0, **options) ⇒ FrequencyEnvelope

Returns a new instance of FrequencyEnvelope.



8
9
10
11
12
# File 'lib/deftones/component/frequency_envelope.rb', line 8

def initialize(base_frequency: 440.0, octaves: 2.0, **options)
  super(**options)
  @base_frequency = base_frequency.to_f
  @octaves = octaves.to_f
end

Instance Attribute Details

#base_frequencyObject

Returns the value of attribute base_frequency.



6
7
8
# File 'lib/deftones/component/frequency_envelope.rb', line 6

def base_frequency
  @base_frequency
end

#octavesObject

Returns the value of attribute octaves.



6
7
8
# File 'lib/deftones/component/frequency_envelope.rb', line 6

def octaves
  @octaves
end

Instance Method Details

#values(num_frames, start_frame = 0) ⇒ Object



14
15
16
17
18
19
20
21
# File 'lib/deftones/component/frequency_envelope.rb', line 14

def values(num_frames, start_frame = 0)
  Array.new(num_frames) do |index|
    time = sample_time(start_frame + index)
    consume_events(time)
    @current_value = envelope_value_at(time)
    @base_frequency * (2.0**(@current_value * @octaves))
  end
end