Class: DSP::SpectralMoments
- Inherits:
-
Data
- Object
- Data
- DSP::SpectralMoments
- Defined in:
- lib/dsprb/spectral_moments.rb,
sig/dsprb.rbs
Constant Summary collapse
- ENERGY_FLOOR =
Below this the band carries no measurable energy and the moments are undefined.
1e-12- VARIANCE_FLOOR =
1e-12- DEFAULT_LOW_HZ =
Fricative energy sits well above the voiced band, so the default window starts high.
500.0- HIGH_MARGIN_HZ =
Keeps the anti-aliasing roll-off out of the measured band.
200.0
Instance Attribute Summary collapse
-
#centroid ⇒ Object
readonly
Returns the value of attribute centroid.
-
#kurtosis ⇒ Object
readonly
Returns the value of attribute kurtosis.
-
#skewness ⇒ Object
readonly
Returns the value of attribute skewness.
-
#spread ⇒ Object
readonly
Returns the value of attribute spread.
Class Method Summary collapse
- .new ⇒ SpectralMoments
- .of(power, sample_rate:, size:, low: DEFAULT_LOW_HZ, high: nil) ⇒ Object
- .zero ⇒ SpectralMoments
Instance Method Summary collapse
Instance Attribute Details
#centroid ⇒ Object (readonly)
Returns the value of attribute centroid
4 5 6 |
# File 'lib/dsprb/spectral_moments.rb', line 4 def centroid @centroid end |
#kurtosis ⇒ Object (readonly)
Returns the value of attribute kurtosis
4 5 6 |
# File 'lib/dsprb/spectral_moments.rb', line 4 def kurtosis @kurtosis end |
#skewness ⇒ Object (readonly)
Returns the value of attribute skewness
4 5 6 |
# File 'lib/dsprb/spectral_moments.rb', line 4 def skewness @skewness end |
#spread ⇒ Object (readonly)
Returns the value of attribute spread
4 5 6 |
# File 'lib/dsprb/spectral_moments.rb', line 4 def spread @spread end |
Class Method Details
.new ⇒ SpectralMoments
338 |
# File 'sig/dsprb.rbs', line 338
def self.new: (centroid: ::Float, spread: ::Float, skewness: ::Float, kurtosis: ::Float) -> SpectralMoments
|
.of(power, sample_rate:, size:, low: DEFAULT_LOW_HZ, high: nil) ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/dsprb/spectral_moments.rb', line 17 def self.of(power, sample_rate:, size:, low: DEFAULT_LOW_HZ, high: nil) ceiling = high || ((sample_rate / 2.0) - HIGH_MARGIN_HZ) frequencies, weights, total = collect(power, sample_rate, size, low, ceiling) return zero if total <= ENERGY_FLOOR centroid = frequencies.each_with_index.sum { |frequency, index| frequency * weights[index] } / total from_central_moments(centroid, central_moments(frequencies, weights, centroid, total)) end |
.zero ⇒ SpectralMoments
15 |
# File 'lib/dsprb/spectral_moments.rb', line 15 def self.zero = new(centroid: 0.0, spread: 0.0, skewness: 0.0, kurtosis: 0.0) |
Instance Method Details
#to_h ⇒ ::Hash[::Symbol, ::Float]
349 |
# File 'sig/dsprb.rbs', line 349
def to_h: () -> ::Hash[::Symbol, ::Float]
|