diff options
author | Eric Wong <e@80x24.org> | 2015-05-07 08:35:46 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-05-07 08:36:12 +0000 |
commit | 403ed90e2e7bed3e017938d76e17037b0d5059b6 (patch) | |
tree | 495cb9d926e25e587d941e22c7a784f94faff685 /lib/dtas/rg_state.rb | |
parent | 04d90417d3f26f0b389e58b9934941f378c92094 (diff) | |
download | dtas-403ed90e2e7bed3e017938d76e17037b0d5059b6.tar.gz |
The `gain' effect seems superior as it can "see" across the effects chain to take into account extra/lost headroom. For example, this allows me to add the the "gain -h" effect at the start of my effects chain before the RGFX placeholder in my source command, so when I play a file requiring a -6dB ReplayGain adjustment, I will only need an additional -4dB of headroom to accomodate the 10dB boost at 20Hz I use (for listening through headphones): Before: RGFX='vol -6dB' sox "$INFILE" $SOXFMT - $TRIMFX $RGFX vol -10dB equalizer 20 0.7071q 10 After: RGFX='gain -6' sox "$INFILE" $SOXFMT - $TRIMFX gain -h $RGFX equalizer 20 0.7071q 10
Diffstat (limited to 'lib/dtas/rg_state.rb')
-rw-r--r-- | lib/dtas/rg_state.rb | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/dtas/rg_state.rb b/lib/dtas/rg_state.rb index 6ab31b9..b124098 100644 --- a/lib/dtas/rg_state.rb +++ b/lib/dtas/rg_state.rb @@ -5,8 +5,10 @@ # MAYBE: account for non-standard reference loudness (89.0 dB is standard) require_relative '../dtas' require_relative 'serialize' +require_relative 'util' class DTAS::RGState # :nodoc: include DTAS::Serialize + include DTAS::Util RG_MODE = { # attribute name => method to use @@ -53,19 +55,19 @@ class DTAS::RGState # :nodoc: to_hash.delete_if { |k,v| RG_DEFAULT[k] == v } end - # returns a dB argument to the "vol" effect, nil if nothing found + # returns a dB argument to the "gain" effect, nil if nothing found def rg_vol_gain(val) val = val.to_f + @preamp return if val.abs < @gain_threshold - sprintf('vol %0.8gdB', val) + sprintf('gain %0.8g', val) end - # returns a linear argument to the "vol" effect + # returns a DB argument to the "gain" effect def rg_vol_norm(val) diff = @norm_level - val.to_f return if (@norm_level - diff).abs < @norm_threshold diff += @norm_level - sprintf('vol %0.8g', diff) + sprintf('gain %0.8g', linear_to_db(diff)) end # The ReplayGain fallback adjustment value (in dB), in case a file is @@ -77,7 +79,7 @@ class DTAS::RGState # :nodoc: val = @fallback_gain + @preamp return if val.abs < @gain_threshold warn(reason) if $DEBUG - "vol #{val}dB" + "gain #{val}" end # returns an array (for command-line argument) for the effect needed |