59 enc_linear8 = 2,enc_linear16 = 3,enc_linear24 = 4,
60 enc_linear32 = 5,enc_float = 6,enc_double = 7};
74 s < -1.0 ? -1.0 : s > 1.0 ? 1.0 : s;
163 static const int32_t max_abs_value = (1<<23) - 1;
165 uint32_t value()
const {
return _value;}
173template<
typename Binary_Out_Stream>
177 char *
c =
reinterpret_cast<char *
>(&sample);
178 if(s.get_endianity() == s.get_native_endianity()){
184 s.put(
c[2]); s.put(
c[1]); s.put(
c[0]);
190template<
typename Binary_In_Stream>
194 char *
c =
reinterpret_cast<char *
>(&sample);
195 if(s.get_endianity() == s.get_native_endianity()){
201 s.get(
c[2]); s.get(
c[1]); s.get(
c[0]);
203 if(s)
v.value(sample);
215 static const std::size_t enc_sample_size = 3;
Generic template class for Audio samples.
Small class to represent 24-bit PCM samples.
Implementation of G.711 logarithmic codecs.
Audio_Encoding
Supported encoding types for audio samples.
int16_t alaw_expand(uint8_t s)
G.711 u-Law expansion function. Returns decoded value for previously compressed sample s....
uint8_t ulaw_compress(int16_t s)
G.711 u-Law compression function. Returns encoded value for sample s.
int16_t ulaw_expand(uint8_t s)
G.711 u-Law expansion function. Returns decoded value for previously compressed sample s....
uint8_t alaw_compress(int16_t s)
G.711 a-Law compression function. Returns encoded value for sample s.
T limit_audio_sample(double s)
Helper function for scaling and limiting of audio samples.
double audio_sample_to_double(T s)
Helper function for scaling and limiting of audio samples.
std::ostream & operator<<(std::ostream &output, const bin &inbin)
Output stream of bin.
std::istream & operator>>(std::istream &input, bin &outbin)
Input stream of bin.
std::size_t encoded_sample_size(Audio_Encoding e)
Size of encoded sample based on the encoding type e.