From 5cbf086d6f2b812fb1ab8bcad6654b2327b26e16 Mon Sep 17 00:00:00 2001 From: Paul Date: Thu, 17 Mar 2022 00:11:50 +0100 Subject: [PATCH] fix 24 bit IQ --- SoapyRadioberry-Release.vgdbsettings | 2 +- SoapyRadioberry.vcxproj | 2 +- SoapyRadioberryStreaming.cpp | 28 ++++++++++++++++------------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/SoapyRadioberry-Release.vgdbsettings b/SoapyRadioberry-Release.vgdbsettings index f8fcf32..56b10e6 100644 --- a/SoapyRadioberry-Release.vgdbsettings +++ b/SoapyRadioberry-Release.vgdbsettings @@ -8,7 +8,7 @@ true - 192.168.88.51 + 192.168.88.47 SSH pi diff --git a/SoapyRadioberry.vcxproj b/SoapyRadioberry.vcxproj index aea4815..bfe503e 100644 --- a/SoapyRadioberry.vcxproj +++ b/SoapyRadioberry.vcxproj @@ -37,7 +37,7 @@ libSoapyRadioberrySDR - 192.168.88.51 + 192.168.88.47 com.sysprogs.toolchain.default-gcc DynamicLibrary diff --git a/SoapyRadioberryStreaming.cpp b/SoapyRadioberryStreaming.cpp index 202fb28..eecbc47 100644 --- a/SoapyRadioberryStreaming.cpp +++ b/SoapyRadioberryStreaming.cpp @@ -130,8 +130,6 @@ int SoapyRadioberry::readStream( { int i; int iq = 0; - int16_t left_sample; - int16_t right_sample; int nr_samples; void *buff_base = buffs[0]; @@ -145,22 +143,28 @@ int SoapyRadioberry::readStream( //printf("nr_samples %d sample: %d %d %d %d %d %d\n",nr_samples, (int)rx_buffer[0],(int)rx_buffer[1],(int)rx_buffer[2],(int)rx_buffer[3],(int)rx_buffer[4],(int)rx_buffer[5]); if(streamFormat == RADIOBERRY_SDR_CF32) { + int32_t left_sample; + int32_t right_sample; + for (i = 0; i < nr_samples; i += 6) { - left_sample = (int)((signed char) rx_buffer[i]) << 16; - left_sample |= (int)((((unsigned char)rx_buffer[i + 1]) << 8) & 0xFF00); - left_sample |= (int)((unsigned char)rx_buffer[i + 2] & 0xFF); - right_sample = (int)((signed char)rx_buffer[i + 3]) << 16; - right_sample |= (int)((((unsigned char)rx_buffer[i + 4]) << 8) & 0xFF00); - right_sample |= (int)((unsigned char)rx_buffer[i + 5] & 0xFF); + left_sample = (int32_t)((signed char) rx_buffer[i]) << 16; + left_sample |= (int32_t)((((unsigned char)rx_buffer[i + 1]) << 8) & 0xFF00); + left_sample |= (int32_t)((unsigned char)rx_buffer[i + 2] & 0xFF); + right_sample = (int32_t)((signed char)rx_buffer[i + 3]) << 16; + right_sample |= (int32_t)((((unsigned char)rx_buffer[i + 4]) << 8) & 0xFF00); + right_sample |= (int32_t)((unsigned char)rx_buffer[i + 5] & 0xFF); right_sample = right_sample * -1; - - target_buffer[iq++] = (float)left_sample / 2048.0; // 12 bit sample - target_buffer[iq++] = (float)right_sample / 2048.0; // 12 bit sample - //printf("nr_samples %d sample: %d %d \n", nr_samples, left_sample, right_sample); + + target_buffer[iq++] = (float)left_sample / 8388608.0; // 12 bit sample + target_buffer[iq++] = (float)right_sample / 8388608.0; // 12 bit sample } + //printf("nr_samples %d sample: %d %d \n", nr_samples, left_sample, right_sample); } if (streamFormat == RADIOBERRY_SDR_CS16) { + int16_t left_sample; + int16_t right_sample; + for (i = 0; i < nr_samples; i += 6) { left_sample = (int16_t)((signed char) rx_buffer[i]) << 16; left_sample |= (int16_t)((((unsigned char)rx_buffer[i + 1]) << 8) & 0xFF00);