From 8e5c62f18501aa22d18aff1c363c9853258f730f Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 22 Jan 2022 20:44:06 -0800 Subject: [PATCH] Info Inspector: Now displays ReplayGain info as tooltip for status text --- Base.lproj/InfoInspector.xib | 1 + Playlist/PlaylistEntry.h | 2 ++ Playlist/PlaylistEntry.m | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/Base.lproj/InfoInspector.xib b/Base.lproj/InfoInspector.xib index 8739c863e..c961d69ff 100644 --- a/Base.lproj/InfoInspector.xib +++ b/Base.lproj/InfoInspector.xib @@ -335,6 +335,7 @@ + diff --git a/Playlist/PlaylistEntry.h b/Playlist/PlaylistEntry.h index 9b5eaec52..40c5efd0a 100644 --- a/Playlist/PlaylistEntry.h +++ b/Playlist/PlaylistEntry.h @@ -153,6 +153,8 @@ @property(readonly) NSString *gainCorrection; +@property(readonly) NSString *gainInfo; + @property double currentPosition; @property(retain) NSString *endian; diff --git a/Playlist/PlaylistEntry.m b/Playlist/PlaylistEntry.m index 141319683..fd7573155 100644 --- a/Playlist/PlaylistEntry.m +++ b/Playlist/PlaylistEntry.m @@ -137,6 +137,11 @@ return [NSSet setWithObjects:@"replayGainAlbumGain", @"replayGainAlbumPeak", @"replayGainTrackGain", @"replayGainTrackPeak", @"volume", nil]; } ++ (NSSet *)keyPathsForValuesAffectingGainInfo +{ + return [NSSet setWithObjects:@"replayGainAlbumGain", @"replayGainAlbumPeak", @"replayGainTrackGain", @"replayGainTrackPeak", @"volume", nil]; +} + - (NSString *)description { return [NSString stringWithFormat:@"PlaylistEntry %li:(%@)", self.index, self.URL]; @@ -362,7 +367,7 @@ else return @"Track Gain"; } - else if (volume) + else if (volume && volume != 1) { return @"Volume scale"; } @@ -372,6 +377,33 @@ } } +@dynamic gainInfo; +- (NSString *)gainInfo +{ + NSMutableArray * gainItems = [[NSMutableArray alloc] init]; + if (replayGainAlbumGain) + { + [gainItems addObject:[NSString stringWithFormat:@"Album Gain: %+.2f dB", replayGainAlbumGain]]; + } + if (replayGainAlbumPeak) + { + [gainItems addObject:[NSString stringWithFormat:@"Album Peak: %.6f", replayGainAlbumPeak]]; + } + if (replayGainTrackGain) + { + [gainItems addObject:[NSString stringWithFormat:@"Track Gain: %+.2f dB", replayGainTrackGain]]; + } + if (replayGainTrackPeak) + { + [gainItems addObject:[NSString stringWithFormat:@"Track Peak: %.6f", replayGainTrackPeak]]; + } + if (volume && volume != 1) + { + [gainItems addObject:[NSString stringWithFormat:@"Volume Scale: %.2f%C", volume, (unichar)0x00D7]]; + } + return [gainItems componentsJoinedByString:@"\n"]; +} + @dynamic positionText; - (NSString *)positionText {