Added TagLib (with AUTORS and COPYING files)
[someplayer] / src / taglib / audioproperties.h
1 /***************************************************************************
2     copyright            : (C) 2002 - 2008 by Scott Wheeler
3     email                : wheeler@kde.org
4  ***************************************************************************/
5
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.                     *
10  *                                                                         *
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.                       *
15  *                                                                         *
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  *
19  *   USA                                                                   *
20  *                                                                         *
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  ***************************************************************************/
25
26 #ifndef TAGLIB_AUDIOPROPERTIES_H
27 #define TAGLIB_AUDIOPROPERTIES_H
28
29 #include "taglib_export.h"
30
31 namespace TagLib {
32
33   //! A simple, abstract interface to common audio properties
34
35   /*!
36    * The values here are common to most audio formats.  For more specific, codec
37    * dependant values, please see see the subclasses APIs.  This is meant to
38    * compliment the TagLib::File and TagLib::Tag APIs in providing a simple
39    * interface that is sufficient for most applications.
40    */
41
42   class TAGLIB_EXPORT AudioProperties
43   {
44   public:
45
46     /*!
47      * Reading audio properties from a file can sometimes be very time consuming
48      * and for the most accurate results can often involve reading the entire
49      * file.  Because in many situations speed is critical or the accuracy of the
50      * values is not particularly important this allows the level of desired
51      * accuracy to be set.
52      */
53     enum ReadStyle {
54       //! Read as little of the file as possible
55       Fast,
56       //! Read more of the file and make better values guesses
57       Average,
58       //! Read as much of the file as needed to report accurate values
59       Accurate
60     };
61
62     /*!
63      * Destroys this AudioProperties instance.
64      */
65     virtual ~AudioProperties();
66
67     /*!
68      * Returns the length of the file in seconds.
69      */
70     virtual int length() const = 0;
71
72     /*!
73      * Returns the most appropriate bit rate for the file in kb/s.  For constant
74      * bitrate formats this is simply the bitrate of the file.  For variable
75      * bitrate formats this is either the average or nominal bitrate.
76      */
77     virtual int bitrate() const = 0;
78
79     /*!
80      * Returns the sample rate in Hz.
81      */
82     virtual int sampleRate() const = 0;
83
84     /*!
85      * Returns the number of audio channels.
86      */
87     virtual int channels() const = 0;
88
89   protected:
90
91     /*!
92      * Construct an audio properties instance.  This is protected as this class
93      * should not be instantiated directly, but should be instantiated via its
94      * subclasses and can be fetched from the FileRef or File APIs.
95      *
96      * \see ReadStyle
97      */
98     AudioProperties(ReadStyle style);
99
100   private:
101     AudioProperties(const AudioProperties &);
102     AudioProperties &operator=(const AudioProperties &);
103
104     class AudioPropertiesPrivate;
105     AudioPropertiesPrivate *d;
106   };
107
108 }
109
110 #endif