Resampling

Add useful snippets of code or links to entire SDR projects.
n2ic
Posts: 27
Joined: Sat May 28, 2016 7:26 pm

Re: Resampling

Post by n2ic » Tue Mar 27, 2018 10:31 pm

At the risk of showing just what a poor developer I am ...

Can anyone point me to C++ code that uses mir_sdr_StreamCallback ? I have looked at Steve Andrew's C# code, and have spent a day trying to figure out how to do that callback in C++.

Thanks,
Steve L

Reason: No reason

SteveAndrew
Posts: 213
Joined: Thu Nov 16, 2017 11:06 pm
Location: Gold Coast, QLD, Australia

Re: Resampling

Post by SteveAndrew » Wed Mar 28, 2018 12:57 am

Hi Steve

At the end of the API document there is a section marked API Usage. There is some simple code written in C/C++ that illustrates how mir_sdr_StreamInit and mir_sdr_StreamCallback are set up and used. It's written for Windows but should need little changing apart from the semaphores to get it running under various flavours of Unix/Linux. This should get the ball rolling for you. Just on the off-chance that you don't have the document, you can download it from here - https://www.sdrplay.com/docs/SDRplay_SD ... cation.pdf

On the off-chance you have not already done so, You can also download the required hardware drivers from https://www.sdrplay.com/downloads/

Good luck

Steve A

Reason: No reason

n2ic
Posts: 27
Joined: Sat May 28, 2016 7:26 pm

Re: Resampling

Post by n2ic » Wed Mar 28, 2018 1:31 am

Thanks ! I think I see what to do now. It helps to walk away and think about these things for a while.

Reason: No reason

sdrplay
Posts: 978
Joined: Wed Jan 07, 2015 7:58 am

Re: Resampling

Post by sdrplay » Wed Mar 28, 2018 5:42 am

We also have some example code on our github repository: https://github.com/SDRplay/examples

Best regards,

SDRplay Support

Reason: No reason

n2ic
Posts: 27
Joined: Sat May 28, 2016 7:26 pm

Re: Resampling

Post by n2ic » Thu Apr 12, 2018 7:33 pm

Thanks to Steve Andrews and the SDRPlay staff for their help. After some hair-pulling, I now have a DLL working using the mir streaming API that samples and decimates to 192 kHz, feeding I/Q samples to VE3NEA's Skimmer Server ( http://www.dxatlas.com/SkimServer/ ). I plan to make this available for free to anyone interested.

Steve L

Reason: No reason

stewartde
Posts: 4
Joined: Sat Dec 22, 2018 6:20 pm

Re: Resampling

Post by stewartde » Fri Jul 12, 2019 2:07 am

Dear Support,

Trying to build a C# Winforms app and I'm trying to the example you posted in StreamingSample_3.zip
However it's missing the "mir_sdr_api.dll" file as you said and that file does not exist on my system anywhere even though I am using SDRUno.
I have download the latest API and it has a sdrplay_api.dll - so I was thinking maybe the API filename was changed?
However, when trying to directly access the DLL directly as you did in your example:

Code: Select all

[DllImport("sdrplay_api.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern mir_sdr_ErrT mir_sdr_StreamInit(ref int gRdB, double fsMHz, double rfMHz, mir_sdr_Bw_MHzT bwType, mir_sdr_If_kHzT ifType, int LNAstate, ref int gRdBsystem, mir_sdr_SetGrModeT setGrMode, ref int samplesPerPacket, mir_sdr_StreamCallback_t StreamCbFn, mir_sdr_GainChangeCallback_t GainChangeCbFn, IntPtr cbContext);
When trying to call that function it errors:
System.BadImageFormatException: 'An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)'

I checked the API documents and the 'mir_sdr_StreamInit' method does not exist.
So I switched to sdrplay_api_Open() and it throws the same error.
Can you please provide any guidance?
Last edited by stewartde on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

sdrplay
Posts: 978
Joined: Wed Jan 07, 2015 7:58 am

Re: Resampling

Post by sdrplay » Fri Jul 12, 2019 1:06 pm

Looks like you need API 2.13, API 3.x has different function calls, etc.

Best regards,

SDRplay Support

Reason: No reason

linqdan2000
Posts: 4
Joined: Tue May 14, 2019 7:05 pm

Re: Resampling

Post by linqdan2000 » Fri Jul 12, 2019 1:46 pm

SteveAndrew wrote:Hi Steve

[...]

In the meantime, I've changed the code so that streaming is started before setting a decimation factor. In addition, I've added some very basic sanity checks, and another function that reports any errors to the console, along with a brief description of the error. The revised code is attached here as StreamingSample_3.zip. [...]

All the best...

Steve
Hello SteveAndrew, thank you for posting the C# example code. This example C# source code really jump started me a few months ago down the rabbit hole of SDR and DSP. Using your c# example code while reading Chris Thompson's tutorial "SDR for the Radio Amateur" really got me going.

I wanted to send your a private message thanking you but this forum would not let me or I could not figure out how.

SDR for the Radio Amateur
https://www.g0kla.com/sdr/index.php
Last edited by linqdan2000 on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

stewartde
Posts: 4
Joined: Sat Dec 22, 2018 6:20 pm

Re: Resampling

Post by stewartde » Fri Jul 12, 2019 9:34 pm

sdrplay wrote:Looks like you need API 2.13, API 3.x has different function calls, etc.
Best regards,
SDRplay Support
Is the official answer for new C# .NET projects to use an OLD API? I don't want to get left behind.
I've been working on this all through the night and I actually built a functional .NET Wrapper for the new 3.04 API.

My goal is to build a multi-antenna array for FoxHunt direction finding and maybe include GPS mapping.
I was considering purchasing the SDR Duo for the synchronized clock to help with the TDOA accuracy.
However, now I'm concerned about SDRPlay support.
Last edited by stewartde on Thu Jan 01, 1970 12:00 am, edited 0 times in total.
Reason: No reason

sdrplay
Posts: 978
Joined: Wed Jan 07, 2015 7:58 am

Re: Resampling

Post by sdrplay » Sun Jul 14, 2019 6:13 pm

If you want to use dual tuner mode of the RSPduo then you will need to use API 3.x

We don't directly support C# but there are people on here that may be able to help with C# related issues.

Best regards,

SDRplay Support

Reason: No reason

Post Reply