Bug 2793 - Smart Gain - Unexpected behavior when gain value set to 0dB
: Smart Gain - Unexpected behavior when gain value set to 0dB
Status: RESOLVED FIXED
Product: Logitech Media Server
Classification: Unclassified
Component: Audio
: 6.2.2
: PC Windows XP
: P2 normal with 2 votes (vote)
: ---
Assigned To: Dan Sully
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-01-07 17:15 UTC by yann oehl
Modified: 2008-09-15 14:38 UTC (History)
2 users (show)

See Also:
Category: ---


Attachments
check for defined album gain (573 bytes, patch)
2006-01-08 02:52 UTC, KDF
Details | Diff
d_source and d_source logs (14.60 KB, text/plain)
2006-01-11 18:53 UTC, yann oehl
Details
metaflac --list output (3.93 KB, text/plain)
2006-01-12 06:56 UTC, yann oehl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description yann oehl 2006-01-07 17:15:24 UTC
If Album-Gain is set to either 0 dB or +0 dB, No "volume ajustment" value is diplayed  via the player UI. In addition, the Smart Gain routine seems to fall back to track gain in this percieved absence of Album-Gain tags (when playing an album) which is IMHO not expected or desirable behavior.
Comment 1 Craig Garnett 2006-01-08 02:34:56 UTC
Recent builds of Slimserver have started reading J River Media centre gain tags so I don't need to process my flac's with Foobar anymore, Unfortunately MediaCentre calculates Album Gain on the fly and doesn't place it in the tags. This is where the fall back to using track gain is causing a problem.
Comment 2 KDF 2006-01-08 02:52:24 UTC
Created attachment 1093 [details]
check for defined album gain

well, assuming that albumgain is undefined, rather than defaulted to zero, then the attached might solve both.  Given an albumgain of 0, the existing code would indeed seem to fall back to track gain.  checking for a defined value will allow zero to be considered valid
Comment 3 yann oehl 2006-01-09 13:26:12 UTC
Thanks KDF. I'll plop this in my plugins directory tonight... I assume that's where it should live? BTW: Thanks for cranking this out so quickly! 
Q: Is the plan to evetually roll this into the build after some testing?
Comment 4 KDF 2006-01-09 17:05:19 UTC
you would need to run the slimserver.pl version with activestate installed, in order to make this patch work since it is in the core server code. Assuming 6.5b1 does the same thing, I could put this into that nightly for testing.  6.2.2 has to hold off until at least some confirmation comes through.
Comment 5 KDF 2006-01-09 20:41:29 UTC
committed to trunk at change 5591.  This will now be included in the 6.5 build for Jan 10.  Please test and confirm so that this can be considered for 6.2.2

Craig, this patch will not help with JRiver's on-the-fly gains.  You will have to file this as a separate enhancement request.
Comment 6 KDF 2006-01-10 00:57:49 UTC
merged to 6.2.2 at change 5597 on Dan's clearance. marking as fixed.  please confirm for Jan 11 build, reopen if needed or open new bugs for new issues. 
Comment 7 Craig Garnett 2006-01-10 09:43:47 UTC
That seems fine for me in the 6.5b build, tracks with an album gain of 0dB show in the web ui as such and play correctly. Tracks without an Album Gain tag play at 0dB although this is not indicated in the UI.

Thanks for your quick work KDF
Comment 8 yann oehl 2006-01-11 07:32:23 UTC
Bug still appears unresolved as of SlimServer Version: 6.2.2 - 5606 - Windows XP - EN - cp1252 (SlimServer_v2006-01-11)
Comment 9 KDF 2006-01-11 08:24:50 UTC
maybe try 6.5, though there should be no difference.  Also make sure that the album_gain is actually defined as zero.  An undefined album gain will still fall to track gain. try d_source debugging to check, but there may not be enough reporting on replay gain values in there.
Comment 10 Craig Garnett 2006-01-11 09:44:07 UTC
I set all my tags to 0dB but Foobar has saved them as +0.00 dB but they show up ok in the web UI on 6.5b1 not tried 6.2.2 though.

KDF - The testing I did of albums without Album gain tags seemed to indicate that they were playing back at 0dB rather than falling back to the track gain.
Comment 11 yann oehl 2006-01-11 10:31:46 UTC
(In reply to comment #9)
> maybe try 6.5, though there should be no difference.  Also make sure that the
> album_gain is actually defined as zero.  An undefined album gain will still
> fall to track gain. try d_source debugging to check, but there may not be
> enough reporting on replay gain values in there.
> 

I couldn't get 6.5b to run (server crash). My album-gain tags are set to "0 dB" and "+0 dB"... but I haven't tried "+0.00". I give that a go, and run a d_source log tonight. Thanks for the help KDF.
Comment 12 yann oehl 2006-01-11 18:53:53 UTC
Created attachment 1097 [details]
d_source and d_source logs

So far I've tried 0,+0, and +0.00 all without results in the 1/11 6.22 nightly. I've attached my logs.
Comment 13 KDF 2006-01-11 19:08:41 UTC
can you grab metaflac output for F:/Music/FLAC/ABBA/ABBA%20Gold/01-Dancing%20Queen.flac?

unfortunately, there seems to be no real debug info for tracking replaygain in use.
Comment 14 yann oehl 2006-01-11 20:44:27 UTC
(In reply to comment #13)
> can you grab metaflac output for
> F:/Music/FLAC/ABBA/ABBA%20Gold/01-Dancing%20Queen.flac?
> 
> unfortunately, there seems to be no real debug info for tracking replaygain in
> use.
> 

What's the command line switch for that?
Comment 15 KDF 2006-01-11 20:54:21 UTC
metaflac --list <file>
it is a separate tool from flac.exe, you may have to google and download a copy.
otherwise, does the songinfo page show the album/track gain? screenshots would be fine.  If Dan doesn't have any ideas on why this code change doesn't fix things for 6.2, then I'll put in some debug lines.  I really can't see any reason why 0 album gain would fail, unless you are in some sort of situation where the track is not getting album gain regardless.  You could try setting to to non-zero and see what happens.
Comment 16 yann oehl 2006-01-12 06:56:36 UTC
Created attachment 1098 [details]
metaflac --list output
Comment 17 yann oehl 2006-01-12 07:00:28 UTC
(In reply to comment #16)
> Created an attachment (id=1098) [edit]
> metaflac --list output
> 

Metaflac output attached. Also, "+0.01" shows up just fine in both the Player abd web UI... so the field is being read. Q: Could the update have simply not made it into the 6.2.2 1/11 nightly?
Comment 18 KDF 2006-01-12 09:26:28 UTC
It should have, but updating won't really hurt anyway.
Comment 19 yann oehl 2006-01-12 09:31:22 UTC
(In reply to comment #18)
> It should have, but updating won't really hurt anyway.
> 

Updated to 1/12. Still unresolved. I'd love to try 6.5... but it absolutely will not load on my rig (neither the exe or .pl). But that's another bug for another day... so far I'm sticking with 6.2.2 until 6.5 is fully baked.
Comment 20 KDF 2006-01-12 09:41:53 UTC
6.5 should be working just fine.  If you have an issue, you had best report it or post the event viewer entry for the crash.  otherwise, when it is released, you will still be unable to use it unless someone else has the same crash. 
Comment 21 yann oehl 2006-01-12 10:04:42 UTC
(In reply to comment #20)
> 6.5 should be working just fine.  If you have an issue, you had best report it
> or post the event viewer entry for the crash.  otherwise, when it is released,
> you will still be unable to use it unless someone else has the same crash. 
> 

KDF, Ok, I'll post the event viewer log. Is there any way to get debug info from SS when the exe refuses to load? I thought I remembered you mentioning a command line switch that could be added to slim.exe itself (?) BTW: When I loaded the pl, I got some messages on screen about errors in CUE files (bad links)... but I assumed these were just informational. Has handling of CUE's changed dramatically from 6.2? Regardless, I'll post results of this as a seperate bug.
Comment 22 Craig Garnett 2006-01-12 10:08:02 UTC
I've just installed the 1/12 builds of both versions and it looks like neither of them are picking up my 0dB tags anymore
Comment 23 KDF 2006-01-12 10:32:37 UTC
Yann,
c:\program files\slimserver\slim.exe, run from command prompt will show you any reasons why it won't load.  

Craig, nothing has changed in 6.5 regarding this feature since the fix. 


I guess I'll put in some debugs for 6.5 so that I'm not continuing to use up my time with no real details on the exact results in software.
Comment 24 Craig Garnett 2006-01-12 15:48:29 UTC
I think I'm getting somewhere here, unless there is a flac format track gain tag in the file, the album gain does not get picked up if it is 0, If I have a Media centre replay gain tag and a flac album tag set to 0, the album gain is ignored.

I'm not sure what format Yann is using but I'd guess it's flac's that don't have a track gain set.



Comment 25 KDF 2006-01-12 16:15:13 UTC
ok, so we're looking at combined logic from several different places not coming together right.  This is part of why this is always such a high learning curve.  Ok, so the logic for choosing track/vs album gain should be right.  If there IS a gain, and the playback is "album mode" then album gain.

album mode is determined by some fancy scheme once used in the transition plugin.   However, a simple case of a single track should always return true, thus causing album gain to be use.  Given that (and given I'm reading code correctly) effort should focus on the single track playlist for testing.

Now, the other logic is whether the album object is being given any gain values.  if the 0db isn't showing up in song info for album gain, then there is no way any fixes I've done will work.  All I did was fix it so that 0 is still "true" for the conditions of the above.  If the album gain isn't in songinfo, we can focus on what grabs/retrieves the data.  Hope that makes sense. 

d_info log output when scanning a given flac file then?  I guess I'll try and figure out how to set a test case.  All I have so far is automatic tools that don't allow me to force a zero, but metaflac must be able to somehow.
Comment 26 Dan Sully 2006-01-12 16:21:00 UTC
Can someone please upload a problem file to:

ftp://electricrain.com/incoming/

Thanks.
Comment 27 KDF 2006-01-12 16:30:58 UTC
DBIStore.pm Line 1928 (6.5b1), I expect should change from:
	if (defined $attributes->{$gainTag}) {
to:
	if ($attributes->{$gainTag}) {

so that the value is $set even with a 0, instead of marked undef.
Comment 28 yann oehl 2006-01-12 17:44:43 UTC
(In reply to comment #26)
> Can someone please upload a problem file to:
> 
> ftp://electricrain.com/incoming/
> 
> Thanks.
>
Dan,
I'll try and post a short one this eve... but I don't think the problem lives with the track itself.

Re Replaygain beviour:
According to http://www.replaygain.org/ (If Replay Gain information is absent)

"If the file only contains one of the Replay Gain adjustments (e.g. Audiophile) but the user has requested the other (Radio), then the player should use the one that is available (in this case, Audiophile)."

i'm not sure I agree with the above... but it's the "official" spec. With this in mind, let me summarize my understanding of the desired behaviour for replay-gain:

If: Volume adjustment set to "track" in SS.
Album_gain tags are initially ignored.
Track_gain if present is used. 0 dB, +0 db, +0.00, dB etc. all count as valid "settings" (=not= as "undefined"). If no value exists in the replaygain_album_gain= field, or if the tag itself is missing, then track volume ajustment is considered "undefined". If undefined, album_gain (if present) is used.

If: Volume adjustment set to "album" in SS.
Track_gain tags are initially ignored.
Album_gain if present is used. 0 dB, +0 db, +0.00, dB etc. all count as valid "settings" (=not= as "undefined"). If no interger exists in the "replaygain_album_gain=" field, or if the tag itself is missing, then album volume ajustment is considered "undefined". If undefined, track_gain (if present) is used.

If: Volume adjustment set to "smart" in SS.
Fancy algorithm determines which of the above (album or track) applies.

Is that right? Makes sense to me.
Comment 29 yann oehl 2006-01-13 07:38:18 UTC
(In reply to comment #25)
> I guess I'll try and
> figure out how to set a test case.  All I have so far is automatic tools that
> don't allow me to force a zero, but metaflac must be able to somehow.
> 
KDF, Foobar2000 and MP3tag (both freeware) allow you to specify replay gain manually. 
Comment 30 Craig Garnett 2006-01-13 12:53:46 UTC
Dan, I've uploaded a couple of tracks
test1 has both Track and Album tags
test2 only has an Album tag

One other thing I have noticed is that if you view test1 it shows the album gain in the UI but if you refresh and go back into the track info then the album gain has dissapeared

Craig
Comment 31 yann oehl 2006-01-13 13:10:34 UTC
(In reply to comment #30)
> Dan, I've uploaded a couple of tracks
> Craig
> 

Dan,
I've uploaded a track called "college.flac" which is set to 0.01 dB, and as such =does= display in both the web and player UI. 0.00 does not.
Comment 32 yann oehl 2006-02-03 15:23:27 UTC
Temporary workaround:
setting Album_Gain to +0.001 will cause the player/web UI to display the album volume ajustment as 0.00, and will behave as expected (that is, as if set to "0") when using "smart gain". Haven't tried setting it to 0.0001, etc. 

Q: Does slimserver actually apply replaygain at this level of granularity, or is 0.001 effectively 0?
Comment 33 Dan Sully 2006-04-21 16:52:30 UTC
While the data for playback has been fixed for a while, I've just checked in change 7029 - which fixes the display on the songinfo page.

This will be in the 2006-04-22 nightly builds.

Thanks.