Beispiel #1
0
        public static string GetTrackLength(CueSheetTrack currentTrack, CueSheetTrack nextTrack)
        {
            var currentTrackPosition = CueSheetIndex.ToTimeSpan(currentTrack.Index.Time);
            var nextTrackPosition    = CueSheetIndex.ToTimeSpan(nextTrack.Index.Time);
            var trackLength          = nextTrackPosition - currentTrackPosition;

            return(CueSheetIndex.FromTimeSpan(trackLength));
        }
Beispiel #2
0
        private void OnParseFile(string[] lines, ref int position, IList <CueSheetFile> files, IList <CueSheetTag> tags)
        {
            var line = lines[position].Trim();
            var path = line.Substring(
                line.IndexOf(' '),
                line.LastIndexOf(' ') - line.IndexOf(' ')
                ).Trim(new[] { '"', ' ' });
            var format = line.Substring(
                line.LastIndexOf(' ')
                ).Trim();
            var tracks       = new List <CueSheetTrack>();
            var trackNumber  = default(string);
            var trackType    = default(string);
            var trackIndexes = new List <CueSheetIndex>();
            var trackTags    = new List <CueSheetTag>();

            for (position = position + 1; position < lines.Length; position++)
            {
                line = lines[position].Trim();
                var parts = line.Split(new[] { ' ' }, 3);
                if (parts.Length < 2)
                {
                    continue;
                }
                switch (parts[0].ToUpper())
                {
                case REM:
                    this.OnParseTag(lines, ref position, files, trackTags);
                    break;

                case TITLE:
                case PERFORMER:
                case SONGWRITER:
                    this.OnParseTag(lines, ref position, files, trackTags);
                    break;

                case ISRC:
                    //TODO: Should we do something with this? International Standard Recording Code.
                    break;

                case FLAGS:
                    //TODO: Should we do something with this? Copy protection, multi channel...
                    break;

                case TRACK:
                    if (!string.IsNullOrEmpty(trackNumber) && !string.IsNullOrEmpty(trackType) && trackIndexes.Count > 0)
                    {
                        var track = new CueSheetTrack(
                            trackNumber,
                            trackType,
                            trackIndexes,
                            trackTags
                            );
                        tracks.Add(track);
                    }
                    trackNumber  = default(string);
                    trackType    = default(string);
                    trackIndexes = new List <CueSheetIndex>();
                    trackTags    = new List <CueSheetTag>();
                    if (parts.Length == 3)
                    {
                        trackNumber = parts[1];
                        trackType   = parts[2];
                    }
                    break;

                case INDEX:
                    if (parts.Length == 3)
                    {
                        var indexPosition = parts[1];
                        var indexTime     = parts[2];
                        var index         = new CueSheetIndex(
                            indexPosition,
                            indexTime
                            );
                        trackIndexes.Add(index);
                    }
                    break;

                default:
                    position--;
                    goto done;
                }
            }
done:
            if (!string.IsNullOrEmpty(trackNumber) && !string.IsNullOrEmpty(trackType) && trackIndexes.Count > 0)
            {
                var track = new CueSheetTrack(
                    trackNumber,
                    trackType,
                    trackIndexes,
                    trackTags
                    );
                tracks.Add(track);
            }
            var file = new CueSheetFile(path, format, tracks);

            files.Add(file);
        }
Beispiel #3
0
 public BassCueStreamAdvice(string fileName, string offset, string length) : base(fileName)
 {
     this.Offset = CueSheetIndex.ToTimeSpan(offset);
     this.Length = CueSheetIndex.ToTimeSpan(length);
 }