Showing results for 
Search instead for 
Did you mean: 

Conversion of int to float and float to int

Associate II

Hello guys, I hope you're doing well, I'm currently trying to replicate a video I saw on YouTube about audio processing using stm, I'm just starting to develop for stm and I'm having some doubts, mainly in terms of libs. I'm trying to convert between int and float and I'm almost sure there's a lib that does this, in the video it uses INT16_TO_FLOAT and FLOAT_TO_INT16, do you know how I can use them? Below is a section of the video showing how they are used. Thanks in advance for your help.


leftIn = INT16_TO_FLOAT * inBufPtr[n];

outBufPtr[n] = (int16_t)(FLOAT_TO_INT16 * leftOut);


There's no need to complicate this with typedefs.

int16_t x = 42;
float x2 = (float) x;

float y = 42.0f;
int16_t y2 = (int16_t) y;


If you feel a post has answered your question, please click "Accept as Solution".