Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Audio Playback, Database and Playlists
| | |-+  Would it be better for Replay Gain to be off by default?
« previous next »
  • Print
Pages: [1] 2

Author Topic: Would it be better for Replay Gain to be off by default?  (Read 13145 times)

Offline Julian67

  • Member
  • *
  • Posts: 116
Would it be better for Replay Gain to be off by default?
« on: October 05, 2012, 01:52:01 PM »
Currently a new default RockBox install is configured to have  "Track Gain If Shuffling" on.  This setting might more clearly be described as "Album Gain On Unless Shuffling".  I noticed several threads recently where people people encounter odd and apparently inexplicable issues with sound quality.  It's really hard to know what they mean without an audio sample, but it occured to me that the default in RockBox is not, as one might assume, to play back at the user set volume.  There is every chance that the level is being either raised or attenuated and the user does not even realise this and in fact may have checked the playback settings and even be confident that they have not enabled RG.  The attenuation is not such a big deal but the raising might be because the default is for no pre-amp adjustment and no clipping prevention so the potential is there to raise the level to undesirable levels and even induce clipping.

It seems that the default of RG Album Gain on with pre-amp 0 and no clipping prevention all presupposes that the user has very few, if any, albums with high positive album gain values and I began to wonder if that supposition was realistic so I examined my music collection:

I just looked at two parts of my collection, firstly Classical (includes Baroque, Early etc) and secondly Pop (includes any modern popular genre like Rock or Garage or Indie etc).

Of the 208 "Pop" albums only 5 have positive album gain and three of those are below 1 dB.  The highest is +3.35 dB.

Of the 819 "Classical" albums 518 have a positive album gain value(!) and of those 149 have an album_gain of +4 dB or higher.  There is one over 14 dB!  The albums with the higher values tend to be of single or duet stringed instruments, or choral works.

So I'm suggesting that the assumptions that led to RockBox's default RG settings might benefit from another look as they may cause problems for anyone who has a lot of unamplified or acoustic or vocal/choral music in their collection.  Btw this is not a complaint as it's no issue for me because quite a long time ago I Read The Fine Manual and discovered that just because I had never switched on RG didn't mean it was off!  But a typical new or uninformed user is not someone who has read the manual, and perhaps has never even heard of Replay Gain, and there is a chance that their music will play back with distortion and even severe clipping.
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Would it be better for Replay Gain to be off by default?
« Reply #1 on: October 05, 2012, 01:58:47 PM »
Quote from: Julian67 on October 05, 2012, 01:52:01 PM
The attenuation is not such a big deal but the raising might be because the default is for no pre-amp adjustment and no clipping prevention so the potential is there to raise the level to undesirable levels and even induce clipping.

The replaygain reference level is so low this will basically never matter. 
Logged

Offline AlexP

  • Global Moderator
  • Member
  • *
  • Posts: 3688
  • ex-BigBambi
Re: Would it be better for Replay Gain to be off by default?
« Reply #2 on: October 05, 2012, 03:52:35 PM »
I personally don't care one way or another, but would another solution be to turn on clipping prevention?
Logged
H140, F60, S120, e260, c240, Clip, Fuze v2, Connect, MP170, Meizu M3, Nano 1G, Android

Offline Julian67

  • Member
  • *
  • Posts: 116
Re: Would it be better for Replay Gain to be off by default?
« Reply #3 on: October 05, 2012, 04:41:22 PM »
Quote from: saratoga

The replaygain reference level is so low this will basically never matter.  


I can offer an example that I believe demonstrates otherwise:

First the mediainfo:

Code: [Select]
General
Complete name                            : 06 - Dulces exuviæ.ogg
Format                                   : OGG
File size                                : 6.77 MiB
Duration                                 : 4mn 50s
Overall bit rate mode                    : Variable
Overall bit rate                         : 195 Kbps
Album replay gain                        : 5.57 dB
Album replay gain peak                   : 0.982951
Album                                    : Spanish songs & vihuela solos
Track name                               : Dulces exuviæ
Track name/Position                      : 6
Performer                                : Catherine King & Jacob Heringman
Composer                                 : Alonso Mudarra
Genre                                    : Renaissance
Recorded date                            : 1997-01-01
CATEGORY                                 : classical
CDID                                     : b9104520

Audio
ID                                       : 602039608 (0x23E26538)
Format                                   : Vorbis
Format settings, Floor                   : 1
Duration                                 : 4mn 50s
Bit rate mode                            : Variable
Bit rate                                 : 224 Kbps
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 KHz
Compression mode                         : Lossy
Replay gain                              : 4.46 dB
Replay gain peak                         : 0.764122
Stream size                              : 7.75 MiB
Writing library                          : libVorbis (Everywhere) (20100325 (Everywhere))

This is ripped from my own CD to flac and subsequently encoded to Ogg Vorbis and the Replay Gain values being calculated by vorbisgain in album mode (vorbisgain -a <album_directory>)

The file: http://www.filefactory.com/file/3oy3lhxu2f59/n/06_-_Dulces_exuvi_ogg

Listen to it from 2m 0s to 2m 4s with RG album mode, no pre-amp, no clipping prevention.  Then listen with RG disabled.  There simply is no way to not notice the very unpleasant distortion even when played back with Rockbox volume level set to -20 dB.

Quote from: AlexP
I personally don't care one way or another, but would another solution be to turn on clipping prevention?

Yes, I think that would be a sane default configuration for Rockbox (probably more acceptable for some people than my original suggestion to switch it off by default) and suspect it might eliminate some of these apparently inexplicable "I tried Rockbox and it sounds bad" posts from new users.
« Last Edit: October 05, 2012, 04:43:16 PM by Julian67 »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Would it be better for Replay Gain to be off by default?
« Reply #4 on: October 05, 2012, 05:28:43 PM »
I should say almost never.  I've never seen this on music I use, but its certainly possible.  If you want, submit a patch. 
Logged

Offline Julian67

  • Member
  • *
  • Posts: 116
Re: Would it be better for Replay Gain to be off by default?
« Reply #5 on: October 05, 2012, 06:43:49 PM »
Quote from: saratoga on October 05, 2012, 05:28:43 PM
I should say almost never.  I've never seen this on music I use, but its certainly possible.  If you want, submit a patch.  

Yes but your "almost never" is based entirely on "music I use" which is an unknown quantity (except to you) and is essentially unquantifiable.  There is zero data, only an assertion or opinion.

What I tried to demonstrate is:

In a collection of modern, amplified music (rock, pop, indie, contemporary African, Cuban etc etc) then positive replay gain values are indeed seen "almost never".

In a collection containing lots of unamplified music or lots of non-orchestral "classical" music then high positive album gain values are definitely encountered and are not even unusual, they are far more usual than the negative gain values found in amplified music.  You might even call them normal or unremarkable.

I've then demonstrated that with the default Rockbox config an album gain value of 5.57 dB being applied can induce severe distortion even at low output levels.  That value of 5.57 dB is not an extreme value likely to be encountered "almost never".   63% of my classical collection has a positive album gain value and of those 97 albums have an album gain value above 4 dB, which is more than 11% of my classical collection.

A default setting in a playback app or firmware that demonstrably induces obvious audible artefacts and even severe clipping might not be a great default.  The fact that it's a reasonable setting for people whose collection is entirely or almost entirely composed of amplified music where a positive gain value is almost never seen doesn't mean that it's a reasonable global default.

I'm sorry to labour the point but it's quite difficult to engage with short assertions that seem more like obstacles than exchanges, so I just try to explain it again as clearly as I know how.

I'm unsure why you suggest to submit a patch.  What exactly would be patched?  After looking at a default .rockbox and at a source tree I'm still unsure where or how Rockbox initial default config is defined or why a patch from a user is required to do something that requires zero new code and which is transparently easy for any Rockbox developer but may be problematic for an end user.  I'm suggesting that the default config has a problem which Rockbox release manager/team/whoever might like to consider and modify if they agree.  I've identified a problem and tried to provide both information, reasoning and a practical demonstration to illustrate this beyond any doubt.  If raising the issue in the forum is not the right approach then wouldn't "file a bug report" is the next step, not "submit a patch"?

To conclude, I'll just refer back to my reply to AlexP in my previous post and apologise for disturbing you.
« Last Edit: October 05, 2012, 06:46:00 PM by Julian67 »
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Would it be better for Replay Gain to be off by default?
« Reply #6 on: October 05, 2012, 07:51:37 PM »
I mean that I don't mind if someone else wants to change it.
Logged

Offline Julian67

  • Member
  • *
  • Posts: 116
Re: Would it be better for Replay Gain to be off by default?
« Reply #7 on: October 05, 2012, 08:01:43 PM »
Ah ok..... ;D

If anyone prefers I submit a bug report please say so.  If a patch is preferred please give me a start by pointing out which file in the source tree is relevant and I will submit a badly formatted patch fully ready for rejection (hint: it's better if someone familiar with the source and the style does it).
Logged

Offline AlexP

  • Global Moderator
  • Member
  • *
  • Posts: 3688
  • ex-BigBambi
Re: Would it be better for Replay Gain to be off by default?
« Reply #8 on: October 06, 2012, 02:50:38 PM »
I don't think anyone would mind turning on clipping prevention by default.  I don't think a bug report is appropriate as a it isn't a bug per se, more a change in behaviour.

I'll have a fiddle.

Edit:  It is a one word change on one line, so easy peasy.  If none of the other devs object (can't see why they would) I'll change it soon.
« Last Edit: October 07, 2012, 07:31:28 AM by AlexP »
Logged
H140, F60, S120, e260, c240, Clip, Fuze v2, Connect, MP170, Meizu M3, Nano 1G, Android

Offline Julian67

  • Member
  • *
  • Posts: 116
Re: Would it be better for Replay Gain to be off by default?
« Reply #9 on: October 07, 2012, 08:06:39 AM »
Thanks for your time and consideration.  I hope the change will mean nobody who tries Rockbox will have sound quality issues at default settings, and hopefully there will be fewer odd "my music doesn't sound right" threads/posts/complaints.
Logged

Offline xpmule

  • Member
  • *
  • Posts: 52
Re: Would it be better for Replay Gain to be off by default?
« Reply #10 on: October 07, 2012, 07:02:22 PM »
interesting.
i make sure my collection ALWAYS has album and track gain tags.
but i don't usually use it at all but would prefer it off by default myself.
if people know what it is I'm sure they will investigate how to turn it on if needed.

i wonder though is the config for it the standard reference settings ?

in case some viewers don't know what this is about see this page maybe..
http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification

and maybe google "Loudness Wars"
Logged

Offline Julian67

  • Member
  • *
  • Posts: 116
Re: Would it be better for Replay Gain to be off by default?
« Reply #11 on: October 07, 2012, 09:33:09 PM »
Quote from: xpmule on October 07, 2012, 07:02:22 PM
interesting.
i make sure my collection ALWAYS has album and track gain tags.
but i don't usually use it at all but would prefer it off by default myself.

I do much the same.  My transcoding process is automated: it requires no effort from me to have RG data added to the metadata so it's done.  I don't usually use RG but have set up my transcode script to add RG data because it may be useful sometimes/occasionally/one day, maybe.  

Quote from: xpmule
if people know what it is I'm sure they will investigate how to turn it on if needed.

This would be my assumption as well and I do find it really surpising that such an intrusive mechanism would be on by default in any audio player.  It seems to presume that the listener listens to a random selection of amplified music.  My assumption would be that I have no idea who the listener is or what they like so vanilla makes the best default and let the person doing the tasting add the syrup.  Definitely don't hide a raw chilli pepper in the middle.

I've encountered several times the idea that RG is almost certain not to cause audible distortion/artefacts so is de facto harmless.  But this is only assured to be true for gain values of zero or lower.  I think I've demonstrated with the sample I linked that in fact RG can cause severe distortion even at a playback level well below minus 20 dB.  And that is with a track which is never, ever going to clip under normal conditions:



There seems to be a widely accepted but erroneous assumption that positive album gain values are unusual and that very high album gain values (i.e. 4 dB and higher) are almost unheard of.  But as soon as you move away from amplified music and into the arena of unamplified music then positive album gain values are the norm and very high values are found surpisingly often.

Replay Gain makes sense in a world where its application means attenuation or very tiny amplification.  But that "world view" is actually quite narrow:  there are multiple traditions of unamplified music with vast repertoires and huge numbers of recordings and listeners.  People didn't stop listening to Bach, Handel, Palestrina et al, or to Indian or Arabian classical or west African traditional music (lots of unamplified strings).  Almost all of it will have positive RG values which if applied can make some of it clip.  For anyone who listens only to amplified music this doesn't matter even a little bit, but for several billion other people it makes a difference.

RG with clip protection is a much better default than RG without, but it still poses a problem which is that the clip protection works on a per-track basis and can make big differences to the relative loudness between adjacent tracks.  There are plenty of albums which are gapless where the track split points are in effect index points in the middle of unbroken audio, and even more albums where the tracks form part of a single work (they are intended to only ever be heard together and in a particular coherent sequence).  It's really hard to think of anything positive to say about a mechanism which at a musically arbitrary point might attenuate or raise the level by several dB.

Anyway enabling clip protection is a good move as at least nobody is going to risk damaging their headphones, or find themselves pulling their buds out as quick as they can before posting a complaint about squelching, upper harmonic distortion or whatever term is currently preferred for "it sounds awful, it made me cry and my ears still hurt".

I have to go now as my new Hannah Montana Forever Soundtrack download has completed and I can't wait to make a karaoke mix and then spend the night singing along....
Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Would it be better for Replay Gain to be off by default?
« Reply #12 on: October 07, 2012, 09:55:10 PM »
You don't need to demonstrate that the 89 db reference level can cause clipping.  This has been known for over a decade. 89 db was chosen over the safer 83 db because it was extremely rare for clipping to occur and so 83 db was judged to not be worthwhile.  But it can occur, particularly if your music is mastered oddly.  Its just extremely rare.

Clipping protection isn't a bad idea, but Most clipping isn't audible and in fact nearly all modern music clips a bit in mp3 format. So if you enable it you will have less effective volume equalization but little gain except for exceptional tracks.
Logged

Offline Julian67

  • Member
  • *
  • Posts: 116
Re: Would it be better for Replay Gain to be off by default?
« Reply #13 on: October 08, 2012, 09:37:35 AM »
Quote from: saratoga
...Its just extremely rare.

Yes but that's an assertion, not a fact, and it only holds good with amplified music, which seems to have led to it being generally accepted.  My point was that with unamplified music that "extremely rare" situation is encountered a lot less rarely, and nothing has to be "mastered oddly".   "Loudness War" mastering basically doesn't exist in classical music; full dynamic range is the aim (and the norm) and the less compression the better.  Another example:

This time the positive album gain is only 1.63 dB

Code: [Select]
TITLE=God is with us
ARTIST=John Tavener
ALBUM=Byzantia
TRACKNUMBER=02
GENRE=Classical
COMPOSER=John Tavener
REPLAYGAIN_TRACK_PEAK=0.98935145
REPLAYGAIN_TRACK_GAIN=-3.15 dB
REPLAYGAIN_ALBUM_PEAK=0.98935145
REPLAYGAIN_ALBUM_GAIN=+1.63 dB



http://www.filefactory.com/file/2fmdp7je1bjx/n/02_-_God_is_with_us_ogg

This clips at about 5m 30s if album gain is applied (hard clicks in both channels), exactly as you'd expect when looking at the waveform and wondering what would happen if you added another dB or two at 5m 30s.....

And another, this time an orchestral work:

Code: [Select]
TITLE=Sinfonía Sevillana: 3
TITLE=Fiesta en San Juan de Aznalfarache
ARTIST=Orquesta Filarmonica de Gran Canaria, Adrian Leaper
ALBUM=Sinfonía Sevillana
DATE=1999-01-01
TRACKNUMBER=3
GENRE=Classical
COMPOSER=Turina
REPLAYGAIN_TRACK_PEAK=0.98125243
REPLAYGAIN_TRACK_GAIN=+1.99 dB
REPLAYGAIN_ALBUM_PEAK=0.98125243
REPLAYGAIN_ALBUM_GAIN=+3.49 dB



http://www.filefactory.com/file/58supg72nnj/n/03_-_Sinfon_a_Sevillana-_3_-_Fiesta_en_San_Juan_de_Aznalfarache_ogg

This one is more typical of what many people think of as classical music - it's orchestral and ends with a loud crescendo.  It's very loud indeed and there are lots of instruments making lots of sounds and you could probably listen to that crescendo with RG album mode and not think anything was amiss, but listening again without any RG it becomes clear that RG did indeed introduce distortion.  It isn't as obvious as hard clicks or or a soprano's voice breaking up and it's easy to see how people might describe it in various terms that are hard to quantify and hard to understand by anyone not sharing the experience.

The tracks I've used as examples are not oddly mastered or unusual repertoire.  You could go through any collection of unamplified music and find lots of albums containing tracks using a full dynamic range and for which RG processing will have applied a positive album gain higher than the track gain, at which point you've introduced the possibility of clipping.

tl ;dr summary:

It isn't extremely rare, it's only as rare as unamplified music - it's very common!

Logged

Offline saratoga

  • Developer
  • Member
  • *
  • Posts: 8974
Re: Would it be better for Replay Gain to be off by default?
« Reply #14 on: October 08, 2012, 10:46:14 AM »
Quote from: Julian67 on October 08, 2012, 09:37:35 AM
tl ;dr summary:

It isn't extremely rare, it's only as rare as unamplified music - it's very common!



Yes, but such music is just a tiny fraction of all the music out there hence the compromise.
Logged

  • Print
Pages: [1] 2
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Audio Playback, Database and Playlists
| | |-+  Would it be better for Replay Gain to be off by default?
 

  • SMF 2.0.17 | SMF © 2019, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.092 seconds with 15 queries.