26 AudioStreamInfo(uint8_t bits_per_sample, uint8_t channels, uint32_t sample_rate);
110#ifdef USE_AUDIO_FLAC_SUPPORT
113#ifdef USE_AUDIO_MP3_SUPPORT
135void scale_audio_samples(
const int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor,
136 size_t samples_to_scale);
144 if (bytes_per_sample == 1) {
145 sample |= data[0] << 24;
146 }
else if (bytes_per_sample == 2) {
147 sample |= data[0] << 16;
148 sample |= data[1] << 24;
149 }
else if (bytes_per_sample == 3) {
150 sample |= data[0] << 8;
151 sample |= data[1] << 16;
152 sample |= data[2] << 24;
153 }
else if (bytes_per_sample == 4) {
155 sample |= data[1] << 8;
156 sample |= data[2] << 16;
157 sample |= data[3] << 24;
169 if (bytes_per_sample == 1) {
170 data[0] =
static_cast<uint8_t
>(sample >> 24);
171 }
else if (bytes_per_sample == 2) {
172 data[0] =
static_cast<uint8_t
>(sample >> 16);
173 data[1] =
static_cast<uint8_t
>(sample >> 24);
174 }
else if (bytes_per_sample == 3) {
175 data[0] =
static_cast<uint8_t
>(sample >> 8);
176 data[1] =
static_cast<uint8_t
>(sample >> 16);
177 data[2] =
static_cast<uint8_t
>(sample >> 24);
178 }
else if (bytes_per_sample == 4) {
179 data[0] =
static_cast<uint8_t
>(sample);
180 data[1] =
static_cast<uint8_t
>(sample >> 8);
181 data[2] =
static_cast<uint8_t
>(sample >> 16);
182 data[3] =
static_cast<uint8_t
>(sample >> 24);
bool operator!=(const AudioStreamInfo &rhs) const
uint32_t ms_sample_rate_gcd_
size_t ms_to_bytes(uint32_t ms) const
Converts duration to bytes.
size_t frames_to_bytes(uint32_t frames) const
Converts frames to bytes.
uint8_t get_bits_per_sample() const
uint32_t frames_to_microseconds(uint32_t frames) const
Computes the duration, in microseconds, the given amount of frames represents.
uint32_t ms_to_samples(uint32_t ms) const
Converts duration to samples.
size_t samples_to_bytes(uint32_t samples) const
Converts samples to bytes.
uint32_t bytes_to_frames(size_t bytes) const
Convert bytes to frames.
uint8_t get_channels() const
uint32_t ms_to_frames(uint32_t ms) const
Converts duration to frames.
uint32_t frames_to_milliseconds_with_remainder(uint32_t *frames) const
Computes the duration, in milliseconds, the given amount of frames represents.
bool operator==(const AudioStreamInfo &rhs) const
uint32_t bytes_to_ms(size_t bytes) const
Convert bytes to duration in milliseconds.
uint32_t get_sample_rate() const
uint32_t bytes_to_samples(size_t bytes) const
Convert bytes to samples.
int32_t unpack_audio_sample_to_q31(const uint8_t *data, size_t bytes_per_sample)
Unpacks a quantized audio sample into a Q31 fixed-point number.
void scale_audio_samples(const int16_t *audio_samples, int16_t *output_buffer, int16_t scale_factor, size_t samples_to_scale)
Scales Q15 fixed point audio samples.
void pack_q31_as_audio_sample(int32_t sample, uint8_t *data, size_t bytes_per_sample)
Packs a Q31 fixed-point number as an audio sample with the specified number of bytes per sample.
const char * audio_file_type_to_string(AudioFileType file_type)
Helper function to convert file type to a const char string.
Providing packet encoding functions for exchanging data with a remote host.