Try (int16_t) round( x * 32767 )

On Wed, Jan 24, 2018 at 5:01 PM, Dario Fertonani via USRP-users <
usrp-users@lists.ettus.com> wrote:

> Any pointer to a C/C++ function (maybe in the UHD source code, or a doc)
> that converts IQ samples from format fc32 to sc16? I'm referring to "CPU
> sample format", not "wire sample format".
>
> For C++ UHD, I know fc32 is complex< float > and sc16 is complex< int16_t
> >. I'm tempted to assume that each component is obtained through some
> simple conversion rule (for example, multiply the float value of the
> real/imag part by 1024.0f and cast/round it to int16_t). Is this correct?
> If so, what is the scaling factor? I know things are more complicated with
> wire sample formats (especially sc12), so I wanted to get a confirmation.
>
> Thanks,
> Dario
>
> _______________________________________________
> USRP-users mailing list
> USRP-users@lists.ettus.com
> http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com
>
>
_______________________________________________
USRP-users mailing list
USRP-users@lists.ettus.com
http://lists.ettus.com/mailman/listinfo/usrp-users_lists.ettus.com

Reply via email to