Data overflow in shift float to int32

Hi,

I use 21571 to process audio datas, the datas format are float. But when I submit audio datas to SPORT to send datas out using  adi_sport_SubmitBuffer() function, the datas need to be int32, I have some questions now.

1) Assum that I use 32bits i2s to transfer datas, what's the format in i2s data line, is it 1.31?

2) It seems like there is auto convert in SHARC cores, after I receive 1.31 datas, I just save datas in int32 buffer and then assign buffers to float variables without any function to convert 1.31 to float. Also when I transmit datas, I only submit int32 datas which is shifted from float without convert int32 to 1.31.

3) If it's 1.31 format, datas range from -1.0 to 1.0 - 2^-31, I find that when float datas out of range, it will overflow to zero rather than clip. How to avoid overflow when shift float datas to int32. Or can I directly submit float datas to SPORT?

Thanks.

  • 0
    •  Analog Employees 
    on Jun 11, 2021 3:26 PM

    Hi,

    We are looking into this query and we will get back to you as early next week.

    Regards,
    Santhakumari.K

  • 0
    •  Analog Employees 
    on Jun 17, 2021 8:41 AM

    Hi Foster,

    Data that is received or transmitted in the SPORT will be a binary, 2's complement format. The DSP interprets the data in fractional format, where all numbers are between -1 and 0.9999999.

    While using the data length as 32, you can assume that the data will be 1.31 fixed point value. You can use the conv_float_by built-in function to convert the fixed point value to floating point value (received from ADC). After processing the float data convert it again to the fixed point data using the conv_fix_by built-in function before sending to DAC.

    You can refer the attached example, there we have used the above built-in functions for the conversions.

    5123.ADC DAC Audio Playback (SC589 SHARC).zip

    Regards,
    Santhakumari.K