Module: Wavify::DSP::Headroom
- Defined in:
- lib/wavify/dsp/headroom.rb,
sig/dsp.rbs
Overview
Applies only the gain needed to keep each mixed frame within full scale.
Constant Summary collapse
- DEFAULT_SMOOTHING_SECONDS =
Default look-behind/look-ahead smoothing window for gain transitions.
0.005
Class Method Summary collapse
Class Method Details
.apply!(samples, channels:, sample_rate:, smoothing_seconds: DEFAULT_SMOOTHING_SECONDS) ⇒ Array[Numeric]
10 11 12 13 14 15 16 17 |
# File 'lib/wavify/dsp/headroom.rb', line 10 def self.apply!(samples, channels:, sample_rate:, smoothing_seconds: DEFAULT_SMOOTHING_SECONDS) smoothing = validate_smoothing!(smoothing_seconds) gains = frame_gains(samples, channels: channels, sample_rate: sample_rate, smoothing_seconds: smoothing) samples.each_index do |index| samples[index] = (samples.fetch(index) * gains.fetch(index / channels)).clamp(-1.0, 1.0) end samples end |