Changeset 1059
- Timestamp:
- 11/11/07 15:34:25 (14 months ago)
- Location:
- trunk
- Files:
-
- 17 modified
-
Audio/Properties/CoreAudioPropertiesReader.m (modified) (2 diffs)
-
Audio/Properties/FLACPropertiesReader.m (modified) (3 diffs)
-
Audio/Properties/MonkeysAudioPropertiesReader.mm (modified) (1 diff)
-
Audio/Properties/MPEGPropertiesReader.m (modified) (2 diffs)
-
Audio/Properties/MusepackPropertiesReader.m (modified) (1 diff)
-
Audio/Properties/OggFLACPropertiesReader.m (modified) (1 diff)
-
Audio/Properties/OggVorbisPropertiesReader.m (modified) (1 diff)
-
Audio/Properties/WavPackPropertiesReader.m (modified) (1 diff)
-
AudioLibrary/AudioStreamTableView.m (modified) (1 diff)
-
AudioLibrary/SmartPlaylistCriterion.m (modified) (2 diffs)
-
AudioScrobbler/AudioScrobbler.m (modified) (1 diff)
-
Database/AudioStream.h (modified) (2 diffs)
-
Database/AudioStream.m (modified) (3 diffs)
-
Database/AudioStreamManager.m (modified) (4 diffs)
-
SQL/create_stream_table.sql (modified) (1 diff)
-
SQL/insert_stream.sql (modified) (2 diffs)
-
Utilities/CueSheetParser.m (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Audio/Properties/CoreAudioPropertiesReader.m
r868 r1059 110 110 [propertiesDictionary setValue:[NSNumber numberWithDouble:asbd.mSampleRate] forKey:PropertiesSampleRateKey]; 111 111 112 // Save sample rate for duration calcuation113 Float64 sampleRate = asbd.mSampleRate;114 115 112 // Zero out part of the asbd so we only get the format's name 116 113 asbd.mSampleRate = 0; … … 143 140 144 141 [propertiesDictionary setValue:[NSNumber numberWithLongLong:totalFrames] forKey:PropertiesTotalFramesKey]; 145 146 [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)totalFrames / sampleRate] forKey:PropertiesDurationKey]; 147 142 148 143 [self setValue:propertiesDictionary forKey:@"properties"]; 149 144 -
trunk/Audio/Properties/FLACPropertiesReader.m
r1030 r1059 94 94 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:block->data.stream_info.channels] forKey:PropertiesChannelsPerFrameKey]; 95 95 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:block->data.stream_info.sample_rate] forKey:PropertiesSampleRateKey]; 96 [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)block->data.stream_info.total_samples / block->data.stream_info.sample_rate] forKey:PropertiesDurationKey];97 96 break; 98 97 … … 140 139 [trackDictionary setValue:[NSNumber numberWithUnsignedLongLong:block->data.cue_sheet.tracks[i].offset] forKey:StreamStartingFrameKey]; 141 140 142 // Fill in frame counts and duration141 // Fill in frame counts 143 142 if(0 < i) { 144 143 unsigned frameCount = (block->data.cue_sheet.tracks[i].offset - 1) - block->data.cue_sheet.tracks[i - 1].offset; 145 144 146 145 [[cueSheetTracks objectAtIndex:(i - 1)] setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 147 [[cueSheetTracks objectAtIndex:(i - 1)] setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey];148 [[cueSheetTracks objectAtIndex:(i - 1)] setValue:[NSNumber numberWithDouble:(double)frameCount / [[propertiesDictionary valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey];149 146 } 150 147 … … 155 152 156 153 [trackDictionary setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 157 [trackDictionary setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey];158 [trackDictionary setValue:[NSNumber numberWithDouble:(double)frameCount / [[propertiesDictionary valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey];159 154 } 160 155 -
trunk/Audio/Properties/MonkeysAudioPropertiesReader.mm
r1024 r1059 63 63 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:decompressor->GetInfo(APE_INFO_CHANNELS)] forKey:PropertiesChannelsPerFrameKey]; 64 64 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:decompressor->GetInfo(APE_INFO_SAMPLE_RATE)] forKey:PropertiesSampleRateKey]; 65 [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)decompressor->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS) / decompressor->GetInfo(APE_INFO_SAMPLE_RATE)] forKey:PropertiesDurationKey];66 65 67 66 [self setValue:propertiesDictionary forKey:@"properties"]; -
trunk/Audio/Properties/MPEGPropertiesReader.m
r1053 r1059 221 221 222 222 [propertiesDictionary setValue:[NSNumber numberWithUnsignedLong:xingTotalFrames] forKey:PropertiesTotalFramesKey]; 223 [propertiesDictionary setValue:[NSNumber numberWithFloat:(xingTotalFrames / frame.header.samplerate)] forKey:PropertiesDurationKey];224 223 } 225 224 … … 342 341 343 342 [propertiesDictionary setValue:[NSNumber numberWithUnsignedLong:totalFrames] forKey:PropertiesTotalFramesKey]; 344 [propertiesDictionary setValue:[NSNumber numberWithFloat:(totalFrames / frame.header.samplerate)] forKey:PropertiesDurationKey];345 343 346 344 // For now, quit after second frame -
trunk/Audio/Properties/MusepackPropertiesReader.m
r868 r1059 93 93 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:streaminfo.channels] forKey:PropertiesChannelsPerFrameKey]; 94 94 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:streaminfo.sample_freq] forKey:PropertiesSampleRateKey]; 95 [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)mpc_streaminfo_get_length_samples(&streaminfo) / streaminfo.sample_freq] forKey:PropertiesDurationKey];96 95 97 96 if(0 != streaminfo.gain_title) -
trunk/Audio/Properties/OggFLACPropertiesReader.m
r1053 r1059 46 46 47 47 [source setValue:[NSNumber numberWithLongLong:metadata->data.stream_info.total_samples] forKeyPath:@"localProperties.totalFrames"]; 48 49 [source setValue:[NSNumber numberWithDouble:(double)metadata->data.stream_info.total_samples / metadata->data.stream_info.sample_rate] forKeyPath:@"localProperties.duration"];50 48 break; 51 49 -
trunk/Audio/Properties/OggVorbisPropertiesReader.m
r1022 r1059 90 90 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:ovInfo->channels] forKey:PropertiesChannelsPerFrameKey]; 91 91 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:ovInfo->rate] forKey:PropertiesSampleRateKey]; 92 [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)totalFrames / ovInfo->rate] forKey:PropertiesDurationKey];93 92 94 93 [self setValue:propertiesDictionary forKey:@"properties"]; -
trunk/Audio/Properties/WavPackPropertiesReader.m
r1023 r1059 56 56 [propertiesDictionary setValue:[NSNumber numberWithInt:WavpackGetNumChannels(wpc)] forKey:PropertiesChannelsPerFrameKey]; 57 57 [propertiesDictionary setValue:[NSNumber numberWithUnsignedInt:WavpackGetSampleRate(wpc)] forKey:PropertiesSampleRateKey]; 58 [propertiesDictionary setValue:[NSNumber numberWithDouble:WavpackGetAverageBitrate(wpc, YES)] forKey:PropertiesBitrateKey]; 59 [propertiesDictionary setValue:[NSNumber numberWithDouble:(double)WavpackGetNumSamples(wpc) / WavpackGetSampleRate(wpc)] forKey:PropertiesDurationKey]; 60 58 [propertiesDictionary setValue:[NSNumber numberWithDouble:WavpackGetAverageBitrate(wpc, YES)] forKey:PropertiesBitrateKey]; 61 59 62 60 [self setValue:propertiesDictionary forKey:@"properties"]; -
trunk/AudioLibrary/AudioStreamTableView.m
r963 r1059 620 620 [searchSheet setArtist:[stream valueForKey:MetadataArtistKey]]; 621 621 [searchSheet setAlbumTitle:[stream valueForKey:MetadataAlbumTitleKey]]; 622 [searchSheet setDuration:[stream valueForKey:PropertiesDurationKey]];622 [searchSheet setDuration:[stream duration]]; 623 623 624 624 [[NSApplication sharedApplication] beginSheet:[searchSheet sheet] -
trunk/AudioLibrary/SmartPlaylistCriterion.m
r953 r1059 289 289 PropertiesFileTypeKey, PropertiesDataFormatKey, PropertiesFormatDescriptionKey, 290 290 PropertiesBitsPerChannelKey, PropertiesChannelsPerFrameKey, PropertiesSampleRateKey, 291 PropertiesTotalFramesKey, PropertiesDurationKey, PropertiesBitrateKey,291 PropertiesTotalFramesKey, @"duration", PropertiesBitrateKey, 292 292 @"-", 293 293 StatisticsDateAddedKey, StatisticsFirstPlayedDateKey, StatisticsLastPlayedDateKey, StatisticsLastSkippedDateKey, … … 548 548 attributeType = NSInteger64AttributeType; 549 549 } 550 else if([keyPath isEqualToString: PropertiesDurationKey]) {550 else if([keyPath isEqualToString:@"duration"]) { 551 551 displayName = NSLocalizedStringFromTable(@"Duration", @"AudioStream", @""); 552 552 attributeType = NSDoubleAttributeType; -
trunk/AudioScrobbler/AudioScrobbler.m
r935 r1059 111 111 escapeForLastFM([stream valueForKey:MetadataAlbumTitleKey]), 112 112 escapeForLastFM([stream valueForKey:MetadataMusicBrainzIDKey]), 113 [[stream valueForKey:PropertiesDurationKey] intValue],113 [[stream duration] intValue], 114 114 escapeForLastFM([[stream valueForKey:StreamURLKey] path]) 115 115 ]]; -
trunk/Database/AudioStream.h
r1043 r1059 70 70 extern NSString * const PropertiesSampleRateKey; 71 71 extern NSString * const PropertiesTotalFramesKey; 72 extern NSString * const PropertiesDurationKey;73 72 extern NSString * const PropertiesBitrateKey; 74 73 … … 97 96 - (NSString *) pathname; 98 97 98 - (NSNumber *) duration; 99 - (NSNumber *) totalDuration; 100 99 101 - (BOOL) isPlaying; 100 102 - (void) setPlaying:(BOOL)playing; -
trunk/Database/AudioStream.m
r1053 r1059 72 72 NSString * const PropertiesSampleRateKey = @"sampleRate"; 73 73 NSString * const PropertiesTotalFramesKey = @"totalFrames"; 74 NSString * const PropertiesDurationKey = @"duration";75 74 NSString * const PropertiesBitrateKey = @"bitrate"; 76 75 … … 255 254 { 256 255 return [[self valueForKey:StreamURLKey] path]; 256 } 257 258 - (NSNumber *) duration 259 { 260 if([self isPartOfCueSheet]) 261 return [NSNumber numberWithDouble:[[self valueForKey:StreamFrameCountKey] longLongValue] / [[self valueForKey:PropertiesSampleRateKey] floatValue]]; 262 else 263 return [self totalDuration]; 264 } 265 266 - (NSNumber *) totalDuration 267 { 268 return [NSNumber numberWithDouble:[[self valueForKey:PropertiesTotalFramesKey] longLongValue] / [[self valueForKey:PropertiesSampleRateKey] floatValue]]; 257 269 } 258 270 … … 357 369 PropertiesSampleRateKey, 358 370 PropertiesTotalFramesKey, 359 PropertiesDurationKey,360 371 PropertiesBitrateKey, 361 372 -
trunk/Database/AudioStreamManager.m
r1055 r1059 791 791 getColumnValue(statement, 39, stream, PropertiesSampleRateKey, eObjectTypeDouble); 792 792 getColumnValue(statement, 40, stream, PropertiesTotalFramesKey, eObjectTypeLongLong); 793 getColumnValue(statement, 41, stream, PropertiesDurationKey, eObjectTypeDouble); 794 getColumnValue(statement, 42, stream, PropertiesBitrateKey, eObjectTypeDouble); 793 getColumnValue(statement, 41, stream, PropertiesBitrateKey, eObjectTypeDouble); 795 794 796 795 // Register the object … … 868 867 bindParameter(statement, 39, stream, PropertiesSampleRateKey, eObjectTypeDouble); 869 868 bindParameter(statement, 40, stream, PropertiesTotalFramesKey, eObjectTypeLongLong); 870 bindParameter(statement, 41, stream, PropertiesDurationKey, eObjectTypeDouble); 871 bindParameter(statement, 42, stream, PropertiesBitrateKey, eObjectTypeDouble); 869 bindParameter(statement, 41, stream, PropertiesBitrateKey, eObjectTypeDouble); 872 870 873 871 result = sqlite3_step(statement); … … 971 969 bindNamedParameter(statement, ":sample_rate", stream, PropertiesSampleRateKey, eObjectTypeDouble); 972 970 bindNamedParameter(statement, ":total_frames", stream, PropertiesTotalFramesKey, eObjectTypeLongLong); 973 bindNamedParameter(statement, ":duration", stream, PropertiesDurationKey, eObjectTypeDouble);974 971 bindNamedParameter(statement, ":bitrate", stream, PropertiesBitrateKey, eObjectTypeDouble); 975 972 … … 1082 1079 PropertiesSampleRateKey, 1083 1080 PropertiesTotalFramesKey, 1084 PropertiesDurationKey,1085 1081 PropertiesBitrateKey, 1086 1082 -
trunk/SQL/create_stream_table.sql
r1025 r1059 47 47 'sample_rate' REAL, 48 48 'total_frames' INTEGER, 49 'duration' REAL,50 49 'bitrate' REAL, 51 50 -
trunk/SQL/insert_stream.sql
r1025 r1059 46 46 sample_rate, 47 47 total_frames, 48 duration,49 48 bitrate 50 49 … … 98 97 ?, 99 98 ?, 100 ?,101 99 ? 102 100 -
trunk/Utilities/CueSheetParser.m
r1053 r1059 330 330 previousTrack = [cueSheetTracks objectAtIndex:(i - 1)]; 331 331 332 // Fill in frame counts and duration332 // Fill in frame counts 333 333 if(nil != previousTrack && [[previousTrack valueForKey:StreamURLKey] isEqual:[thisTrack valueForKey:StreamURLKey]]) { 334 334 unsigned frameCount = ([[thisTrack valueForKey:StreamStartingFrameKey] longLongValue] - 1) - [[previousTrack valueForKey:StreamStartingFrameKey] longLongValue]; 335 335 336 336 [previousTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 337 [previousTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey];338 [previousTrack setValue:[NSNumber numberWithDouble:(double)frameCount / [[thisTrack valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey];339 337 } 340 338 … … 344 342 345 343 [thisTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:StreamFrameCountKey]; 346 [thisTrack setValue:[NSNumber numberWithUnsignedInt:frameCount] forKey:PropertiesTotalFramesKey];347 [thisTrack setValue:[NSNumber numberWithDouble:(double)frameCount / [[thisTrack valueForKey:PropertiesSampleRateKey] floatValue]] forKey:PropertiesDurationKey];348 344 } 349 345 }
