Пример #1
0
        /// <summary>
        /// Create a new cuesheet from scratch
        /// </summary>
        static void NewCueSheet()
        {
            CueSheet cue = new CueSheet();

            //Album performer
            cue.Performer = "Rotterdam Philharmonic Orchestra";
            //Album title
            cue.Title = "Edo de Waart / Rachmaninoff: The 3 Symphonies, The Rock - Disc 1";

            //Create 1st track, with a filename that future tracks will inherit
            cue.AddTrack("Symphony No. 2 in E minor, Op. 27: I. Largo - Allegro moderato", "", "CDImage.ape", FileType.WAVE);
            cue.AddIndex(0, 0, 0, 0, 0);
            cue.AddIndex(0, 1, 0, 0, 33);

            //Create 2nd track, with optional 'Performance' field used
            cue.AddTrack("II. Allegro molto", "Fake G. Uy: Timpani");
            cue.AddIndex(1, 0, 18, 39, 33);
            cue.AddIndex(1, 2, 22, 14, 10); //add another index we'll delete later
            cue.AddIndex(1, 1, 18, 44, 25);

            //Create 3rd track
            cue.AddTrack("III. Adagio", "");
            cue.AddIndex(2, 0, 27, 56, 33);
            cue.AddIndex(2, 1, 27, 59, 40);

            //Create 4th track using a method that gives us more control over the data
            Track tempTrack = new Track(4, DataType.AUDIO);
            tempTrack.Title = "IV. Allegro vivace";
            tempTrack.ISRC = "0000078652395";
            tempTrack.AddFlag(Flags.CH4);
            tempTrack.AddIndex(0, 41, 57, 33);
            tempTrack.AddIndex(1, 42, 00, 60);
            cue.AddTrack(tempTrack);

            //Create 5th track we'll delete later
            cue.AddTrack("Symphony No. Infinity", "Rachmaninoff's Dog");

            //Remove the bad index from the 2nd track
            cue.RemoveIndex(1, 1);//(trackIndex, indexIndex)
            //Notice the index (array-wise) of the Index (cuesheet min/sec/frame) is '1'
            //but the Index Number is 2. This is to show that index and the Index Number are
            //not the same thing and may or may not be equal.

            //Remove the 5th track
            cue.RemoveTrack(4);

            Console.WriteLine(cue.ToString());
            cue.SaveCue("newCDImage.cue");
        }
Пример #2
0
        private void openCue_Click(object sender, EventArgs e)
        {
            StartTimer();

            OpenFileDialog dialog = new OpenFileDialog();
            dialog.InitialDirectory = folderTree.ActiveNode.FullPath.Replace(folderTree.ActiveNode.RootNode.FullPath + "\\", "");

            dialog.Filter = "CUE'sheet lists (*.cue)|*.cue|Text sheet Files (*.txt)|*.txt";
            dialog.Title = "Select CUE'sheet to open";

            if (dialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    CueSheet sheet = new CueSheet(dialog.FileName);
                    string artist = sheet.Performer;
                    string album = sheet.Title;

                    CueSharp.Track[] tracks = sheet.Tracks;

                    //TagLib.File tagFile = TagLib.File.Create(dialog.FileName);
                    //TimeSpan totalTime = new TimeSpan(tagFile.Length);

                    TimeSpan totalTime = new TimeSpan();
                    TimeSpan totalTrackTime = new TimeSpan();
                    int totalTracks = tracks.Length;

                    bool readFile = false;

                    try
                    {
                        TagLib.File tagFile = TagLib.File.Create(Path.GetDirectoryName(dialog.FileName) + "\\" + tracks[0].DataFile.Filename);
                        totalTime = tagFile.Properties.Duration;
                        readFile = true;
                    }
                    catch
                    {
                    }

                    foreach (object item in tracks)
                    {
                        try
                        {
                            CueSharp.Track track = (CueSharp.Track)item;

                            ArrayList subItemValues = new ArrayList();

                            subItemValues.Add(track.Title);
                            subItemValues.Add(track.Performer);
                            subItemValues.Add(album);

                            TimeSpan trackTime = new TimeSpan();

                            if (track.TrackNumber != totalTracks)
                            {
                                trackTime = new TimeSpan(0, tracks[track.TrackNumber].Indices[0].Minutes - track.Indices[0].Minutes, tracks[track.TrackNumber].Indices[0].Seconds - track.Indices[0].Seconds);
                            }
                            else if(readFile)
                                trackTime = new TimeSpan(0, totalTime.Minutes - totalTrackTime.Minutes, totalTime.Seconds - totalTrackTime.Seconds);
                            else trackTime = new TimeSpan(0, totalTrackTime.Minutes/totalTracks, totalTrackTime.Seconds/totalTracks);

                            totalTrackTime = totalTrackTime.Add(trackTime);

                            subItemValues.Add(trackTime.ToString());
                            subItemValues.Add(1);

                            UltraListViewItem listTrack = new UltraListViewItem("CUE'sheet item", subItemValues.ToArray());
                            trackList.Items.Add(listTrack);
                        }
                        catch (Exception exp)
                        {
                            //errors.Add(((UltraListViewItem)file).Value.ToString() + " : " + exp.Message.ToString());
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Ook!");
                }
            }

            UpdateStats();

            StopTimer();
        }
Пример #3
0
        public static IPlaylist Import(string basePath, StreamReader reader)
        {
            var playlist = new NormalPlaylist();

            var cue = new CueSheet(reader);

            if (cue.Tracks.Length == 0 || cue.Tracks[0].DataFile.Filename == null)
                return null;

            var genre = string.Empty;
            var year = 0u;
            if (cue.Comments != null && cue.Comments.Length > 0)
            {
                foreach (var comment in cue.Comments)
                    if (comment.StartsWith("GENRE "))
                        genre = comment.Substring(6);
                    else if (comment.StartsWith("DATE "))
                    {
                        uint.TryParse(comment.Substring(5), out year);
                        if (year <= 1000 || year >= 3000)
                            year = 0;
                    }
            }


            var audioFile = cue.Tracks[0].DataFile.Filename;

            int i = 1;

            foreach (var track in cue.Tracks)
            {
                if (track.Indices.Length == 0)
                    continue;

                var offset = track.Offset;
                var duration = TimeSpan.Zero;

                if (i < cue.Tracks.Length)
                {
                    TimeSpan nextOffset = cue.Tracks[i].Offset;
                    duration = nextOffset - offset;
                }
                else
                {
                    // there's no way of knowing what's the last track's duration without decoding audio file
                    // and checking it's duration first; deferred to track info reading code
                }

                var element = new LocalTrackFragment(offset, duration, track.Title)
                {
                    Path = Path.Combine(basePath, audioFile),
                    Artist = track.Performer ?? cue.Performer,
                    Album = track.Title ?? cue.Title,
                    TrackNumber = track.TrackNumber,
                    Genres = new List<Genre> { PlayableBase.StringToGenre(genre) },
                    Year = year
                };

                playlist.AddTrack(element);

                ++i;
            }

            return playlist;
        }
Пример #4
0
        /// <summary>
        /// Open an manipulate an existing cuesheet.
        /// </summary>
        static void OpenExistingFile()
        {
            //Incomplete FreeDB feature
            //Console.WriteLine(cue.CalculateCDDBdiscID());
            //Console.Read();

            //open a cuesheet from file with the default encoding.
            CueSheet cue = new CueSheet("CDImage.cue");

            //print out the title from the global section of the cue file
            Console.WriteLine(cue.Title);

            //print out the performer from the global section of the cue file
            Console.WriteLine(cue.Performer);

            //Show how many track there are
            Console.WriteLine("There are " + cue.Tracks.Length.ToString() + "tracks in this cue file.");

            //Write out the first track
            Console.WriteLine(cue[0].ToString());

            Console.WriteLine("------ Start CueSheet -------");
            Console.WriteLine(cue.ToString());
            Console.WriteLine("------  End CueSheet  -------");

            //print out the title of the second track
            Console.WriteLine(cue[1].Title);

            //print out the Minutes, seconds, and frames of the first index of the second track.
            Console.WriteLine(cue[1][0].Minutes);
            Console.WriteLine(cue[1][0].Seconds);
            Console.WriteLine(cue[1][0].Frames);

            //Print out the image filename
            Console.WriteLine("Data file location: " + cue[0].DataFile.Filename);

            //change the title of the cuesheet
            cue.Title = "Great Music";

            //Manipulate the first track
            Track tempTrack = cue[0];//create a tempTrack to change info
            tempTrack.AddFlag(Flags.CH4);//add a new flag
            tempTrack.Title = "Wonderful track #1";//change the title
            cue[0] = tempTrack;//Set the 1st track with the newly manipulated track.

            cue.SaveCue("newcue.cue");
        }