- Merge from trunk up to r45543
[reactos.git] / base / applications / sndrec32 / audio_format.hpp
index 1f620b2..947e34d 100644 (file)
@@ -1,3 +1,12 @@
+/* PROJECT:         ReactOS sndrec32
+ * LICENSE:         GPL - See COPYING in the top level directory
+ * FILE:            base/applications/sndrec32/audio_format.hpp
+ * PURPOSE:         Audio format abstraction
+ * PROGRAMMERS:     Marco Pagliaricci (irc: rendar)
+ */
+
+
+
 #ifndef _AUDIOFORMAT__H_
 #define _AUDIOFORMAT__H_
 
@@ -18,62 +27,63 @@ _AUDIO_NAMESPACE_START_
 
 class audio_format
 {
-       protected:
-       
+    protected:
+    
+
+        unsigned int samples_psec;
+        unsigned short int bits_psample;
+        unsigned short int chan;
 
-               unsigned int samples_psec;
-               unsigned short int bits_psample;
-               unsigned short int chan;
 
+    public:
+        
+        
+        //
+        // Ctors
+        //
 
-       public:
-               
-               
-               //
-               // Ctors
-               //
+        audio_format( unsigned int samples_per_second, 
+            unsigned short int bits_per_sample, unsigned short int channels )
 
-               audio_format( unsigned int samples_per_second, 
-                       unsigned short int bits_per_sample, unsigned short int channels )
+            : samples_psec( samples_per_second ), bits_psample( bits_per_sample ),
+            chan( channels )
 
-                       : samples_psec( samples_per_second ), bits_psample( bits_per_sample ),
-                       chan( channels )
+        {     }
 
-               {     }
 
 
 
 
 
 
+        //
+        // Dtor
+        //
 
-               //
-               // Dtor
-               //
+        virtual ~audio_format( void )
+        { }
 
-               virtual ~audio_format( void )
-               { }
 
 
 
 
 
 
+        //
+        // Operators
+        //
 
-               //
-               // Operators
-               //
+        bool operator==( audio_format & eq ) const
+        {
+            //
+            // The same audio format is when samples per second,
+            // bit per sample, and channels mono/stereo are equal.
+            //
 
-               bool operator==( audio_format & eq ) const
-               {
-                       //
-                       // The same audio format is when samples per second,
-                       // bit per sample, and channels mono/stereo are equal.
-                       //
+            return (( samples_psec == eq.samples_psec ) 
+                && ( bits_psample == eq.bits_psample ) && ( chan == eq.chan ));
+        }
 
-                       return (( samples_psec == eq.samples_psec ) 
-                               && ( bits_psample == eq.bits_psample ) && ( chan == eq.chan ));
-               }
 
 
 
@@ -81,46 +91,52 @@ class audio_format
 
 
 
+        //
+        // Public Functions
+        //
 
-               //
-               // Public Functions
-               //
+        unsigned int sample_rate( void ) const
+        { return samples_psec; }
 
-               unsigned int sample_rate( void ) const
-               { return samples_psec; }
 
+        unsigned short int bits( void ) const
+        { return bits_psample; }
 
-               unsigned short int bits( void ) const
-               { return bits_psample; }
 
+        unsigned short int channels( void ) const
+        { return chan; }
 
-               unsigned short int channels( void ) const
-               { return chan; }
 
+        unsigned int byte_rate( void ) const
+        { return ( samples_psec * chan * ( bits_psample / 8 )); }
 
-               unsigned int byte_rate( void ) const
-               { return ( samples_psec * chan * ( bits_psample / 8 )); }
 
+        unsigned int block_align( void ) const
+        { return ( chan * ( bits_psample / 8 )); }
 
-               unsigned int block_align( void ) const
-               { return ( chan * ( bits_psample / 8 )); }
 
 
+        unsigned int samples_in_seconds( float seconds ) const
+        {
 
-               unsigned int samples_in_seconds( float seconds ) const
-               {
+            return ( unsigned int )
+                ((( float )samples_psec * ( float ) chan ) * seconds );
 
-                       return ( unsigned int )
-                               ((( float )samples_psec * ( float ) chan ) * seconds );
+        }
 
-               }
+        unsigned int samples_in_bytes ( unsigned int bytes ) const
+        {
 
-               unsigned int samples_in_bytes ( unsigned int bytes ) const
-               {
+            return ( bytes / (( bits_psample / 8 ) * chan ));
 
-                       return ( bytes / (( bits_psample / 8 ) * chan ));
+        }
 
-               }
+        unsigned int bytes_in_samples( unsigned int samples ) const
+        {
+
+            return ( samples * (( bits_psample / 8 ) * chan ));
+
+        }
 
 };
 
@@ -129,7 +145,7 @@ class audio_format
 
 extern audio_format UNKNOWN_FORMAT;
 extern audio_format A44100_16BIT_STEREO;
-
+extern audio_format A44100_16BIT_MONO;