Inheritance: TagLib.Id3v2.Frame
 public static RelativeVolumeFrame Get(TagLib.Id3v2.Tag tag, string identification, bool create)
 {
     RelativeVolumeFrame frame;
     IEnumerator<Frame> enumerator = tag.GetFrames(FrameType.RVA2).GetEnumerator();
     try
     {
         while (enumerator.MoveNext())
         {
             Frame current = enumerator.Current;
             frame = current as RelativeVolumeFrame;
             if ((frame != null) && (frame.Identification == identification))
             {
                 return frame;
             }
         }
     }
     finally
     {
         if (enumerator == null)
         {
         }
         enumerator.Dispose();
     }
     if (!create)
     {
         return null;
     }
     frame = new RelativeVolumeFrame(identification);
     tag.AddFrame(frame);
     return frame;
 }
        /// <summary>
        ///    Gets a specified volume adjustment frame from the
        ///    specified tag, optionally creating it if it does not
        ///    exist.
        /// </summary>
        /// <param name="tag">
        ///    A <see cref="Tag" /> object to search in.
        /// </param>
        /// <param name="identification">
        ///    A <see cref="string" /> specifying the identification to
        ///    match.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> specifying whether or not to create
        ///    and add a new frame to the tag if a match is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="RelativeVolumeFrame" /> object containing
        ///    the matching frame, or <see langword="null" /> if a match
        ///    wasn't found and <paramref name="create" /> is <see
        ///    langword="false" />.
        /// </returns>
        public static RelativeVolumeFrame Get(Tag tag,
                                              string identification,
                                              bool create)
        {
            RelativeVolumeFrame rva2;

            foreach (Frame frame in tag.GetFrames(FrameType.RVA2))
            {
                rva2 = frame as RelativeVolumeFrame;

                if (rva2 == null)
                {
                    continue;
                }

                if (rva2.Identification != identification)
                {
                    continue;
                }

                return(rva2);
            }

            if (!create)
            {
                return(null);
            }

            rva2 = new RelativeVolumeFrame(identification);
            tag.AddFrame(rva2);
            return(rva2);
        }
 public override Frame Clone()
 {
     RelativeVolumeFrame frame = new RelativeVolumeFrame(this.identification);
     for (int i = 0; i < 9; i++)
     {
         frame.channels[i] = this.channels[i];
     }
     return frame;
 }
        /// <summary>
        ///    Creates a deep copy of the current instance.
        /// </summary>
        /// <returns>
        ///    A new <see cref="Frame" /> object identical to the
        ///    current instance.
        /// </returns>
        public override Frame Clone()
        {
            var frame = new RelativeVolumeFrame(Identification);

            for (int i = 0; i < 9; i++)
            {
                frame.channels[i] = channels[i];
            }
            return(frame);
        }
        /// <summary>
        ///    Gets a specified volume adjustment frame from the
        ///    specified tag, optionally creating it if it does not
        ///    exist.
        /// </summary>
        /// <param name="tag">
        ///    A <see cref="Tag" /> object to search in.
        /// </param>
        /// <param name="identification">
        ///    A <see cref="string" /> specifying the identification to
        ///    match.
        /// </param>
        /// <param name="create">
        ///    A <see cref="bool" /> specifying whether or not to create
        ///    and add a new frame to the tag if a match is not found.
        /// </param>
        /// <returns>
        ///    A <see cref="RelativeVolumeFrame" /> object containing
        ///    the matching frame, or <see langword="null" /> if a match
        ///    wasn't found and <paramref name="create" /> is <see
        ///    langword="false" />.
        /// </returns>
        public static RelativeVolumeFrame Get(Tag tag,
            string identification,
            bool create)
        {
            RelativeVolumeFrame rva2;
            foreach (Frame frame in tag.GetFrames (FrameType.RVA2)) {
                rva2 = frame as RelativeVolumeFrame;

                if (rva2 == null)
                    continue;

                if (rva2.Identification != identification)
                    continue;

                return rva2;
            }

            if (!create)
                return null;

            rva2 = new RelativeVolumeFrame (identification);
            tag.AddFrame (rva2);
            return rva2;
        }
Example #6
0
		public void TestRelativeVolumeFrameWithBrokenPeakVolume ()
		{
			// RVA2 data found in the wild
			var data = new byte[] { 82, 86, 65, 50, 0, 0, 0, 12, 0, 0, 97, 108, 98, 117, 109, 0, 1, 255, 0, 200, 15, 116 };
			var frame = new RelativeVolumeFrame (data, 4);
			Assert.AreEqual ("album", frame.Identification);
			Assert.AreEqual (-256, frame.GetVolumeAdjustmentIndex (ChannelType.MasterVolume));
			Assert.AreEqual (0, frame.GetPeakVolumeIndex (ChannelType.MasterVolume));
		}
Example #7
0
		public void TestRelativeVolumeFrame ()
		{
			for (int a = 0; a < 2; a ++) {
			for (int b = 0; b < 2; b ++) {
			for (int c = 0; c < 2; c ++) {
			for (int d = 0; d < 2; d ++) {
			for (int e = 0; e < 2; e ++) {
			for (int f = 0; f < 2; f ++) {
			for (int g = 0; g < 2; g ++) {
			for (int h = 0; h < 2; h ++) {
			for (int i = 0; i < 2; i ++) {
			
			RelativeVolumeFrame frame = new RelativeVolumeFrame (val_sing);
			
			frame.SetPeakVolume ((ChannelType) 0, (double) a);
			frame.SetVolumeAdjustment ((ChannelType) 0, (float) -a);
			frame.SetPeakVolume ((ChannelType) 1, (double) b);
			frame.SetVolumeAdjustment ((ChannelType) 1, (float) -b);
			frame.SetPeakVolume ((ChannelType) 2, (double) c);
			frame.SetVolumeAdjustment ((ChannelType) 2, (float) -c);
			frame.SetPeakVolume ((ChannelType) 3, (double) d);
			frame.SetVolumeAdjustment ((ChannelType) 3, (float) -d);
			frame.SetPeakVolume ((ChannelType) 4, (double) e);
			frame.SetVolumeAdjustment ((ChannelType) 4, (float) -e);
			frame.SetPeakVolume ((ChannelType) 5, (double) f);
			frame.SetVolumeAdjustment ((ChannelType) 5, (float) -f);
			frame.SetPeakVolume ((ChannelType) 6, (double) g);
			frame.SetVolumeAdjustment ((ChannelType) 6, (float) -g);
			frame.SetPeakVolume ((ChannelType) 7, (double) h);
			frame.SetVolumeAdjustment ((ChannelType) 7, (float) -h);
			frame.SetPeakVolume ((ChannelType) 8, (double) i);
			frame.SetVolumeAdjustment ((ChannelType) 8, (float) -i);
			
			FrameTest (frame, 2, null,
				delegate (ByteVector d_, byte v_) {
					return new RelativeVolumeFrame (d_, v_);
				},
				
				delegate (Frame f_, string m_) {
					RelativeVolumeFrame g_ = (f_ as RelativeVolumeFrame);
					Assert.AreEqual ((double) a, g_.GetPeakVolume ((ChannelType) 0), "A: " + m_);
					Assert.AreEqual ((float) -a, g_.GetVolumeAdjustment ((ChannelType) 0), "A: " + m_);
					Assert.AreEqual ((double) b, g_.GetPeakVolume ((ChannelType) 1), "B: " + m_);
					Assert.AreEqual ((float) -b, g_.GetVolumeAdjustment ((ChannelType) 1), "B: " + m_);
					Assert.AreEqual ((double) c, g_.GetPeakVolume ((ChannelType) 2), "C: " + m_);
					Assert.AreEqual ((float) -c, g_.GetVolumeAdjustment ((ChannelType) 2), "C: " + m_);
					Assert.AreEqual ((double) d, g_.GetPeakVolume ((ChannelType) 3), "D: " + m_);
					Assert.AreEqual ((float) -d, g_.GetVolumeAdjustment ((ChannelType) 3), "D: " + m_);
					Assert.AreEqual ((double) e, g_.GetPeakVolume ((ChannelType) 4), "E: " + m_);
					Assert.AreEqual ((float) -e, g_.GetVolumeAdjustment ((ChannelType) 4), "E: " + m_);
					Assert.AreEqual ((double) f, g_.GetPeakVolume ((ChannelType) 5), "F: " + m_);
					Assert.AreEqual ((float) -f, g_.GetVolumeAdjustment ((ChannelType) 5), "F: " + m_);
					Assert.AreEqual ((double) g, g_.GetPeakVolume ((ChannelType) 6), "G: " + m_);
					Assert.AreEqual ((float) -g, g_.GetVolumeAdjustment ((ChannelType) 6), "G: " + m_);
					Assert.AreEqual ((double) h, g_.GetPeakVolume ((ChannelType) 7), "H: " + m_);
					Assert.AreEqual ((float) -h, g_.GetVolumeAdjustment ((ChannelType) 7), "H: " + m_);
					Assert.AreEqual ((double) i, g_.GetPeakVolume ((ChannelType) 8), "I: " + m_);
					Assert.AreEqual ((float) -i, g_.GetVolumeAdjustment ((ChannelType) 8), "I: " + m_);
				});
			
			}}}}}}}}}
		}