ReactOS 0.4.15-dev-7994-gb388cb6
audio_format.hpp
Go to the documentation of this file.
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
14
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),
28 {
29 }
30
31 /* Dtor */
32 virtual ~audio_format(void)
33 {
34 }
35
36 /* Operators */
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
92
94
95#endif /* _AUDIOFORMAT__H_ */
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define _AUDIO_NAMESPACE_START_
Definition: audio_def.hpp:24
#define _AUDIO_NAMESPACE_END_
Definition: audio_def.hpp:25
audio_format A44100_16BIT_STEREO
audio_format A44100_16BIT_MONO
audio_format UNKNOWN_FORMAT
unsigned int samples_psec
unsigned short int chan
unsigned short int bits(void) const
bool operator==(audio_format &eq) const
unsigned short int bits_psample
unsigned int bytes_in_samples(unsigned int samples) const
unsigned int byte_rate(void) const
unsigned int samples_in_seconds(float seconds) const
unsigned int sample_rate(void) const
unsigned int samples_in_bytes(unsigned int bytes) const
audio_format(unsigned int samples_per_second, unsigned short int bits_per_sample, unsigned short int channels)
unsigned short int channels(void) const
unsigned int block_align(void) const
virtual ~audio_format(void)
GLsizei samples
Definition: glext.h:7006
#define eq(received, expected, label, type)
Definition: locale.c:144
static float(__cdecl *square_half_float)(float x