Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenaudio_format.hpp
Go to the documentation of this file.
00001 /* PROJECT: ReactOS sndrec32 00002 * LICENSE: GPL - See COPYING in the top level directory 00003 * FILE: base/applications/sndrec32/audio_format.hpp 00004 * PURPOSE: Audio format abstraction 00005 * PROGRAMMERS: Marco Pagliaricci (irc: rendar) 00006 */ 00007 00008 00009 00010 #ifndef _AUDIOFORMAT__H_ 00011 #define _AUDIOFORMAT__H_ 00012 00013 00014 00015 #include "audio_def.hpp" 00016 00017 00018 00019 00020 _AUDIO_NAMESPACE_START_ 00021 00022 00023 00024 00025 00026 00027 00028 class audio_format 00029 { 00030 protected: 00031 00032 00033 unsigned int samples_psec; 00034 unsigned short int bits_psample; 00035 unsigned short int chan; 00036 00037 00038 public: 00039 00040 00041 // 00042 // Ctors 00043 // 00044 00045 audio_format( unsigned int samples_per_second, 00046 unsigned short int bits_per_sample, unsigned short int channels ) 00047 00048 : samples_psec( samples_per_second ), bits_psample( bits_per_sample ), 00049 chan( channels ) 00050 00051 { } 00052 00053 00054 00055 00056 00057 00058 00059 // 00060 // Dtor 00061 // 00062 00063 virtual ~audio_format( void ) 00064 { } 00065 00066 00067 00068 00069 00070 00071 00072 // 00073 // Operators 00074 // 00075 00076 bool operator==( audio_format & eq ) const 00077 { 00078 // 00079 // The same audio format is when samples per second, 00080 // bit per sample, and channels mono/stereo are equal. 00081 // 00082 00083 return (( samples_psec == eq.samples_psec ) 00084 && ( bits_psample == eq.bits_psample ) && ( chan == eq.chan )); 00085 } 00086 00087 00088 00089 00090 00091 00092 00093 00094 // 00095 // Public Functions 00096 // 00097 00098 unsigned int sample_rate( void ) const 00099 { return samples_psec; } 00100 00101 00102 unsigned short int bits( void ) const 00103 { return bits_psample; } 00104 00105 00106 unsigned short int channels( void ) const 00107 { return chan; } 00108 00109 00110 unsigned int byte_rate( void ) const 00111 { return ( samples_psec * chan * ( bits_psample / 8 )); } 00112 00113 00114 unsigned int block_align( void ) const 00115 { return ( chan * ( bits_psample / 8 )); } 00116 00117 00118 00119 unsigned int samples_in_seconds( float seconds ) const 00120 { 00121 00122 return ( unsigned int ) 00123 ((( float )samples_psec * ( float ) chan ) * seconds ); 00124 00125 } 00126 00127 unsigned int samples_in_bytes ( unsigned int bytes ) const 00128 { 00129 00130 return ( bytes / (( bits_psample / 8 ) * chan )); 00131 00132 } 00133 00134 unsigned int bytes_in_samples( unsigned int samples ) const 00135 { 00136 00137 return ( samples * (( bits_psample / 8 ) * chan )); 00138 00139 } 00140 00141 }; 00142 00143 00144 00145 00146 extern audio_format UNKNOWN_FORMAT; 00147 extern audio_format A44100_16BIT_STEREO; 00148 extern audio_format A44100_16BIT_MONO; 00149 00150 00151 00152 00153 00154 00155 _AUDIO_NAMESPACE_END_ 00156 00157 00158 00159 00160 00161 00162 00163 #endif //ifdef _AUDIOFORMAT__H_ Generated on Sat May 26 2012 04:16:25 for ReactOS by
1.7.6.1
|