Using 40 meter SSB, Max/MSP, and Websdr to build a feedback delay from Maine to the Netherlands.
A Max patch plays an audio file into the transmitter in Maine. Then, using a websdr receiver in the Netherlands, the received signal is amplified and mixed back into the audio to be retransmitted. Effectively creating a feedback delay line.
Here is an example of what it sounds like on 40 meters.
The audio from Websdr is routed to the input of Max by creating a multi-output device (In Audio Midi Setup) combining “Blackhole 2ch” and external headphone output (for monitoring). The audio output of Max is assigned to the transmitter SSB input.
Patch not yet available. Local version is in max teaching examples.
I needed a text to morse code generator in Max for the Twitter streaming map project. There was an ancient one that used [mxj] but its kind of a pain to use that object. I thought it can’t be that difficult to write one? I didn’t really have any idea where to start. Something about the blank Max patch causes brain activity? I went through about 5 different approaches. Eventually came up with this pattern thing, from thinking about the lighted buttons on the tr-808 drum machine.
For example, the letter A is . _ (dot dash)
morse code has rules for spacing:
dot = 1
space between tones = 1
dash = 3
space between letters = 3
space between words = 7
If you think of a drum machine pattern, the pattern for letter A would be: 1 0 1 1 1 0 0 0 (with the 3 trailing 0’s for letter spacing)
I made a [coll] with all the letter patterns indexed by ascii codes.
Then just concatenate letter patterns, for a given block of text, together into one big list and run it through [zl.nth] clocked by a [metro] and [counter]. the ones and zero’s turn an oscillator on and off.
local file: tkzic/internetsensors/twitter-stream2/morse5.maxpat
This implementation uses node.js for Max instead of Ruby to access the API. You will need set up a developer account with Spotify and request API credentials. See below.
Other than that, the synthesis code in Max has not changed. Some of the following background information and video is from the original version. ..
What if you used that data to reconstruct music by driving a sequencer in Max? The analysis is a series of time based quanta called segments. Each segment provides information about timing, timbre, and pitch – roughly corresponding to rhythm, harmony, and melody.
Edit spot1.js replacing the cliendID and clientSecret with your spotify credentials
node for max install instructions (first time only)
Open the Max patch: spotify-synth1.maxpat
Scroll the patch over to the far right side until you see this green panel:
Click the [script npm init] message – this initializes the node infrastructure in the current folder
Then click each of the 2 script npm install messages – this installs the necessary libraries
Instructions
Open the Max patch: spotify-synth1.maxpat
Click the green [script start] message
Click the Speaker icon to start audio
Click the first dot in the preset object to set the mixer settings to something reasonable
open the Max Console window so you can see the Spotify API data
From the 2 menus at the top of the screen select an Artist and Title that match, for example: Albert Ayler and “Witches and Devils”
Click the [analyze] button – the console window should fill with interest data about your selection.
Click [play]
Note: if you hear a lot of clicks and pops, reduce the audio sample rate to 44.1 KHz.
Alternative search method:
Enter an Artist and Song title for analysis, in the text boxes. Then press the buttons for title and artist. Then press the /analyze button. If it works you will get prompts from the terminal window, the Max window, and you should see the time in seconds in upper right corner of the patch.
troubleshooting
If there are problems with the analysis, its most likely due to one of the following:
artist or title spelled incorrectly
song is not available
song is too long
API is busy
Mixer controls
The Mixer channels from Left to right are:
bass
synth (left)
synth (right)
random octave synth
timbre synth
master volume
gain trim
HPF cutoff frequency
You can also adjust the reverb decay time and the playback rate. Normal playback rate is 1.
programming notes
Best results happen with slow abstract material, like the Miles (Wayne Shorter) piece above. The bass is not really happening. Lines all sound pretty much the same. I’m thinking it might be possible to derive a bass line from the pitch data by doing a chordal analysis of the analysis.
Here are screenshots of the Max sub-patches (the main screen is in the video above)
Timbre (percussion synth) – plays filtered noise:
Random octave synth:
Here’s a Coltrane piece, using roughly the same configuration but with sine oscillators for everything:
There are issues with clicks on the envelopes and the patch is kind of a mess but it plays!
Several modules respond to the API data:
tone synthesiszer (pitch data)
harmonic (random octave) synthesizer (pitch data)
filtered noise (timbre data)
bass synthesizer (key and mode data)
envelope generator (loudness data)
Since the key/mode data is global for the track, bass notes are probable guesses. This method doesn’t work for material with strong root motion or a variety of harmonic content. It’s essentially the same approach I use when asked to play bass at an open mic night.
additional notes
Now that this project is running again. I plan to write additional synthesizers that follow more of the spirit of the data. For example, distinguishing strong pitches from noise.
Also would like to make use of the [section] data as well as the rhythmic analysis. There is an amazing amount of potential here.
How to build SoapySDR and CubicSDR from source in Ubuntu 20.04
After unsuccessful attempts to compile SoapySDR and CubicSDR on Mac OS and Windows, I was able to get it running in Ubuntu 20.04. The whole process took about 2 hours but could be done in less time if you know what you are doing.
It wasn’t really necessary to install CubicSDR to test SoapySDR. But CubicSDR is the only SoapySDR app that consistently works when it comes to devices, I/Q, files and TCP frequency control.
I also added the rtlsdr driver and the airspyhf driver. Instructions for rtlsdr are on the wiki. Instructions for airspyhf are below. You can add these drivers/libraries at any time, after SoapySDR is installed.
There were several missing libraries – described here.
hamlib
Hamlib is an option in CubicSDR. It was included because we’re using it to send frequency data to the devices via rigctld. You’ll need to install hamlib before you try to compile CubicSDR
This is what I did, if I can remember correctly. You may need to install libusb, but if you have done all the stuff above you probably already have it.
git clone https://github.com/airspy/airspyhf
cd airspyhf
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON<
make
sudo make install
sudo ldconfig
Now working some better… The Max SDR patch is receiving an IQ audio stream at 96 KHz from CubicSDR and sending frequency data to rigctld daemon via a python script that recodes OSC to tcp data.
make sure to start the rigctl daemon before CubicSDR
rigctld -m 1 4532 &
And make sure there is some audio gain on CubicSDR
But… There is only one Max patch now and – after you start the rigcltd daemon, you need to run the python script in the max8radio folder like this:
python3 py3rigctl2.py
The most important thing is to start CubicSDR first before you run the Max patch. Make sure to get everything working correctly. Then start the Max SDR.
In CubicSDR make sure you only have one “modem” running – otherwise the IQ data stream will be a complete mess. Als0 make sure that the audio sample rate in CubicSDR is set to 96 KHz. It will revert to 48 KHz. everytime you load the program. You can use the ‘bookmarks’ from a previous CubicSDR session (lower left part of the screen) to load a previous session with the same parameters.
These are the necessary settings:
I/Q modem
Audio out: Existential Audio Inc. Blackhole 2 ch.
Audio sample rate: 96 KHz.
Rig Control Menu: enable rig and follow rig should be ‘checked’
Frequency should equal Center frequency and the V delta lock toggle should be on
Demodulator Gain level should be very low to prevent excess AGC (upper right corner)
Actually if you have loaded everything ok in a previous session, try this:
get the rigctld daemon running from the command
load CubicSDR
First thing: click ‘enable rig’ under rig control (this will probably load some crazy frequency like 145 Mhz
Then in the bookmarks (lower left) double click on your previous session, under ‘recents’ for example: 7007MHzI/Q – this should restore almost all the settings.
Then change the audio sample rate to 96 KHz if needed.
If the input to Max seems wrong, try clicking the S (over near the top right) to solo the modems. There may be more than one going.
Max settings
Set audio input to Blackhole 2ch @ 96 KHz. (to match output from CubicSDR
Click the ‘flip IQ’ toggle – for some reason CubicSDR sends out the I/Q signal flipped
The arrow key tuning and all other tuning methods should work now
Notes
One of the problems with CubicSDR is sometimes you’ll accidentally change something and all the settings go crazy.
note: I tried a new version of CubicSDR (2.6) from the sdrplay website. It would not detect any connected devices or audio drivers.
Once you get it working, the audio quality inside Max is excellent – using the Airspy HF+
The Max patch is not available. From the video it appears that many channels of sound are playing concurrently. Color values are assigned to faders for each channel.