Page 2 of 2

Re: Tryin to get the sample sdr app to work

Posted: Wed Aug 21, 2019 1:58 am
by ka4zbn
Just an update. I went back an ran the api example as a C++ version. It ran for me very similar to what Darin reported. I used the free Visual Studio 2019 Community version to make and build the console application. Now back trying the C# version. A C# form application makes adding data plots much easier for me and the graphic designer works for adding a windows interface. However....

I am still stuck getting the dll to work in the code. I tried to add the dll as a reference in my code. The initial feedback is that the dll is not a valid COM and wonder if anybody has done the manual registering approach to install the dll? I was hoping the SDRuno would have installed the component but I don't think they programmed that way. I could not fine SDRplay in a search for the reference database.

I did find a nice set of articles by googling FSK using an SDR receiver. The api just gets you the raw data about a frequency and you still need to do all of the math routines to extra the data from the signals. One of the examples did everything using Scilab. I also looked at GNURADIO got a signal extracted but then got lost in code.

Re: Tryin to get the sample sdr app to work

Posted: Wed Aug 21, 2019 6:12 am
by sdrplay
There is an example of how to use the API in C# here...


Best regards,

SDRplay Support

Re: Tryin to get the sample sdr app to work

Posted: Thu Sep 05, 2019 5:59 pm
by ka4zbn
Thanks that was a big help. The example used the mir_sdr_play.dll instead of the new ver 3 api but that worked for me after recompiling for x64. I only have a rsp1a and ver 2.13 worked. One thing I wish that both the ver 3 api and the posted example using ver 2 had was a simple call using the callback pointer to retrieve the I and Q buffers. The FFT that I plan to use wants two double arrays to feed a complex FFT conversion. Converting the short [16384] arrays to double is not an issue but my initial attempts to extract the arrays using the pointer has not work. Indirect pointers have always been a challenge for me. Can anybody post an example? I am confused about using the lock feature, another thread, and how best to pop the data into the FFT.

From the ver 2 C# example a callback pointer is created as well as the Stream callback function, streamcbfunc(…). The program does initialize and start the streaming. However the example doesn't actually tap the streamed data. The program also uses a 1 second timer interval but I thought we would want something like 50 milliseconds.

// streaming and gain change callback function pointers
public mir_sdr_StreamCallback_t streamcbfuncptr;

public void streamcbfunc(IntPtr xi, IntPtr xq, uint firstSampleNum, int grChanged, int rfChanged, int fsChanged, uint numSamples, uint reset, IntPtr cbContext)
// lock buffers and get a copy of the IQ data - use a lock because IQ processing will probably be done in another thread
lock (bufferLock)
Marshal.Copy(xi, Ibuf, 0, (int)numSamples);
Marshal.Copy(xq, Qbuf, 0, (int)numSamples);

When I was playing around with the GNURADIO block style functions they appeared to do two separate extractions of the IQ signal. One is done before decimation to show the emitting frequencies in the pass band. A second was done after the decimation to enable filtering and audio wavefile creation. Am I correct that is what is needed in a C# application? Obviously I am still learning how to digitally process this data stream. I saw one article that said I could directly send the 192kHz data to the audio and it might sound okay for an AM signal provided the opposite offset beat did not also have a station causing interference. Sort of like a crude direct conversion radio.