Post
by kc2sci » Wed Aug 19, 2015 2:05 am
I think I found the problem. The SDRplay API reads and returns the samples as 16-bit integers left justified. Gr-osmosdr incorrectly considers them right justified. I located this bug by writing samples out to a file and then looking at the waveform in audacity: all the samples had a mid level much higher than zero. Here is the patch:
--------------------------------------------------------------------------------------------------------------------
diff --git a/lib/sdrplay/sdrplay_source_c.cc b/lib/sdrplay/sdrplay_source_c.cc
index 81926a3..5cf11f1 100644
--- a/lib/sdrplay/sdrplay_source_c.cc
+++ b/lib/sdrplay/sdrplay_source_c.cc
@@ -238,7 +238,7 @@ int sdrplay_source_c::work( int noutput_items,
{
for (int i = _buf_offset; i < _dev->samplesPerPacket; i++)
{
- *out++ = gr_complex( float(_bufi) * (1.0f/2048.0f), float(_bufq) * (1.0f/2048.0f) );
+ *out++ = gr_complex( float(_bufi) * (1.0f/32768.0f), float(_bufq) * (1.0f/32768.0f) );
}
cnt -= (_dev->samplesPerPacket - _buf_offset);
}
@@ -248,7 +248,7 @@ int sdrplay_source_c::work( int noutput_items,
mir_sdr_ReadPacket(_bufi.data(), _bufq.data(), &sampNum, &grChanged, &rfChanged, &fsChanged);
for (int i = 0; i < _dev->samplesPerPacket; i++)
{
- *out++ = gr_complex( float(_bufi) * (1.0f/2048.0f), float(_bufq) * (1.0f/2048.0f) );
+ *out++ = gr_complex( float(_bufi) * (1.0f/32768.0f), float(_bufq) * (1.0f/32768.0f) );
}
cnt -= _dev->samplesPerPacket;
}
@@ -259,7 +259,7 @@ int sdrplay_source_c::work( int noutput_items,
mir_sdr_ReadPacket(_bufi.data(), _bufq.data(), &sampNum, &grChanged, &rfChanged, &fsChanged);
for (int i = 0; i < cnt; i++)
{
- *out++ = gr_complex( float(_bufi) * (1.0f/2048.0f), float(_bufq) * (1.0f/2048.0f) );
+ *out++ = gr_complex( float(_bufi[i]) * (1.0f/32768.0f), float(_bufq[i]) * (1.0f/32768.0f) );
}
_buf_offset = cnt;
}
Last edited by
kc2sci on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason