CORE-13875 Added russian translation for timeout util
[reactos.git] / base / applications / sndrec32 / audio_format.hpp
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)
6 */
7
8 #ifndef _AUDIOFORMAT__H_
9 #define _AUDIOFORMAT__H_
10
11 #include "audio_def.hpp"
12
13 _AUDIO_NAMESPACE_START_
14
15 class audio_format
16 {
17 protected:
18 unsigned int samples_psec;
19 unsigned short int bits_psample;
20 unsigned short int chan;
21 public:
22 /* Ctors */
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),
27 chan(channels)
28 {
29 }
30
31 /* Dtor */
32 virtual ~audio_format(void)
33 {
34 }
35
36 /* Operators */
37 bool operator==(audio_format & eq) const
38 {
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) &&
43 (chan == eq.chan));
44 }
45
46 /* Public Functions */
47
48 unsigned int sample_rate(void) const
49 {
50 return samples_psec;
51 }
52
53 unsigned short int bits(void) const
54 {
55 return bits_psample;
56 }
57
58 unsigned short int channels(void) const
59 {
60 return chan;
61 }
62
63 unsigned int byte_rate(void) const
64 {
65 return (samples_psec * chan * (bits_psample / 8));
66 }
67
68 unsigned int block_align(void) const
69 {
70 return (chan * (bits_psample / 8));
71 }
72
73 unsigned int samples_in_seconds(float seconds) const
74 {
75 return (unsigned int)(((float)samples_psec * (float) chan) * seconds);
76 }
77
78 unsigned int samples_in_bytes(unsigned int bytes) const
79 {
80 return (bytes / ((bits_psample / 8) * chan));
81 }
82
83 unsigned int bytes_in_samples(unsigned int samples) const
84 {
85 return (samples * ((bits_psample / 8) * chan));
86 }
87 };
88
89 extern audio_format UNKNOWN_FORMAT;
90 extern audio_format A44100_16BIT_STEREO;
91 extern audio_format A44100_16BIT_MONO;
92
93 _AUDIO_NAMESPACE_END_
94
95 #endif /* _AUDIOFORMAT__H_ */