Page 5 of 9

Re: SDRPLAY linux commandline tools?

Posted: Tue Mar 15, 2016 10:29 am
by Sasan
I know this is a Linux thread, but maybe my comments help someone:
I tried to compile and use this sample code on Mac OS X 10.11.3 (latest version)
At first, I was getting this error like other users:
Writing samples...
Short read, samples lost, exiting!

Library error 0, exiting...
Then, I removed this section:

Code: Select all

 if ((uint32_t)n_read < out_block_size) {
            fprintf(stderr, "Short read, samples lost, exiting!\n");
            break;
        }
        
(According to this post by user 0815: viewtopic.php?f=9&t=541&start=10#p2265 )
Now the code works as expected (I've tested both 8 and 16-bit data samples)
I recorded some samples to a file. Converted it to 8-bit signed integer with this command:
sox -t raw -r 250000 -b 8 -c 1 -e unsigned-integer sdrplay_iq.raw -t raw -r 250000 -c 1 -e signed-integer sdrplay_converted.raw
Then I converted this file to a Gqrx compatible format, using this code:
https://gist.github.com/DrPaulBrewer/91 ... a51f7febb5

Now I can listen to the recorded FM station on Gqrx.
Note: I've set the sample rate to 1.536 Msps.

Re: SDRPLAY linux commandline tools?

Posted: Tue Mar 15, 2016 12:49 pm
by 0815
i am not sure about the 16bit output if it is valid,when i play it it sounds too fast....... like played double speed....

i changed:

Code: Select all

for (i=0; i < samplesPerPacket; i++)
        {
            buffer[j++] = ibuf[i];
            buffer[j++] = qbuf[i];
        }	
and

Code: Select all

short *buffer;
and

Code: Select all

buffer = malloc(DEFAULT_BUF_LENGTH  * sizeof(short));
is the output 16 bit signed or unsigned? miri tells 16bit left justified integers...?

maybe somebody can test the 16 bit either....

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 11:16 am
by Bill_C
Hi 0815,

Your updated version of rawIQ.c this seems to work fine on my Ubuntu system for continuous data storage to file! This code doesn't include a parameter allowing the bandwidth to be set, but it looks like that should be easy to include in the mir_sdr_Init routine.

Many thanks, Bill

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 4:03 pm
by Sasan
Dear SDRPlay Team
Can you please help regarding the 8 vs 16-bit issue?
What is lost when we use your sample code (which truncates I/Q samples to 8-bits)?
I tried to convert 16-bit stored samples to another format (Gqrx or SDRSharp) but haven't succeeded so far.
Even a simple hint would be appreciated.

Thanks

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 4:58 pm
by sdrplay
The output of the RSP is 16 bits. To be compatible with the RTL code you need to remove the top 8 bits which is what...

>> 8

is doing

In the ADS-B code we have to do >> 8 + 127

so you can try with that as well.

Hope that helps,

Best regards,

SDRplay Support

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 6:14 pm
by Sasan
sdrplay wrote:The output of the RSP is 16 bits. To be compatible with the RTL code you need to remove the top 8 bits which is what...

>> 8

is doing

In the ADS-B code we have to do >> 8 + 127

so you can try with that as well.

Hope that helps,

Best regards,

SDRplay Support
I'm puzzled. If we remove the top 8 bits and then add a constant value (127) to it, we're always losing some data (the upper half which is truncated and later replaced by 127)
What I meant was: how to use the original 16-bit I/Q samples (RTL-SDR and HackRF use 8-bit samples, but higher level SDRs like USRP and BladeRF use 16-bit samples. I'm trying to use all the 16-bit data, like those high-end SDRs)

Thanks

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 6:49 pm
by sdrplay
If you want a 16 bit output, don't do the right shift and change the output buffer to 16 bits instead of 8

Best regards,

SDRplay

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 7:54 pm
by Sasan
0815 wrote:i am not sure about the 16bit output if it is valid,when i play it it sounds too fast....... like played double speed....
I have the same problem.
(I've changed the original source code to write 16-bit samples to file. Then converted the raw IQ file with sox, to change from unsigned-integer type to signed-integer. Then, using the modified rtl2gqrx utility, converted it to Gqrx compatible format. Gqrx can play it, but it's like double speed)
My source code is attached)

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 8:22 pm
by sdrplay
I'm not sure about the post processing - what is the -r option in sox doing? The sample rate used in the play_sdr is 2MHz - are you taking that into account anywhere?

Best regards,

SDRplay Support

Re: SDRPLAY linux commandline tools?

Posted: Wed Mar 16, 2016 8:31 pm
by 0815
-r, --rate RATE[k]
Gives the sample rate in Hz

i used the sample rate for it that i used when recording with rawIQ