From 85a0271afcb8414fb1968546b822738904e22a7b Mon Sep 17 00:00:00 2001 From: Chip Audette Date: Wed, 30 Nov 2016 13:29:31 -0500 Subject: [PATCH] AudioConvert: comment to CMSIS conversion instead --- AudioConvert_F32.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/AudioConvert_F32.h b/AudioConvert_F32.h index f0f3484..35133d3 100644 --- a/AudioConvert_F32.h +++ b/AudioConvert_F32.h @@ -33,8 +33,9 @@ class AudioConvert_I16toF32 : public AudioStream_F32 //receive Int and transmits audio_block_f32_t *inputQueueArray_f32[1]; //2 for stereo 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; - //for (int i = 0; i < len; i++) out->data[i] = (float)(in->data[i])/MAX_INT; 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 } @@ -68,6 +69,8 @@ class AudioConvert_F32toI16 : public AudioStream_F32 //receive Float and transmi private: audio_block_f32_t *inputQueueArray_Float[1]; static void convertAudio_F32ToI16(audio_block_f32_t *in, audio_block_t *out, int len) { + + //WEA Method. Should look at CMSIS arm_float_to_q15 instead: https://www.keil.com/pack/doc/CMSIS/DSP/html/group__float__to__x.html#ga215456e35a18db86882e1d3f0d24e1f2 const float MAX_INT = 32678.0; for (int i = 0; i < len; i++) { out->data[i] = (int16_t)(max(min( (in->data[i] * MAX_INT), MAX_INT), -MAX_INT));