1 /***************************************************************************
2 copyright : (C) 2002 - 2008 by Scott Wheeler
3 email : wheeler@kde.org
4 ***************************************************************************/
6 /***************************************************************************
7 * This library is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU Lesser General Public License version *
9 * 2.1 as published by the Free Software Foundation. *
11 * This library is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14 * Lesser General Public License for more details. *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with this library; if not, write to the Free Software *
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
21 * Alternatively, this file is available under the Mozilla Public *
22 * License Version 1.1. You may obtain a copy of the License at *
23 * http://www.mozilla.org/MPL/ *
24 ***************************************************************************/
26 #ifndef TAGLIB_RELATIVEVOLUMEFRAME_H
27 #define TAGLIB_RELATIVEVOLUMEFRAME_H
30 #include "id3v2frame.h"
31 #include "taglib_export.h"
37 //! An ID3v2 relative volume adjustment frame implementation
40 * This is an implementation of ID3v2 relative volume adjustment. The
41 * presence of this frame makes it possible to specify an increase in volume
42 * for an audio file or specific audio tracks in that file.
44 * Multiple relative volume adjustment frames may be present in the tag
45 * each with a unique identification and describing volume adjustment for
46 * different channel types.
49 class TAGLIB_EXPORT RelativeVolumeFrame : public Frame
51 friend class FrameFactory;
56 * This indicates the type of volume adjustment that should be applied.
59 //! A type not enumerated below
61 //! The master volume for the track
63 //! The front right audio channel
65 //! The front left audio channel
67 //! The back right audio channel
69 //! The back left audio channel
71 //! The front center audio channel
73 //! The back center audio channel
75 //! The subwoofer audio channel
79 //! Struct that stores the relevant values for ID3v2 peak volume
82 * The peak volume is described as a series of bits that is padded to fill
83 * a block of bytes. These two values should always be updated in tandem.
88 * Constructs an empty peak volume description.
90 PeakVolume() : bitsRepresentingPeak(0) {}
92 * The number of bits (in the range of 0 to 255) used to describe the
95 unsigned char bitsRepresentingPeak;
97 * The array of bits (represented as a series of bytes) used to describe
100 ByteVector peakVolume;
104 * Constructs a RelativeVolumeFrame. The relevant data should be set
107 RelativeVolumeFrame();
110 * Constructs a RelativeVolumeFrame based on the contents of \a data.
112 RelativeVolumeFrame(const ByteVector &data);
115 * Destroys the RelativeVolumeFrame instance.
117 virtual ~RelativeVolumeFrame();
120 * Returns the frame's identification.
122 * \see identification()
124 virtual String toString() const;
127 * Returns a list of channels with information currently in the frame.
129 List<ChannelType> channels() const;
132 * \deprecated Always returns master volume.
134 ChannelType channelType() const;
137 * \deprecated This method no longer has any effect.
139 void setChannelType(ChannelType t);
142 * There was a terrible API goof here, and while this can't be changed to
143 * the way it appears below for binary compaibility reasons, let's at
144 * least pretend that it looks clean.
150 * Returns the relative volume adjustment "index". As indicated by the
151 * ID3v2 standard this is a 16-bit signed integer that reflects the
152 * decibils of adjustment when divided by 512.
154 * This defaults to returning the value for the master volume channel if
155 * available and returns 0 if the specified channel does not exist.
157 * \see setVolumeAdjustmentIndex()
158 * \see volumeAjustment()
160 short volumeAdjustmentIndex(ChannelType type = MasterVolume) const;
163 * Set the volume adjustment to \a index. As indicated by the ID3v2
164 * standard this is a 16-bit signed integer that reflects the decibils of
165 * adjustment when divided by 512.
167 * By default this sets the value for the master volume.
169 * \see volumeAdjustmentIndex()
170 * \see setVolumeAjustment()
172 void setVolumeAdjustmentIndex(short index, ChannelType type = MasterVolume);
175 * Returns the relative volume adjustment in decibels.
177 * \note Because this is actually stored internally as an "index" to this
178 * value the value returned by this method may not be identical to the
179 * value set using setVolumeAdjustment().
181 * This defaults to returning the value for the master volume channel if
182 * available and returns 0 if the specified channel does not exist.
184 * \see setVolumeAdjustment()
185 * \see volumeAdjustmentIndex()
187 float volumeAdjustment(ChannelType type = MasterVolume) const;
190 * Set the relative volume adjustment in decibels to \a adjustment.
192 * By default this sets the value for the master volume.
194 * \note Because this is actually stored internally as an "index" to this
195 * value the value set by this method may not be identical to the one
196 * returned by volumeAdjustment().
198 * \see setVolumeAdjustment()
199 * \see volumeAdjustmentIndex()
201 void setVolumeAdjustment(float adjustment, ChannelType type = MasterVolume);
204 * Returns the peak volume (represented as a length and a string of bits).
206 * This defaults to returning the value for the master volume channel if
207 * available and returns 0 if the specified channel does not exist.
209 * \see setPeakVolume()
211 PeakVolume peakVolume(ChannelType type = MasterVolume) const;
214 * Sets the peak volume to \a peak.
216 * By default this sets the value for the master volume.
220 void setPeakVolume(const PeakVolume &peak, ChannelType type = MasterVolume);
224 // BIC: Combine each of the following pairs of functions (or maybe just
225 // rework this junk altogether).
227 short volumeAdjustmentIndex(ChannelType type) const;
228 short volumeAdjustmentIndex() const;
230 void setVolumeAdjustmentIndex(short index, ChannelType type);
231 void setVolumeAdjustmentIndex(short index);
233 float volumeAdjustment(ChannelType type) const;
234 float volumeAdjustment() const;
236 void setVolumeAdjustment(float adjustment, ChannelType type);
237 void setVolumeAdjustment(float adjustment);
239 PeakVolume peakVolume(ChannelType type) const;
240 PeakVolume peakVolume() const;
242 void setPeakVolume(const PeakVolume &peak, ChannelType type);
243 void setPeakVolume(const PeakVolume &peak);
248 * Returns the identification for this frame.
250 String identification() const;
253 * Sets the identification of the frame to \a s. The string
254 * is used to identify the situation and/or device where this
255 * adjustment should apply.
257 void setIdentification(const String &s);
260 virtual void parseFields(const ByteVector &data);
261 virtual ByteVector renderFields() const;
264 RelativeVolumeFrame(const ByteVector &data, Header *h);
265 RelativeVolumeFrame(const RelativeVolumeFrame &);
266 RelativeVolumeFrame &operator=(const RelativeVolumeFrame &);
268 class RelativeVolumeFramePrivate;
269 RelativeVolumeFramePrivate *d;