IQ file and stream converters for SDR

Notes on streaming IQ data

Looking for an alternative to CubicSDR that would provide soapySDR library support, and backend frequency control without at GUI


links:

audacity: http://play.fallows.ca/wp/radio/software-defined-radio/recording-smartsdr-iq-data-audacity/

convert rtlsdr to sdr-sharp: https://github.com/Marcin648/iqToSharp

demod (demodulate IQ streams)  https://github.com/cubehub/demod

rust-airspy  (get stream from airspy)  https://github.com/cubehub/rust-airspy

andres vahter blog: https://andres.svbtle.com/pipe-sdr-iq-data-through-fm-demodulator-for-fsk9600-ax25-reception

rtl_tcp -a 192.168.2.106

rtl_fm can also output raw signed 16 bit IQ data. – as in this example from vahter’s blog: rtl_fm -f 437.505M -M raw –s 1024000r 22050 | doppler -tle “ESTCUBE 1” cubesat.txt | demod -M fm -deviation 3.5k | multimon-ng -t raw -a FSK9600 /dev/stdin

liquid-dsp c sdr dsp lib : https://github.com/jgaeddert/liquid-dsp

sv3exp – interesting experiment with piping iq data in linux command line:  https://sv3exp.blogspot.com/2019/09/decoding-ft8-in-with-any-sdr-like-usrp.html

ha7ilm csdr (command line sdr processor)  https://github.com/ha7ilm/csdr

**sdrplay rtl_tcp fork  https://github.com/SDRplay/RSPTCPServer

cloud-sdr internet streaming:  http://www.cloud-sdr.com/streaming-iq-over-internet-listen-remotely-to-airport-radio/ cloud-sdr also looks to be out of business.

 

interesting post about requests for command line cubicsdr and related : https://github.com/cjcliffe/CubicSDR/issues/654

rx tools (an update of some of the rtl stuff using soapysdr  https://github.com/rxseger/rx_tools

rx_tools, in theory, is a good prospect, but the code is several years out of date, gives errors on devices, is unsupported – just doesn’t work yet.

There are many good examples of IQ streaming with rtl_fm and rtl_tcp, but of course they only suppport rtlsdr.

Prospects

pothos sdr : flowgraph https://github.com/pothosware/PothosCore/wiki

**luaradio – similar to gnu-radio and looks like will run with macports:  https://github.com/vsergeev/luaradio This is a flowgraph language like Gnu-radio. But its lightweight. If the device support is ok, then it looks like there are flowgraph modules that would allow tcp data in/out as well as audio. This is primarily a linux app – but if you ran it on r-pi it could make a good front end for a lot of devices. Also it may run in Mac OS with some audio tweaks. ie., portaudio and pulseaudio.

**sdrGlut this app runs on mac os and streams iq https://github.com/righthalfplane/SdrGlut – I was not able to find a method of external frequency control. It may be added in future releases as this app is in active current development.  Also it runs sdrplay rspdx.

**gnu-radio: Well supported and active development. Not sure about device support for common hobbyist radios like sdrplay, airspyhf, etc.,  gnu-radio: http://play.fallows.ca/wp/radio/software-defined-radio/gnuradio-ssb-receiver/

**worst-case scenario. Actually build something with soapy-sdr, hamlib, and csdr.

docs

**PLSDR – some nice theory here: https://arachnoid.com/PLSDR/

**IQ data for dummies: http://whiteboard.ping.se/SDR/IQ

 

Max8radio project

New version of software define radio for Max/MSP  (in progress)

github repository: https://github.com/tkzic/max8radio

Notes

goals and strategy

The new approach will be to remove most of the device handling code from Max. Instead providing device interfaces from existing device libraries, like soapy-sdr, hamlib, gnu-radio, etc., The Max portion of the project will read IQ files, perform DSP, and other magic.

The first platform will be Max8 in Mac OS Catalina

projects

Max + CubicSDR + hamlib

See working prototype below. This setup uses CubicSDR as a device driver to send IQ data into Max’s input audio stream. CubicSDR supports many devices via soapySDR. It supports networked rig control via Hamlib.

Advantages of this system: It works now. It runs in Windows. It runs over the a local network. The software is managed and distributed by somebody else.

Disadvantages: Its not an elegant solution – ie., not self contained within Max. It requires installation and setup of CubicSDr. The software is managed and distributed by somebody else – so it could stop working at any time.

rx_tools + hamlib

rx_tools is an update of some of the rtl tools, like rtl_fm. It includes soapySDR device support. If hamlib is added to rx_tools, then you could do the same networked frequency control, and IQ streaming as CubicSDR – using rigctld. Without the overhead of running CubicSDR. The downside it that it’s yet another program to maintain and distribute.

Next step: look at source code for rx_tools and estimate scope of hamlib intergration.

openwebrx and websdr API

openwebrx  https://www.openwebrx.de/

Websdr  http://websdr.org/

These sites provide access to SDR devices connected to web servers. Although they don’t stream IQ data, it would be interesting to build a Max front end to the APIS.

background information

See previous posts:

External programs required

  • hamlib (macports)
  • cubicSDR (see link above)
  • netcat (nc) (built into Mac OS terminal)

notes on rigctld commands

Best results using one letter commands with single quotes:

echo 'F 7023000' | nc -w 1 localhost 4532

Prepend ‘+’ for more feedback, like this:

% echo '+F 7023000' | nc -w 1 localhost 4532
set_freq: 7023000
RPRT 0

Latest prototypes

Links to latest working projects (from newest to oldest)

 

First Max test project

This is an update of the test done with CubicSDR and RTLSDR as described here: https://reactivemusic.net/?p=19802

CubicSDR is great but eventually the goal is to pare down the interface between the SDR device and Max. Something like a command line IQ filter would be ideal:  https://github.com/xmikos/simplesoapy

Hardware and system setup

This test uses an Airspy Discovery HF+, but any device supported in CubicSDR should work – that’s the point of this exercise.

Using BlackHole from Existential Audio https://existential.audio/blackhole/

as an alternative to Soundflower to route the IQ (audio stream) data from CubicSDR to Max. You could also use a cable to connect output of one audio device to input of another, etc.,

Signal path:

Antenna -> Airspy -> CubicSDR -> rigctld -> Max

CubicSDR settings

  • Plug in Airspy device before launching CubicSDR, so it will be discovered on the setup screen
  • On the main display, click just to the right of the mode buttons to bring up a drop down menu of audio devices
  • select I/Q mode
  • select the audio device, or “BlackHole 2ch”, that you will use to route audio to Max
  • click on any of the frequency digits, press space, and enter in the same frequency as the Center Frequency (e.g., 7000000)
  • click the ‘V’ to the left of the frequency digits, to select ‘delta lock mode’. This causes the frequency and center frequency to sync.
  • Be careful not to click anywhere in the waterfall window – or this will mess up the sync
  • Under Rig Control menu:
    • Select “Hamlib NET rigctl” as the model
    • Enter localhost:4532 as the control port
    • Select 57600 as the serial rate
    • Make sure that “follow rig” and “floating center” are checked
    • After you get the rigctld daemon started, come back here and ‘Check’ ‘enable rig’. If it doesn’t stay checked, then there is a problem with the connection.
  • Under the Audio sample rate menu, select the correct sample rate for your audio device (e.g. 96k)

Notes: It seems there is some kind of AGC hardwired into CubicSDR.  https://github.com/cjcliffe/CubicSDR/issues/826

TCP and rigctld settings

  • Open a terminal window
  • type: rigctld -m 1 4532 &
  • This starts the server running in the background using the HAMLIB test dummy rig
  • to set frequency to 7.010 MHz, type:

    echo ‘F 7010000’ | nc -w 1 localhost 4532

  • This should change the center frequency and frequency in CubicSDR

Max settings

For this test, you can use any of the MaxSDR tutorials available  at https://github.com/tkzic/max8radio

We’ll be using maxsdr7a.maxpat

ignore the max-console messages about missing externals.

The key is to choose the default audio input device and set it to be the same as what is coming out of CubicSDR.  ie., “BlackHole 2ch”

  • Set the audio input device to match CubicSDR, as described above. Also match the sample rate (e.g., 96k)
  • Set the audio output device to your internal soundcard/speakers
  • Start audio and recall preset 1 or some normal settings for SSB
  • It should be receiving I/Q data now from Cubic SDR
  • Note: may need to flip the I/Q input due to anomaly in CubicSDR.
  • Now load another Max patch to do the frequency control: rigctld1.maxpat

This patch sends frequency data to the rigctld daemon via the [shell] object. You can change the frequency using the number box.

That’s about it for now.

Updating Max/MSP internet sensor projects

Notes for updating from Max6 to Max8 in Mac OS Catalina

In general, 32 bit code will not work

Link to internetsensors project: https://reactivemusic.net/?p=5859

Github: https://github.com/tkzic/internet-sensors

1. mxj object

Need to update, but the Oracle link leads to a dead end message. Go to the Oracle download link https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html but instead of pressing the green download button, <ctrl> click and save the link as described in the instructions from intrepidOlivia in this link https://gist.github.com/wavezhang/ba8425f24a968ec9b2a8619d7c2d86a6

2. aka.objects

I have used aka.shell, and aka.speech – among others. These objects no longer work. Replace with Jeremy Bernstein’s shell object: https://github.com/jeremybernstein/shell/releases/tag/1.0b2

NOTE: There’s a problem with [shell] – it rejects input that is converted to a symbol using [tosymbol].

This can be fixed by using from symbol – or just eliminating [tosymbol] – it make affect the stderr-stdout redirection token, ie., “>” and other special characters but for now [shell] does not accept symbol input

aka.speech can be replaced using the “say” command in the shell.  more details to follow about voice parameters.

‘say’ has similar params to aka.speech, eg., voice name and rate. There are voices for specific languages. This feature could be used, for example, to match the language from a Tweet to an appropriate voice

3. Twitter streaming API

I revised the php code for the Twitter streaming project, to use the coordinates of a corner of the city polygon bounding box. That seems to be more reliable than the geo coordinates which are absent from most Tweets.

There is a new API in the works – but its difficult to decipher the Twitter API docs because they have so many products and the documentation is obtuse.

Also it would be interesting to extract the “language” field and use it to select which voice to use in the speech synthesizer. Or even have an english translation option.

4. Echonest API

Echonest was absorbed into Spotify. The API is gone. But the Spotify API does have some of the feature detection and analysis code. But it doesn’t allow you to submit your own audio clips. There are also some efforts to preserve some of the Echonest stuff like the blog by Paul Lamere, and the remix code. Here are a few links I found to get started.

Spotify API (features) https://developer.spotify.com/console/get-audio-features-track/?id=06AKEBrKUckW0KREUWRnvT

Echonest blog:  https://blog.echonest.com/

Amen – algorithmic remix project:  https://github.com/algorithmic-music-exploration/amen

5. Google speech to text

Several issues:

  • Replacing [aka.shell] with [shell] – instead of using [tosymbol], this workaround seems to help

  • Now have rewritten all of the recording code, and shell interactions with Google.
  • Still need to work on voice options for the ‘say’ command (text to speech)
  • pandorabots API problems turned out that the URL needed to be https instead of http

6. twitter curl project

Looks like xively.com is gone. Maybe purchased by google? Anyway – this project is toast

7. Twitter via Ruby

Got this working again.

8. Bird calls from xeno-canto.com

This patch has been completely re-written. The old API was obsolete. This version uses [dict] and [maxurl] to format and execute the initial query. Then it uses [jit.uldl] to download the mp3 file with the bird-call audio.  Interesting that [maxurl] would not download the file using the “download” URL. It only worked with a URL containing the actual file name.

9. ping

Needed to reinstall ruby gems using xcrun (see above)

seems to be a problem with mashape:

Could not resolve host: igor-zachetly-ping-uin.p.mashape.com (Patron::HostResolutionError)

[mashape was acquired by rapidapi.com – so will need to refactor the code in the ruby server.]

 

Test

Returning after a long long time

For many years this website lived on an Amazon cloud server. Around 2016 the attacks began. Malware and viruses swarmed the site and used it to send bizarre emails. Then the people at Amazon threatened to shut it down if I didn’t do something. I added recommended security features. The attacks continued. Eventually I closed the site to all outside IP addresses. Until today. I found a new hosting platform.

IOTA

Igloos on the Air

Operating the 2016 ARRL DX CW contest from inside an igloo at the summit of Witt Hill in Norway, Maine.

You can see the dipole feedline entering the air hole near the top right of the igloo – in the above photo.

Inside the igloo, the rig is balanced on a board, supported by plastic storage containers. I ran full power, 100 watts, from an IC-7300, using Bioenno LiFePo batteries. The temperature inside stays a few degrees above zero Celsius. I thought the rig would help heat up the igloo, but instead had to rely on wool blankets.

All of the gear was pulled up on sleds using human power.

About 3 feet of snow fell in the week before the contest.

Results: KA1IS – 40 meters SOSB LP claimed score: 86,286 (394 QSO’s + 73 countries)

 

Generic SDR realtime IQ converter

With CubicSDR, HAMLIB, and Max

update: 1/25/2021 – Using this general setup with Airspy, CubicSDR, rigctld, and netcat (nc) to send IQ data into the basicSDR3.maxpat patch


CubicSDR uses the SoapySDR library as generic tool for extracting realtime IQ data streams from common SDR devices. It also provides TCP external frequency control using HAMLIB.

http://cubicsdr.com/

Although its not the main purpose of CubicSDR, the IQ streaming capability will connect SDR devices to Max, Pd, and other DSP platforms, to build experimental radios. All without building external objects or hardware device drivers.  The convenience of using CubicSDR for this purpose far outweighs the overhead.

A prototype with Max and rtl_sdr

How to use CubicSDR as a front-end for SDR experiments in Max.

The signal path for this test is:

  1. antenna
  2. NooElec HAM IT UP upconverter
  3. rtl-sdr dongle
  4. CubicSDR
  5. Soundflower (or a “loop-backed” external audio device)
  6. Max

Running in the other direction, the frequency control path is:

  1. netcat running in Mac OS X terminal (or a Max patch that sends TCP)
  2. rigctld (hamlib TCP server)
  3. CubicSDR
  4. rtl-sdr dongle

There’s a lot of stuff going on here, so the choice to use hardware audio routing instead of Soundflower and netcat instead of TCP in Max, is an effort toward simplicity.

CubicSDR settings:

  • Plug in the rtl-sdr before launching CubicSDR, so it will be discovered on the setup screen
  • On the main display, click just to the right of the mode buttons to bring up a drop down menu of audio devices
  • select I/Q mode
  • select the audio device, or Soundflower, that you will use to route audio to Max
  • If using an upconverter, set the ‘frequency offset’ in the settings menu (e.g. -125000000)
  • click on any of the frequency digits, press space, and enter in the same frequency as the Center Frequency (e.g., 7000000)
  • click the ‘V’ to the left of the frequency digits, to select ‘delta lock mode’. This causes the frequency and center frequency to sync.
  • Be careful not to click anywhere in the waterfall window – or this will mess up the sync
  • Under Rig Control menu:
    • Select “Hamlib NET rigctl” as the model
    • Enter localhost:4532 as the control port
    • Select 57600 as the serial rate
    • Make sure that “follow rig” and “floating center” are checked
    • ‘Check’ ‘enable rig’. If it doesn’t stay checked, then there is a problem with the connection.
  • Under the Audio sample rate menu, select the correct sample rate for your audio device (e.g. 96k)

TCP and rigctld settings

  • Open a terminal window
  • type: rigctld -m 1 4532 &
  • This starts the server running in the background using the HAMLIB test dummy rig
  • to set frequency to 7.010 MHz, type:

    echo ‘F 7010000’ | nc -w 1 localhost 4532

  • This should change the center frequency and frequency in CubicSDR

Max settings

For this test, you can use any of the MaxSDR tutorials available at https://github.com/tkzic/maxradio but I chose to use the main program, currently maxsdr7a.maxpat. The key is to choose the default audio input device and set it to be the same as what is coming out of CubicSDR.  I used a stereo patch cord to connect the line output of my Apollo Twin interface to the input jacks – but you can also use Soundflower.

  • Set the audio input device to match CubicSDR, as described above. Also match the sample rate (e.g., 96k)
  • Set the audio output device to your internal soundcard/speakers
  • You may need to toggle the flip IQ button
  • Start audio and recall preset 1 or some normal settings for SSB
  • It should be receiving I/Q data now from Cubic SDR

Links:

Installing Hamlib: https://reactivemusic.net/?p=19402

Installing CubicSDR: https://github.com/cjcliffe/CubicSDR/releases

Supported SDR devices: https://reactivemusic.net/?p=19746

Notes:

I had some success using the Max TCP external described at the Installing Hamlib link above, but temporarily abandoned it due to some latency and dropouts.

Local version of this patch is: tcpClient-small2.maxpat

Next steps:

  • hardware (i.e., MIDI controller) control of frequency – and refinement of Max TCP patch. Can likely re-use the patch from the remote radio project.
  • Convert to PD : TCP/IP code is builtin
  • Consider forking CubicSDR and adding direct MIDI/OSC control of UI.