Example #1
0
        public CueSheet(string cueFile)
        {
            List <CueTrack> tracks = new List <CueTrack>();

            Lines = File.ReadAllLines(cueFile).Select(l => new CueLine(l)).ToArray();
            CueTrack currentTrack = null;

            foreach (var line in Lines)
            {
                if (line.Command == "REM")
                {
                }
                else if (line.Command == "PERFORMER")
                {
                    if (currentTrack == null)
                    {
                        Performer = line[1];
                    }
                    else
                    {
                        currentTrack.Performer = line[1];
                    }
                }
                else if (line.Command == "TITLE")
                {
                    if (currentTrack == null)
                    {
                        Title = line[1];
                    }
                    else
                    {
                        currentTrack.Title = line[1];
                    }
                }
                else if (line.Command == "FILE")
                {
                    Filename = Path.Combine(Path.GetDirectoryName(cueFile), line[1]);
                }
                else if (line.Command == "TRACK")
                {
                    int track = int.Parse(line[1]);
                    if (track != tracks.Count + 1)
                    {
                        throw new FormatException();
                    }
                    currentTrack = new CueTrack();
                    tracks.Add(currentTrack);
                }
                else if (line.Command == "INDEX")
                {
                    int index = int.Parse(line[1]);

                    long time = ParseCdTime(line[2]);
                    currentTrack.Indexes[index] = time;
                }
                Tracks = tracks.ToArray();
            }
        }
Example #2
0
        public CueSheet(string cueFile)
        {
            List<CueTrack> tracks = new List<CueTrack>();
            Lines = File.ReadAllLines(cueFile).Select(l => new CueLine(l)).ToArray();
            CueTrack currentTrack = null;
            foreach (var line in Lines)
            {
                if (line.Command == "REM")
                {
                }
                else if (line.Command == "PERFORMER")
                {
                    if (currentTrack == null)
                    {
                        Performer = line[1];
                    }
                    else
                    {
                        currentTrack.Performer = line[1];
                    }
                }
                else if (line.Command == "TITLE")
                {
                    if (currentTrack == null)
                    {
                        Title = line[1];
                    }
                    else
                    {
                        currentTrack.Title = line[1];
                    }
                }
                else if (line.Command == "FILE")
                {
                    Filename = Path.Combine(Path.GetDirectoryName(cueFile), line[1]);
                }
                else if (line.Command == "TRACK")
                {
                    int track = int.Parse(line[1]);
                    if (track != tracks.Count + 1)
                    {
                        throw new FormatException();
                    }
                    currentTrack = new CueTrack();
                    tracks.Add(currentTrack);
                }
                else if (line.Command == "INDEX")
                {
                    int index = int.Parse(line[1]);

                    long time = ParseCdTime(line[2]);
                    currentTrack.Indexes[index] = time;
                }
                Tracks = tracks.ToArray();
            }
        }