dsd: new rtl-sdr feature

Status
Not open for further replies.

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
Nearly 5 years later, I've finally managed to carve out some time to add rtl-sdr support natively to dsd.
Better late than never.(y)
I've made so may changes to this code base over the years it's not funny. o_O

Any feedback/testing/etc is welcomed.
It would be handy to expose 'dongle.ppm_error' to the command line options (used in 'verbose_ppm_set' in 'open_rtlsdr_stream').
As not all RTLs are created equal, 0 would not be OK in most cases.
 

k8jss

Member
Premium Subscriber
Joined
Jul 14, 2004
Messages
15
Location
Columbus, OH, USA
Better late than never.(y)
I've made so may changes to this code base over the years it's not funny. o_O
Pull requests are always welcomed, its open source for a reason :)

It would be handy to expose 'dongle.ppm_error' to the command line options (used in 'verbose_ppm_set' in 'open_rtlsdr_stream').
As not all RTLs are created equal, 0 would not be OK in most cases.
Great suggestion, I'll add some more cli options.
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
Just climbed from one rabbit hole to another to try this out.
Compiled with Cygwin (32 bit) and tested this DSD with RTL as source and it seems to be working OK.

Feels strange going back to this version, I will need to look at merging into my code so I can give it a better looking into.
 

lwvmobile

DSD-FME
Joined
Apr 26, 2020
Messages
1,297
Location
Lafayette County, FL
Nearly 5 years later, I've finally managed to carve out some time to add rtl-sdr support natively to dsd.

Any feedback/testing/etc is welcomed.


I compiled it and tried out a local NXDN voice channel, and it works pretty well so far. In the future, might we be able to see more control over the RTL, such as gain control, dc offset, ppm, all those goody bits? Also, is there any way to remote control the channel in DSD, or a way to implement it without jumping through tons of hops. My programming chops are pretty terrible.

Code:
lwvmobile@Zorin-Core-PowerEdge-T310:/STORAGE/2020/lwvmobile/SDR/dsd-rtl-sdr/build$ padsp -m nxdn48 -- ./dsd -fi -i rtl:0 -o /dev/dsp -c 154.9875M -d NXDN48LO
Digital Speech Decoder 1.7.0-dev (build:HEAD-HASH-NOTFOUND)
mbelib version 1.3.0
Setting symbol rate to 2400 / second
Enabling only GFSK modulation optimizations.
Decoding only NXDN 4800 baud frames.
Using center freq: 154987500
Writing mbe data files to directory NXDN48LO
Audio Out Device: /dev/dsp
Audio In Device: rtl:0
Found Rafael Micro R820T tuner
Tuner gain set to automatic.
Tuned to 155239500 Hz.
Oversampling input by: 21x.
Oversampling output by: 1x.
Buffer size: 8.13ms
Exact sample rate is: 1008000.009613 Hz
Sampling at 1008000 S/s.
Output at 48000 Hz.
Sync:  +NXDN48    mod: GFSK inlvl: 50% VOICE e:===
Sync:  +NXDN48    mod: GFSK inlvl: 30% VOICE e:========
Sync:  +NXDN48    mod: GFSK inlvl: 19% VOICE e:======R===
Sync:  +NXDN48    mod: GFSK inlvl: 14% VOICE e:=======
Sync:  +NXDN48    mod: GFSK inlvl: 12% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl: 10% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl: 10% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl:  9% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl:  9% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl:  9% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl:  9% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl:  9% VOICE e:
Sync:  +NXDN48    mod: GFSK inlvl:  9% VOICE e:

Also, and it may just be the way I have things set up on my end, but using Zorin/Ubuntu 18.04 and also LM19, I've had issues with Port Audio in general. Is there any chance in the future of getting direct ALSA or Pulse Audio input and output. Currently, when using DSD, I'm having to use padsp to emulate OSS audio to get both input and output to function properly. Here is a few examples of what I've been having to use for NXDN48.

Here is what happens when I try to use pa for both input and output, ALSA errors, and no audio output on voice decoding.

Code:
lwvmobile@Zorin-Core-PowerEdge-T310:/STORAGE/2020/lwvmobile/SDR/dsd-rtl-sdr/build$ ./dsd -a
Digital Speech Decoder 1.7.0-dev (build:HEAD-HASH-NOTFOUND)
mbelib version 1.3.0
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave

PortAudio version number = 1246720
PortAudio version text = 'PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4'
Number of devices = 5
--------------------------------------- device #0
Name                        = HDA ATI HDMI: 0 (hw:0,3)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #1
Name                        = Microsoft® LifeCam HD-5000: USB Audio (hw:1,0)
Host API                    = ALSA
Max inputs = 1, Max outputs = 0
Default sample rate         = 44100.00
--------------------------------------- device #2
Name                        = hdmi
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #3
Name                        = pulse
Host API                    = ALSA
Max inputs = 32, Max outputs = 32
Default sample rate         = 44100.00
--------------------------------------- device #4
[ Default Input, Default Output ]
Name                        = default
Host API                    = ALSA
Max inputs = 32, Max outputs = 32
Default sample rate         = 44100.00
----------------------------------------------
lwvmobile@Zorin-Core-PowerEdge-T310:/STORAGE/2020/lwvmobile/SDR/dsd-rtl-sdr/build$ ./dsd -fp -i pa:4 -o pa:4
Digital Speech Decoder 1.7.0-dev (build:HEAD-HASH-NOTFOUND)
mbelib version 1.3.0
Setting symbol rate to 9600 / second
Enabling only GFSK modulation optimizations.
Decoding only ProVoice frames.
Initializing portaudio.
ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_dmix.c:1052:(snd_pcm_dmix_open) unable to open slave
Using portaudio device 4.
Name                        = default
Using portaudio device 4.
Name                        = default
Audio In/Out Device: pa:4
Sync:  -ProVoice  mod: GFSK inlvl: 58% VOICE e:======R===========R=============R
Sync:  -ProVoice  mod: GFSK inlvl: 41% VOICE e:======R===========R=============R
Sync:  -ProVoice  mod: GFSK inlvl: 32% VOICE e:=======R============R========RM=====
Sync:  -ProVoice  mod: GFSK inlvl: 29% VOICE e:=======R=========R=========R======RM
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:==RR==RRM
Sync:  -ProVoice  mod: GFSK inlvl: 26% VOICE e:==
Sync:  -ProVoice  mod: GFSK inlvl: 26% VOICE e:====
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 26% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:=
Sync:  -ProVoice  mod: GFSK inlvl: 27% VOICE e:
Sync:  -ProVoice  mod: GFSK inlvl: 25% VOICE e:=======
Sync:  -ProVoice  mod: GFSK inlvl: 25% VOICE e:======R========R==========R========RM
Sync: no sync

If I use pa:4 for input and pa:3 for output, I usually end up with this kind of error.

Code:
Syncing voice output stream
An error occured while using the portaudio output stream
Error number: -9983
Error message: Stream is stopped
 

hrh17

Member
Joined
Mar 4, 2015
Messages
147
Location
.
Not having much luck getting this version of DSD running. All my RTL drivers are installed and working as I can get Op25 running with no issues, I'm using the following command line

Code:
op25@op25-Z390-GAMING-SLI:~/dsd$ dsd -f1 -i rtl:0 -o pa:10 c 499.9625M
Digital Speech Decoder 1.7.0-dev (build:v1.6.0-92-g290a220)
mbelib version 1.3.0
Decoding only P25 Phase 1 frames.
Initializing portaudio.
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Using portaudio device 10.
Name                        = sysdefault
Audio Out Device: pa:10
Error, couldn't open rtl:0

Code:
rtl_test
Found 1 device(s):
  0:  Realtek, RTL2838UHIDIR, SN: VHF

Using device 0: Generic RTL2832U OEM
Found Rafael Micro R820T tuner
Supported gain values (29): 0.0 0.9 1.4 2.7 3.7 7.7 8.7 12.5 14.4 15.7 16.6 19.7 20.7 22.9 25.4 28.0 29.7 32.8 33.8 36.4 37.2 38.6 40.2 42.1 43.4 43.9 44.5 48.0 49.6 
[R82XX] PLL not locked!
Sampling at 2048000 S/s.

Info: This tool will continuously read from the device, and report if
samples get lost. If you observe no further output, everything is fine.

Reading samples in async mode...



Code:
dsd -a
Digital Speech Decoder 1.7.0-dev (build:v1.6.0-92-g290a220)
mbelib version 1.3.0
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib pcm.c:2495:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib pcm_route.c:867:(find_matching_chmap) Found no matching channel map
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock

PortAudio version number = 1246720
PortAudio version text = 'PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4'
Number of devices = 23
--------------------------------------- device #0
Name                        = HDA Intel PCH: ALC1220 Analog (hw:0,0)
Host API                    = ALSA
Max inputs = 2, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #1
Name                        = HDA Intel PCH: ALC1220 Digital (hw:0,1)
Host API                    = ALSA
Max inputs = 0, Max outputs = 2
Default sample rate         = 44100.00
--------------------------------------- device #2
Name                        = HDA Intel PCH: ALC1220 Alt Analog (hw:0,2)
Host API                    = ALSA
Max inputs = 2, Max outputs = 0
Default sample rate         = 44100.00
--------------------------------------- device #3
Name                        = HDA NVidia: HDMI 0 (hw:1,3)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #4
Name                        = HDA NVidia: HDMI 1 (hw:1,7)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #5
Name                        = HDA NVidia: HDMI 2 (hw:1,8)
Host API                    = ALSA
Max inputs = 0, Max outputs = 2
Default sample rate         = 44100.00
--------------------------------------- device #6
Name                        = HDA NVidia: HDMI 3 (hw:1,9)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #7
Name                        = HDA NVidia: HDMI 4 (hw:1,10)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #8
Name                        = HDA NVidia: HDMI 5 (hw:1,11)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #9
Name                        = HDA NVidia: HDMI 6 (hw:1,12)
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #10
Name                        = sysdefault
Host API                    = ALSA
Max inputs = 128, Max outputs = 128
Default sample rate         = 48000.00
--------------------------------------- device #11
Name                        = front
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #12
Name                        = surround21
Host API                    = ALSA
Max inputs = 0, Max outputs = 128
Default sample rate         = 44100.00
--------------------------------------- device #13
Name                        = surround40
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #14
Name                        = surround41
Host API                    = ALSA
Max inputs = 0, Max outputs = 128
Default sample rate         = 44100.00
--------------------------------------- device #15
Name                        = surround50
Host API                    = ALSA
Max inputs = 0, Max outputs = 128
Default sample rate         = 44100.00
--------------------------------------- device #16
Name                        = surround51
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #17
Name                        = surround71
Host API                    = ALSA
Max inputs = 0, Max outputs = 8
Default sample rate         = 44100.00
--------------------------------------- device #18
Name                        = iec958
Host API                    = ALSA
Max inputs = 0, Max outputs = 2
Default sample rate         = 44100.00
--------------------------------------- device #19
Name                        = spdif
Host API                    = ALSA
Max inputs = 0, Max outputs = 2
Default sample rate         = 44100.00
--------------------------------------- device #20
Name                        = pulse
Host API                    = ALSA
Max inputs = 32, Max outputs = 32
Default sample rate         = 44100.00
--------------------------------------- device #21
Name                        = dmix
Host API                    = ALSA
Max inputs = 0, Max outputs = 2
Default sample rate         = 48000.00
--------------------------------------- device #22
[ Default Input, Default Output ]
Name                        = default
Host API                    = ALSA
Max inputs = 32, Max outputs = 32
Default sample rate         = 44100.00
 

UR3AKF

Newbie
Joined
Apr 7, 2021
Messages
1
Feature WIP: RTL-SDR Support by szechyjs · Pull Request #108 · szechyjs/dsd is working on Raspberry Pi 4 using onboard and external USB audio card.

I had no luck using PortAudio despite of the sample rate values shown in "dsd -a" output.

To deal with 48000 sample rate I use such commands:
Bash:
sudo modprobe snd_pcm_oss
dsd -i rtl:0 -o /dev/dsp2 -c FREQ

For me, most welcomed features are sample rate for audio and option to choose a DMR slot.

Anyway, great work!
 

kd4e

Member
Joined
Jun 19, 2006
Messages
164
Location
Nevils, GA
Usage: <code>dsd -i rtl:0 -o pa:1 -c 446M</code>

Does this presume that gqrx is set to a frequency where something that dsd can decode is found?

Would this work if trunk-recorder is set to such a frequency and this is linked somehow from it?

I'm looking to decode DMR (TRBO).

Thanks ... always learning ...
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
Usage: <code>dsd -i rtl:0 -o pa:1 -c 446M
The frequency is tuned to (on command line) by the newly add tuner code in DSD, you would not need/use gqrx.
No idea about the 'trunk-recorder'.

I've found you need a strong signal and a dongle with good PPM (-1 to 1) for this new code to work.
Tweaking of this code is needed to improve with weaker signals. (this may have something to do with the gain been set to auto)
 

kd4e

Member
Joined
Jun 19, 2006
Messages
164
Location
Nevils, GA
Is this designed to run inside of SDRtrunk? I just get a bunch of instructions, executing from the command line - no error.
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
Is this designed to run inside of SDRtrunk? I just get a bunch of instructions, executing from the command line - no error.
No. Doesn't SDRTrunk have a DMR decoder built in now? I've not used it since version 0.2 or 0.3.
This DSD is a standalone program when used with the tuner option.
"I just get a bunch of instructions". I'm guessing you mean the timeslot info that scrolls when tuned to a DMR signal. This is normal but don't expect it to show much as it does not have code to process the upper layers of DMR.

Is there any binary for those of us that dont know to compile ?
Not for this 'tuner' branch of DSD.
You would be better off sticking with DSD+ if you don't intend to experiment with the DSD code.
 

kd4e

Member
Joined
Jun 19, 2006
Messages
164
Location
Nevils, GA
I'm sorry, I left out the word "help" in front of "instructions". It's not executing - it's telling me that the command string isn't correct - or so it seems.
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
It should be telling you somewhere what the cause of the error is, before the output of the 'help' text.
- Could be the RTL driver not setup
- Portaudio not compiled into DSD
- Portaudio device # not correct
- Not using correct default audio device (if not using portaudio)
- command line syntax

If you use the command as you posted, it should work OK but may there maybe an issue with portaudio in Linux.
Ideally the portaudio code needs to swapped out for ALSA code for the newer Linux distros.
There is a github somewhere which has this code and you could merge it by hand.
I've done this to work with Debian but not done much testing with it as Linux makes doing everything harder than it needs to be.
 

kd4e

Member
Joined
Jun 19, 2006
Messages
164
Location
Nevils, GA
<code> pi@raspberrypi:~ $ dsd -i rtl:0 -o pa:1 -c 446M
Digital Speech Decoder 1.7.0-dev (build:v1.6.0-92-g290a220)
mbelib version 1.3.0

Usage: dsd [options] Live scanner mode
or: dsd [options] -r <files> Read/Play saved mbe data from file(s)
or: dsd -h Show help

Display Options:
-e Show Frame Info and errorbars (default)
-pe Show P25 encryption sync bits
-pl Show P25 link control bits
-ps Show P25 status bits and low speed data
-pt Show P25 talkgroup info
-q Don't show Frame Info/errorbars
-s Datascope (disables other display options)
-t Show symbol timing during sync
-v <num> Frame information Verbosity
-z <num> Frame rate for datascope

Input/Output options:
-i <device> Audio input device (default is /dev/audio, - for piped stdin)
-o <device> Audio output device (default is /dev/audio)
-d <dir> Create mbe data files, use this directory
-r <files> Read/Play saved mbe data from file(s)
-g <num> Audio output gain (default = 0 = auto, disable = -1)
-n Do not send synthesized speech to audio output device
-w <file> Output synthesized speech to a .wav file
-a Display port audio devices

Scanner control options:
-B <num> Serial port baud rate (default=115200)
-C <device> Serial port for scanner control (default=/dev/ttyUSB0)
-R <num> Resume scan after <num> TDULC frames or any PDU or TSDU

Decoder options:
-fa Auto-detect frame type (default)
-f1 Decode only P25 Phase 1
-fd Decode only D-STAR
-fi Decode only NXDN48* (6.25 kHz) / IDAS*
-fn Decode only NXDN96 (12.5 kHz)
-fp Decode only ProVoice*
-fr Decode only DMR/MOTOTRBO
-fx Decode only X2-TDMA
-l Disable DMR/MOTOTRBO and NXDN input filtering
-ma Auto-select modulation optimizations (default)
-mc Use only C4FM modulation optimizations
-mg Use only GFSK modulation optimizations
-mq Use only QPSK modulation optimizations
-pu Unmute Encrypted P25
-u <num> Unvoiced speech quality (default=3)
-xx Expect non-inverted X2-TDMA signal
-xr Expect inverted DMR/MOTOTRBO signal

* denotes frame types that cannot be auto-detected.

Advanced decoder options:
-A <num> QPSK modulation auto detection threshold (default=26)
-S <num> Symbol buffer size for QPSK decision point tracking
(default=36)
-M <num> Min/Max buffer size for QPSK decision point tracking
(default=15)

Report bugs to: szechyjs/dsd </code>
 

thewraith2008

Member
Joined
Nov 22, 2016
Messages
1,867
You need to switch branches in your local cloned DSD repo and then recompile as normal.
NOTE: This 'rtl-sdr' branch is only for RTL SDRs (dongles).

From within your DSD folder, type the following to list the branches in the repo and determine the current checked out branch. (most likely 'master')
Code:
git branch -a
In the response, the "*" will indicate the checked out branch.

If the branch 'rtl-sdr' is listed, then type the following command to switch to it.
Code:
git checkout rtl-sdr


Confirm with
Code:
git branch -a
and see if "*" is now next to 'rtl-sdr'.

When compiling this branch you will need the dependencies for the 'librtlsdr'. (may already exist if you have already been using a RTL on the PC)
 

kd4e

Member
Joined
Jun 19, 2006
Messages
164
Location
Nevils, GA
You need to switch branches in your local cloned DSD repo and then recompile as normal.
NOTE: This 'rtl-sdr' branch is only for RTL SDRs (dongles).

From within your DSD folder, type the following to list the branches in the repo and determine the current checked out branch. (most likely 'master')
Code:
git branch -a
In the response, the "*" will indicate the checked out branch.

Code:
pi@raspberrypi:~/dsd $ git branch -a
  =a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/feature/cpp
  remotes/origin/master
  remotes/origin/rtl-sdr
pi@raspberrypi:~/dsd $

If the branch 'rtl-sdr' is listed, then type the following command to switch to it.
Code:
git checkout rtl-sdr

No response - do I need to specify the /remotes/origin/ location - or is that a problem that needs to be addressed, first?
 
Status
Not open for further replies.
Top