Exemple #1
0
        public Dictionary <string, string> GetAllMetaTagsDataFormatted() // Returns all metadata of the track in a formatted, displayable manner
        {
            Dictionary <string, string> allTags = new Dictionary <string, string>();

            allTags.Add(nameof(Title), Title.ToString());
            allTags.Add(nameof(Album), Album.ToString());
            allTags.Add(nameof(Copyright), Copyright.ToString());
            allTags.Add(nameof(AlbumArtists), AlbumArtists.ToString());
            allTags.Add(nameof(AlbumArtistsSort), AlbumArtistsSort.ToString());
            allTags.Add(nameof(Genres), Genres.ToString());
            allTags.Add(nameof(BeatsPerMinute), BeatsPerMinute.ToString());
            allTags.Add(nameof(Year), Year.ToString());
            allTags.Add(nameof(Track), Track.ToString());
            allTags.Add(nameof(TrackCount), TrackCount.ToString());
            allTags.Add(nameof(Disc), Disc.ToString());
            allTags.Add(nameof(DiscCount), DiscCount.ToString());
            allTags.Add(nameof(MusicBrainzReleaseArtistId), MusicBrainzReleaseArtistId.ToString());
            allTags.Add(nameof(MusicBrainzTrackId), MusicBrainzTrackId.ToString());
            allTags.Add(nameof(MusicBrainzDiscId), MusicBrainzDiscId.ToString());
            allTags.Add(nameof(MusicBrainzReleaseStatus), MusicBrainzReleaseStatus.ToString());
            allTags.Add(nameof(MusicBrainzReleaseType), MusicBrainzReleaseType.ToString());
            allTags.Add(nameof(MusicBrainzReleaseCountry), MusicBrainzReleaseCountry.ToString());
            allTags.Add(nameof(MusicBrainzReleaseId), MusicBrainzReleaseId.ToString());
            allTags.Add(nameof(MusicBrainzArtistId), MusicBrainzArtistId.ToString());

            return(allTags);
        }
Exemple #2
0
        public Dictionary <string, Tuple <string, string> > Diff(AudioTag other)
        {
            var output = new Dictionary <string, Tuple <string, string> >();

            if (!IsValid || !other.IsValid)
            {
                return(output);
            }

            if (Title != other.Title)
            {
                output.Add("Title", Tuple.Create(Title, other.Title));
            }

            if ((Performers != null && Performers.Any()) ^
                (other.Performers != null && other.Performers.Any()) || (
                    other.Performers != null && other.Performers.Any() &&
                    Performers != null && Performers.Any() &&
                    !Performers.SequenceEqual(other.Performers)))
            {
                var oldValue = Performers != null && Performers.Any() ? string.Join(" / ", Performers) : null;
                var newValue = other.Performers != null && other.Performers.Any() ? string.Join(" / ", other.Performers) : null;

                output.Add("Artist", Tuple.Create(oldValue, newValue));
            }

            if (Album != other.Album && other.Album != null)
            {
                output.Add("Album", Tuple.Create(Album, other.Album));
            }

            if ((AlbumArtists != null && AlbumArtists.Any()) ^
                (other.AlbumArtists != null && other.AlbumArtists.Any()) || (
                    other.AlbumArtists != null && other.AlbumArtists.Any() &&
                    AlbumArtists != null && AlbumArtists.Any() &&
                    !AlbumArtists.SequenceEqual(other.AlbumArtists)))
            {
                var oldValue = AlbumArtists != null && AlbumArtists.Any() ? string.Join(" / ", AlbumArtists) : null;
                var newValue = other.AlbumArtists != null && other.AlbumArtists.Any() ? string.Join(" / ", other.AlbumArtists) : null;

                output.Add("Album Artist", Tuple.Create(oldValue, newValue));
            }

            if (Track != other.Track)
            {
                output.Add("Track", Tuple.Create(Track.ToString(), other.Track.ToString()));
            }

            if (TrackCount != other.TrackCount)
            {
                output.Add("Track Count", Tuple.Create(TrackCount.ToString(), other.TrackCount.ToString()));
            }

            if (Disc != other.Disc)
            {
                output.Add("Disc", Tuple.Create(Disc.ToString(), other.Disc.ToString()));
            }

            if (DiscCount != other.DiscCount)
            {
                output.Add("Disc Count", Tuple.Create(DiscCount.ToString(), other.DiscCount.ToString()));
            }

            if (Media != other.Media)
            {
                output.Add("Media Format", Tuple.Create(Media, other.Media));
            }

            if (Date != other.Date)
            {
                var oldValue = Date.HasValue ? Date.Value.ToString("yyyy-MM-dd") : null;
                var newValue = other.Date.HasValue ? other.Date.Value.ToString("yyyy-MM-dd") : null;
                output.Add("Date", Tuple.Create(oldValue, newValue));
            }

            if (OriginalReleaseDate != other.OriginalReleaseDate)
            {
                // Id3v2.3 tags can only store the year, not the full date
                if (OriginalReleaseDate.HasValue &&
                    OriginalReleaseDate.Value.Month == 1 &&
                    OriginalReleaseDate.Value.Day == 1)
                {
                    if (OriginalReleaseDate.Value.Year != other.OriginalReleaseDate.Value.Year)
                    {
                        output.Add("Original Year", Tuple.Create(OriginalReleaseDate.Value.Year.ToString(), other.OriginalReleaseDate.Value.Year.ToString()));
                    }
                }
                else
                {
                    var oldValue = OriginalReleaseDate.HasValue ? OriginalReleaseDate.Value.ToString("yyyy-MM-dd") : null;
                    var newValue = other.OriginalReleaseDate.HasValue ? other.OriginalReleaseDate.Value.ToString("yyyy-MM-dd") : null;
                    output.Add("Original Release Date", Tuple.Create(oldValue, newValue));
                }
            }

            if (Publisher != other.Publisher)
            {
                output.Add("Label", Tuple.Create(Publisher, other.Publisher));
            }

            if ((Genres != null && Genres.Any()) ^
                (other.Genres != null && other.Genres.Any()) || (
                    other.Genres != null && other.Genres.Any() &&
                    Genres != null && Genres.Any() &&
                    !Genres.SequenceEqual(other.Genres)))
            {
                var oldValue = Genres != null && Genres.Any() ? string.Join(" / ", Genres) : null;
                var newValue = other.Genres != null && other.Genres.Any() ? string.Join(" / ", other.Genres) : null;

                output.Add("Genres", Tuple.Create(oldValue, newValue));
            }

            if (ImageSize != other.ImageSize)
            {
                output.Add("Image Size", Tuple.Create(ImageSize.ToString(), other.ImageSize.ToString()));
            }

            return(output);
        }
Exemple #3
0
        public void Read(Stream strm)
        {
            readFileFlag = true;
            bool getIntervalflag = false;

            format = trackCount = division = 0;

            FindHeader(strm);
            Format     = (int)ReadProperty(strm);
            TrackCount = (int)ReadProperty(strm);
            Division   = (int)ReadProperty(strm);
            Console.WriteLine("Format=" + Format.ToString());
            Console.WriteLine("TrackCount=" + TrackCount.ToString());
            Console.WriteLine("Division=" + Division.ToString());
            for (int i = 0; i < trackCount; i++)
            {
                int truckBytes = FindTrunkHeader(strm);
                List <MidiOutFakeMessage> list = new List <MidiOutFakeMessage>();
                while (truckBytes > 0)
                {
                    if (!getIntervalflag)
                    {
                        MidiMessage mmTmp = getMessage(strm, ref truckBytes);
                        if (mmTmp.midiEvent == 0xFF5103)
                        {
                            getIntervalflag = true;
                            intervalTimer   = ((double)mmTmp.midiData / (double)division) * 0.001;
                        }
                    }
                    else
                    {
                        MidiMessage        mmTmp = getMessage(strm, ref truckBytes);
                        MidiOutFakeMessage mom;
                        mom.msg = 0;
                        if ((mmTmp.midiEvent & 0xF0) == 0x90 || (mmTmp.midiEvent & 0xF0) == 0x80) //

                        {
                            mom.timer   = mmTmp.midiTrick;
                            mom.msg     = (uint)(((mmTmp.midiData & 0xFF) << 16) | (mmTmp.midiData & 0xFF00) | mmTmp.midiEvent);
                            mom.channel = mmTmp.midiEvent & 0x0F;
                            list.Add(mom);
                        }
                        else if ((mmTmp.midiEvent & 0xF0) == 0xc0 || (mmTmp.midiEvent & 0xF0) == 0xd0)
                        {
                            mom.timer   = mmTmp.midiTrick;
                            mom.msg     = (uint)((mmTmp.midiData << 8) | mmTmp.midiEvent);
                            mom.channel = mmTmp.midiEvent & 0x0F;
                            list.Add(mom);
                        }
                        else if ((mmTmp.midiEvent & 0xF0) == 0xb0 ||
                                 (mmTmp.midiEvent & 0xF0) == 0xa0 || (mmTmp.midiEvent & 0xF0) == 0xe0)
                        {
                            mom.timer   = mmTmp.midiTrick;
                            mom.msg     = (uint)(((mmTmp.midiData & 0xFF) << 16) | (mmTmp.midiData & 0xFF00) | mmTmp.midiEvent);
                            mom.channel = mmTmp.midiEvent & 0x0F;
                            list.Add(mom);
                        }
                        else
                        {
                            mom.timer   = mmTmp.midiTrick;
                            mom.msg     = 0x00;
                            mom.channel = mmTmp.midiEvent & 0x0F;
                            list.Add(mom);
                        }
                    }
                }
                queueList.Add(list);
            }
            readFileFlag = false;
        }