Class: Deftones::Analysis::FFT
Instance Attribute Summary
#context, #input
Class Method Summary
collapse
Instance Method Summary
collapse
-
#get_value ⇒ Object
(also: #getValue)
-
#initialize(size: 1024, smoothing: 0.8, return_type: :float, normal_range: false, min_decibels: -100.0,, max_decibels: 0.0, context: Deftones.context) ⇒ FFT
constructor
-
#max_decibels ⇒ Object
(also: #maxDecibels)
-
#max_decibels=(value) ⇒ Object
-
#maxDecibels=(value) ⇒ Object
-
#min_decibels ⇒ Object
(also: #minDecibels)
-
#min_decibels=(value) ⇒ Object
-
#minDecibels=(value) ⇒ Object
-
#multichannel_process? ⇒ Boolean
-
#normal_range ⇒ Object
(also: #normalRange)
-
#normal_range=(value) ⇒ Object
-
#normalRange=(value) ⇒ Object
-
#process(input_buffer, num_frames, start_frame, cache) ⇒ Object
-
#return_type ⇒ Object
(also: #returnType)
-
#return_type=(value) ⇒ Object
-
#returnType=(value) ⇒ Object
-
#size ⇒ Object
-
#size=(value) ⇒ Object
-
#smoothing ⇒ Object
-
#smoothing=(value) ⇒ Object
#>>, #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, #name, #normalize_connection_index, #normalize_output_block, #now, #number_of_inputs, #number_of_outputs, #output, #output_for_connection, #output_for_index, #outputs, #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(size: 1024, smoothing: 0.8, return_type: :float, normal_range: false, min_decibels: -100.0,, max_decibels: 0.0, context: Deftones.context) ⇒ FFT
Returns a new instance of FFT.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/deftones/analysis/fft.rb', line 30
def initialize(size: 1024, smoothing: 0.8, return_type: :float, normal_range: false,
min_decibels: -100.0, max_decibels: 0.0, context: Deftones.context)
super(context: context)
@delegate = Analysis::Analyser.new(
size: size,
type: :fft,
smoothing: smoothing,
return_type: return_type,
normal_range: normal_range,
min_decibels: min_decibels,
max_decibels: max_decibels,
context: context
)
end
|
Class Method Details
.decibels(samples, floor: -100.0)) ⇒ Object
24
25
26
27
28
|
# File 'lib/deftones/analysis/fft.rb', line 24
def self.decibels(samples, floor: -100.0)
magnitudes(samples).map do |magnitude|
[Deftones.gain_to_db([magnitude, 1.0e-12].max), floor.to_f].max
end
end
|
.magnitudes(samples) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/deftones/analysis/fft.rb', line 6
def self.magnitudes(samples)
size = samples.length
half = size / 2
Array.new(half) do |bin|
real = 0.0
imaginary = 0.0
samples.each_with_index do |sample, index|
angle = (2.0 * Math::PI * bin * index) / size
real += sample * Math.cos(angle)
imaginary -= sample * Math.sin(angle)
end
Math.sqrt((real * real) + (imaginary * imaginary)) / [size, 1].max
end
end
|
Instance Method Details
#get_value ⇒ Object
Also known as:
getValue
93
94
95
|
# File 'lib/deftones/analysis/fft.rb', line 93
def get_value
@delegate.get_value
end
|
#max_decibels ⇒ Object
Also known as:
maxDecibels
85
86
87
|
# File 'lib/deftones/analysis/fft.rb', line 85
def max_decibels
@delegate.max_decibels
end
|
#max_decibels=(value) ⇒ Object
89
90
91
|
# File 'lib/deftones/analysis/fft.rb', line 89
def max_decibels=(value)
@delegate.max_decibels = value
end
|
#maxDecibels=(value) ⇒ Object
115
116
117
|
# File 'lib/deftones/analysis/fft.rb', line 115
def maxDecibels=(value)
self.max_decibels = value
end
|
#min_decibels ⇒ Object
Also known as:
minDecibels
77
78
79
|
# File 'lib/deftones/analysis/fft.rb', line 77
def min_decibels
@delegate.min_decibels
end
|
#min_decibels=(value) ⇒ Object
81
82
83
|
# File 'lib/deftones/analysis/fft.rb', line 81
def min_decibels=(value)
@delegate.min_decibels = value
end
|
#minDecibels=(value) ⇒ Object
111
112
113
|
# File 'lib/deftones/analysis/fft.rb', line 111
def minDecibels=(value)
self.min_decibels = value
end
|
#multichannel_process? ⇒ Boolean
123
124
125
|
# File 'lib/deftones/analysis/fft.rb', line 123
def multichannel_process?
true
end
|
#normal_range ⇒ Object
Also known as:
normalRange
69
70
71
|
# File 'lib/deftones/analysis/fft.rb', line 69
def normal_range
@delegate.normal_range
end
|
#normal_range=(value) ⇒ Object
73
74
75
|
# File 'lib/deftones/analysis/fft.rb', line 73
def normal_range=(value)
@delegate.normal_range = value
end
|
#normalRange=(value) ⇒ Object
107
108
109
|
# File 'lib/deftones/analysis/fft.rb', line 107
def normalRange=(value)
self.normal_range = value
end
|
#process(input_buffer, num_frames, start_frame, cache) ⇒ Object
119
120
121
|
# File 'lib/deftones/analysis/fft.rb', line 119
def process(input_buffer, num_frames, start_frame, cache)
@delegate.process(input_buffer, num_frames, start_frame, cache)
end
|
#return_type ⇒ Object
Also known as:
returnType
61
62
63
|
# File 'lib/deftones/analysis/fft.rb', line 61
def return_type
@delegate.return_type
end
|
#return_type=(value) ⇒ Object
65
66
67
|
# File 'lib/deftones/analysis/fft.rb', line 65
def return_type=(value)
@delegate.return_type = value
end
|
#returnType=(value) ⇒ Object
103
104
105
|
# File 'lib/deftones/analysis/fft.rb', line 103
def returnType=(value)
self.return_type = value
end
|
#size ⇒ Object
45
46
47
|
# File 'lib/deftones/analysis/fft.rb', line 45
def size
@delegate.size
end
|
#size=(value) ⇒ Object
49
50
51
|
# File 'lib/deftones/analysis/fft.rb', line 49
def size=(value)
@delegate.size = value
end
|
#smoothing ⇒ Object
53
54
55
|
# File 'lib/deftones/analysis/fft.rb', line 53
def smoothing
@delegate.smoothing
end
|
#smoothing=(value) ⇒ Object
57
58
59
|
# File 'lib/deftones/analysis/fft.rb', line 57
def smoothing=(value)
@delegate.smoothing = value
end
|