From 6a5d40a4595c608bf6576947e05a722acdf946dd Mon Sep 17 00:00:00 2001 From: joerg Date: Sun, 15 May 2022 11:40:43 +0200 Subject: [PATCH] fixed a typo int -> float -> int conversion is now lossless credits to jcj83429, same as https://github.com/chipaudette/OpenAudio_ArduinoLibrary/pull/8/commits/93a3732fbff4816c4040416533fabeda9974cf99 --- AudioConvert_F32.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AudioConvert_F32.h b/AudioConvert_F32.h index 485e867..bc7f25f 100644 --- a/AudioConvert_F32.h +++ b/AudioConvert_F32.h @@ -36,7 +36,7 @@ class AudioConvert_I16toF32 : public AudioStream_F32 //receive Int and transmits static void convertAudio_I16toF32(audio_block_t *in, audio_block_f32_t *out, int len) { //WEA Method. Should look at CMSIS arm_q15_to_float instead: https://www.keil.com/pack/doc/CMSIS/DSP/html/group__q15__to__x.html#gaf8b0d2324de273fc430b0e61ad4e9eb2 - const float MAX_INT = 32678.0; + const float MAX_INT = 32768.0; for (int i = 0; i < len; i++) out->data[i] = (float)(in->data[i]); arm_scale_f32(out->data, 1.0/MAX_INT, out->data, out->length); //divide by 32678 to get -1.0 to +1.0 }