Skip to content

Commit

Permalink
fix 24 bit IQ
Browse files Browse the repository at this point in the history
  • Loading branch information
paulh002 committed Mar 16, 2022
1 parent 561ea2d commit 5cbf086
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 1 addition & 1 deletion SoapyRadioberry-Release.vgdbsettings
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</CustomSourceDirectories>
<AutoProgramSPIFFSPartition>true</AutoProgramSPIFFSPartition>
<BuildHost>
<HostName>192.168.88.51</HostName>
<HostName>192.168.88.47</HostName>
<Transport>SSH</Transport>
<UserName>pi</UserName>
</BuildHost>
Expand Down
2 changes: 1 addition & 1 deletion SoapyRadioberry.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<TargetName>libSoapyRadioberrySDR</TargetName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|VisualGDB'">
<RemoteBuildHost>192.168.88.51</RemoteBuildHost>
<RemoteBuildHost>192.168.88.47</RemoteBuildHost>
<ToolchainID>com.sysprogs.toolchain.default-gcc</ToolchainID>
<ToolchainVersion />
<GNUTargetType>DynamicLibrary</GNUTargetType>
Expand Down
28 changes: 16 additions & 12 deletions SoapyRadioberryStreaming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand All @@ -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);
Expand Down

0 comments on commit 5cbf086

Please sign in to comment.