RTP Audio System
2.0.0
|
00001 // ########################################################################## 00002 // #### #### 00003 // #### RTP Audio Server Project #### 00004 // #### ============================ #### 00005 // #### #### 00006 // #### Audio Quality #### 00007 // #### #### 00008 // #### Copyright (C) 1999-2012 by Thomas Dreibholz #### 00009 // #### #### 00010 // #### Contact: #### 00011 // #### EMail: dreibh@iem.uni-due.de #### 00012 // #### WWW: https://www.nntb.no/~dreibh/rtpaudio #### 00013 // #### #### 00014 // #### ---------------------------------------------------------------- #### 00015 // #### #### 00016 // #### This program is free software: you can redistribute it and/or #### 00017 // #### modify it under the terms of the GNU General Public License as #### 00018 // #### published by the Free Software Foundation, either version 3 of #### 00019 // #### the License, or (at your option) any later version. #### 00020 // #### #### 00021 // #### This program is distributed in the hope that it will be useful, #### 00022 // #### but WITHOUT ANY WARRANTY; without even the implied warranty of #### 00023 // #### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #### 00024 // #### GNU General Public License for more details. #### 00025 // #### #### 00026 // #### You should have received a copy of the GNU General Public #### 00027 // #### License along with this program. If not, see #### 00028 // #### <http://www.gnu.org/licenses/>. #### 00029 // #### #### 00030 // ########################################################################## 00031 // $Id: audioquality.h 1286 2011-12-18 13:43:16Z dreibh $ 00032 00033 00034 #ifndef AUDIOQUALITY_H 00035 #define AUDIOQUALITY_H 00036 00037 00038 #include "tdsystem.h" 00039 #include "randomizer.h" 00040 #include "audioqualityinterface.h" 00041 00042 00050 class AudioQuality : virtual public AdjustableAudioQualityInterface 00051 { 00052 // ====== Constructors =================================================== 00053 public: 00057 AudioQuality(); 00058 00067 AudioQuality(const card16 samplingRate, 00068 const card8 bits, 00069 const card8 channels, 00070 const card16 byteOrder = BYTE_ORDER); 00071 00077 AudioQuality(const AudioQualityInterface& quality); 00078 00079 00080 // ====== Quality functions ============================================== 00086 card16 getSamplingRate() const; 00087 00093 card8 getBits() const; 00094 00100 card8 getChannels() const; 00101 00102 00108 card16 getByteOrder() const; 00109 00110 00116 cardinal getBytesPerSecond() const; 00117 00123 cardinal getBitsPerSample() const; 00124 00125 00131 card16 setSamplingRate(const card16 samplingRate); 00132 00138 card8 setBits(const card8 bits); 00139 00145 card8 setChannels(const card8 channels); 00146 00147 00153 card16 setByteOrder(const card16 byteOrder); 00154 00155 00161 inline bool isLowest() const; 00162 00168 inline bool isHighest() const; 00169 00170 00177 void increase(const cardinal steps); 00178 00185 void decrease(const cardinal setps); 00186 00187 00193 bool prevSamplingRate(); 00194 00200 bool nextSamplingRate(); 00201 00202 00206 inline card64 bytesToTime(const size_t bytes) const; 00207 00211 inline size_t timeToBytes(const card64 microseconds) const; 00212 00213 00214 // ====== Operators ====================================================== 00218 AudioQuality& operator=(const AudioQualityInterface& quality); 00219 00223 AudioQuality operator++(int); 00224 00228 AudioQuality operator--(int); 00229 00230 00231 // ====== Static functions =============================================== 00232 public: 00239 static AudioQuality getQualityForByteRate(const cardinal bps); 00240 00246 static AudioQuality getRandomQuality(Randomizer* randomizer); 00247 00248 00252 static const card16* ValidRatesTable; 00253 00257 static const cardinal ValidRates; 00258 00262 static const card8* ValidBitsTable; 00263 00267 static const cardinal ValidBits; 00268 00272 static const card8* ValidChannelsTable; 00273 00277 static const cardinal ValidChannels; 00278 00279 00283 static const AudioQuality LowestQuality; 00284 00288 static const AudioQuality HighestQuality; 00289 00293 static const card16 LowestSamplingRate; 00294 00298 static const card16 HighestSamplingRate; 00299 00303 static const card8 LowestBits; 00304 00308 static const card8 HighestBits; 00309 00313 static const card8 LowestChannels; 00314 00318 static const card8 HighestChannels; 00319 00323 static const cardinal QualityLevels = 23; 00324 00325 00326 // ====== Private data =================================================== 00327 private: 00328 card16 SamplingRate; 00329 card8 Bits; 00330 card8 Channels; 00331 card16 ByteOrder; 00332 }; 00333 00334 00338 std::ostream& operator<<(std::ostream& out, const AudioQualityInterface& quality); 00339 00343 AudioQuality operator+(const AudioQualityInterface& q1, const AudioQualityInterface& q2); 00344 00348 AudioQuality operator-(const AudioQualityInterface& q1, const AudioQualityInterface& q2); 00349 00354 AudioQuality operator-(const AudioQualityInterface& q1, const cardinal bytesPerSecond); 00355 00356 00357 #include "audioquality.icc" 00358 00359 00360 #endif