1 /* PROJECT: ReactOS sndrec32
2 * LICENSE: GPL - See COPYING in the top level directory
3 * FILE: base/applications/sndrec32/audio_format.hpp
4 * PURPOSE: Audio format abstraction
5 * PROGRAMMERS: Marco Pagliaricci (irc: rendar)
8 #ifndef _AUDIOFORMAT__H_
9 #define _AUDIOFORMAT__H_
11 #include "audio_def.hpp"
13 _AUDIO_NAMESPACE_START_
18 unsigned int samples_psec;
19 unsigned short int bits_psample;
20 unsigned short int chan;
23 audio_format(unsigned int samples_per_second,
24 unsigned short int bits_per_sample,
25 unsigned short int channels) : samples_psec(samples_per_second),
26 bits_psample(bits_per_sample),
32 virtual ~audio_format(void)
37 bool operator==(audio_format & eq) const
39 /* The same audio format is when samples per second,
40 bit per sample, and channels mono/stereo are equal */
41 return ((samples_psec == eq.samples_psec) &&
42 (bits_psample == eq.bits_psample) &&
46 /* Public Functions */
48 unsigned int sample_rate(void) const
53 unsigned short int bits(void) const
58 unsigned short int channels(void) const
63 unsigned int byte_rate(void) const
65 return (samples_psec * chan * (bits_psample / 8));
68 unsigned int block_align(void) const
70 return (chan * (bits_psample / 8));
73 unsigned int samples_in_seconds(float seconds) const
75 return (unsigned int)(((float)samples_psec * (float) chan) * seconds);
78 unsigned int samples_in_bytes(unsigned int bytes) const
80 return (bytes / ((bits_psample / 8) * chan));
83 unsigned int bytes_in_samples(unsigned int samples) const
85 return (samples * ((bits_psample / 8) * chan));
89 extern audio_format UNKNOWN_FORMAT;
90 extern audio_format A44100_16BIT_STEREO;
91 extern audio_format A44100_16BIT_MONO;
95 #endif /* _AUDIOFORMAT__H_ */