CueSheet input: Implement support for ReplayGain tags
parent
59aea2966f
commit
dac1dfee47
|
@ -105,6 +105,11 @@
|
|||
NSString *title = nil;
|
||||
NSString *genre = nil;
|
||||
NSString *year = nil;
|
||||
|
||||
float albumGain = 0.0f;
|
||||
float albumPeak = 0.0f;
|
||||
float trackGain = 0.0f;
|
||||
float trackPeak = 0.0f;
|
||||
|
||||
BOOL trackAdded = NO;
|
||||
|
||||
|
@ -190,7 +195,11 @@
|
|||
album:album
|
||||
title:title
|
||||
genre:genre
|
||||
year:year]];
|
||||
year:year
|
||||
albumGain:albumGain
|
||||
albumPeak:albumPeak
|
||||
trackGain:trackGain
|
||||
trackPeak:trackPeak]];
|
||||
trackAdded = YES;
|
||||
}
|
||||
else if ([command isEqualToString:@"PERFORMER"])
|
||||
|
@ -253,6 +262,26 @@
|
|||
continue;
|
||||
}
|
||||
}
|
||||
else if ([type hasPrefix:@"REPLAYGAIN_"])
|
||||
{
|
||||
NSString *rgTag = nil;
|
||||
if (![scanner scanUpToCharactersFromSet:whitespace intoString:&rgTag])
|
||||
continue;
|
||||
if ([type hasPrefix:@"REPLAYGAIN_ALBUM_"])
|
||||
{
|
||||
if ([type hasSuffix:@"GAIN"])
|
||||
albumGain = [rgTag floatValue];
|
||||
else if ([type hasSuffix:@"PEAK"])
|
||||
albumPeak = [rgTag floatValue];
|
||||
}
|
||||
else if ([type hasPrefix:@"REPLAYGAIN_TRACK_"])
|
||||
{
|
||||
if ([type hasSuffix:@"GAIN"])
|
||||
trackGain = [rgTag floatValue];
|
||||
else if ([type hasSuffix:@"PEAK"])
|
||||
trackPeak = [rgTag floatValue];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,10 @@
|
|||
[NSNumber numberWithInt:[[track track] intValue]], @"track",
|
||||
[track genre], @"genre",
|
||||
[NSNumber numberWithInt:[[track year] intValue]], @"year",
|
||||
[NSNumber numberWithFloat:[track albumGain]], @"replayGainAlbumGain",
|
||||
[NSNumber numberWithFloat:[track albumPeak]], @"replayGainAlbumPeak",
|
||||
[NSNumber numberWithFloat:[track trackGain]], @"replayGainTrackGain",
|
||||
[NSNumber numberWithFloat:[track trackPeak]], @"replayGainTrackPeak",
|
||||
nil];
|
||||
|
||||
return [fileMetadata dictionaryByMergingWith:cuesheetMetadata];
|
||||
|
|
|
@ -18,12 +18,17 @@
|
|||
NSString *title;
|
||||
NSString *genre;
|
||||
NSString *year;
|
||||
|
||||
float albumGain;
|
||||
float albumPeak;
|
||||
float trackGain;
|
||||
float trackPeak;
|
||||
|
||||
double time; //Starting time for the track
|
||||
}
|
||||
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y;
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y;
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y albumGain:(float)albumGain albumPeak:(float)albumPeak trackGain:(float)trackGain trackPeak:(float)trackPeak;
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y albumGain:(float)albumGain albumPeak:(float)albumPeak trackGain:(float)trackGain trackPeak:(float)trackPeak;
|
||||
|
||||
|
||||
- (NSString *)track;
|
||||
|
@ -34,6 +39,11 @@
|
|||
- (NSString *)genre;
|
||||
- (NSString *)year;
|
||||
|
||||
- (float)albumGain;
|
||||
- (float)albumPeak;
|
||||
- (float)trackGain;
|
||||
- (float)trackPeak;
|
||||
|
||||
- (double)time;
|
||||
|
||||
@end
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
|
||||
@implementation CueSheetTrack
|
||||
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y
|
||||
+ (id)trackWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y albumGain:(float)albumGain albumPeak:(float)albumPeak trackGain:(float)trackGain trackPeak:(float)trackPeak
|
||||
{
|
||||
return [[CueSheetTrack alloc] initWithURL:u track:t time:s artist:a album:b title:l genre:g year:y];
|
||||
return [[CueSheetTrack alloc] initWithURL:u track:t time:s artist:a album:b title:l genre:g year:y albumGain:albumGain albumPeak:albumPeak trackGain:trackGain trackPeak:trackPeak];
|
||||
}
|
||||
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y
|
||||
- (id)initWithURL:(NSURL *)u track:(NSString *)t time:(double)s artist:(NSString *)a album:(NSString *)b title:(NSString *)l genre:(NSString *)g year:(NSString *)y albumGain:(float)albumGain albumPeak:(float)albumPeak trackGain:(float)trackGain trackPeak:(float)trackPeak
|
||||
{
|
||||
self = [super init];
|
||||
if (self)
|
||||
|
@ -30,6 +30,11 @@
|
|||
year = [y copy];
|
||||
|
||||
time = s;
|
||||
|
||||
self->albumGain = albumGain;
|
||||
self->albumPeak = albumPeak;
|
||||
self->trackGain = trackGain;
|
||||
self->trackPeak = trackPeak;
|
||||
}
|
||||
|
||||
return self;
|
||||
|
@ -75,6 +80,26 @@
|
|||
return year;
|
||||
}
|
||||
|
||||
- (float) albumGain
|
||||
{
|
||||
return albumGain;
|
||||
}
|
||||
|
||||
- (float) albumPeak
|
||||
{
|
||||
return albumPeak;
|
||||
}
|
||||
|
||||
- (float) trackGain
|
||||
{
|
||||
return trackGain;
|
||||
}
|
||||
|
||||
- (float) trackPeak
|
||||
{
|
||||
return trackPeak;
|
||||
}
|
||||
|
||||
-(NSString *) description {
|
||||
return [NSString stringWithFormat:@"CueSheetTrack{track: %@, url: %@, artist: %@, album: %@, title: %@, genre: %@, year: %@}", track, [url absoluteURL], artist, album, title, genre, year];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue