private void ParseRelativeVolumeFields(ByteVector data) { int pos = data.Find(TextDelimiter(StringType.Latin1)); if (pos < 0) { return; } identification = data.Mid(0, pos).ToString(StringType.Latin1); pos += 1; // Each channel is at least 4 buffer. while (pos <= data.Count - 4) { Id3v2ChannelType type = (Id3v2ChannelType)data[pos]; pos += 1; SetVolumeAdjustmentIndex(data.Mid(pos, 2).ToShort(), type); pos += 2; int bytes = BitsToBytes(data[pos]); pos += 1; SetPeakVolumeIndex(ParsePeakVolume(data.Mid(pos, bytes)), type); pos += bytes; } }
/// <summary> /// Initializes a new instance of the <see cref="Id3v2ChannelInformation"/> class. /// </summary> /// <param name="channelType">Type of the channel.</param> /// <param name="volumeAdjustment">The volume adjustment.</param> /// <param name="bitsRepresentingPeak">The bits representing peak.</param> /// <param name="peakVolume">The peak volume.</param> public Id3v2ChannelInformation(Id3v2ChannelType channelType, float volumeAdjustment, byte bitsRepresentingPeak, long peakVolume) { ChannelType = channelType; VolumeAdjustment = volumeAdjustment; BitsRepresentingPeak = bitsRepresentingPeak; PeakVolume = peakVolume; }
public void SetVolumeAdjustmentIndex(short index, Id3v2ChannelType type) { if (!channels.ContainsKey(type)) { channels.Add(type, new ChannelData(type)); } channels[type].VolumeAdjustment = index; }
public void SetPeakVolumeIndex(ulong index, Id3v2ChannelType type) { if (!channels.ContainsKey(type)) { channels.Add(type, new ChannelData(type)); } channels[type].PeakVolume = index; }
public float VolumeAdjustment(Id3v2ChannelType type) { return(((float)VolumeAdjustmentIndex(type)) / 512f); }
public ChannelData(Id3v2ChannelType type) { channelType = type; //volumeAdjustment = 0; //peakVolume = 0; }
public float VolumeAdjustment(Id3v2ChannelType type) { return ((float)VolumeAdjustmentIndex(type)) / 512f; }
public void SetPeakVolume(double adjustment, Id3v2ChannelType type) { SetPeakVolumeIndex((ulong)(adjustment * 512.0), type); }
public double PeakVolume(Id3v2ChannelType type) { return(((double)PeakVolumeIndex(type)) / 512.0); }
public ulong PeakVolumeIndex(Id3v2ChannelType type) { return(channels.ContainsKey(type) ? channels[type].PeakVolume : 0); }
public void SetVolumeAdjustmentIndex(short index, Id3v2ChannelType type) { if (!channels.ContainsKey(type)) channels.Add(type, new ChannelData(type)); channels[type].VolumeAdjustment = index; }
public void SetVolumeAdjustment(float adjustment, Id3v2ChannelType type) { SetVolumeAdjustmentIndex((short)(adjustment * 512f), type); }
public short VolumeAdjustmentIndex(Id3v2ChannelType type) { return(channels.ContainsKey(type) ? channels[type].VolumeAdjustment : (short)0); }
public double PeakVolume(Id3v2ChannelType type) { return ((double)PeakVolumeIndex(type)) / 512.0; }
public void SetPeakVolumeIndex(ulong index, Id3v2ChannelType type) { if (!channels.ContainsKey(type)) channels.Add(type, new ChannelData(type)); channels[type].PeakVolume = index; }
public ulong PeakVolumeIndex(Id3v2ChannelType type) { return channels.ContainsKey(type) ? channels[type].PeakVolume : 0; }
////------------------------------------------------------------------------------------------------------------------------------ private static bool IsValidChannelType(Id3v2ChannelType channelType) { return Enum.TryParse(channelType.ToString(), true, out channelType); }
public short VolumeAdjustmentIndex(Id3v2ChannelType type) { return channels.ContainsKey(type) ? channels[type].VolumeAdjustment : (short)0; }