I have been making oscilloscope music for a while, and use the Pure Data programming language to generate pretty things on oscilloscopes. Here is the latest iteration of the Raspberry Pi device I call The Unilateral Phase Detractor.
I’ve spent the past couple months working on ways to draw pretty patterns on oscilloscopes.
This is the latest video about the project:
The Pure Data patch I’m using here offers a few features:
A “quadrature” oscillator that generates sine and cosine waves at various harmonics and mixes them
A random mode with several clock settings to modify the mix of harmonics
Ability to record the audio output to the SD card with a unique filename
Integration of Derek Holzer’s brilliant Vector Synthesis 3-D Shapes patch
A poorly drawn “Scope Crazy” logo drawn on the scope
A switcher to select between my generator, Derek’s shapes and the logo
Control of parameters via Midi controller and keyboard
All on a Raspberry Pi Model 4B w/ 4GB RAM
But let’s back up a little bit. I had been looking for ways to accent my modular synthesizer music with visuals. As a lover of oscilloscopes since I was a kid, drawing patterns on them seemed like a natural. Then, I started paying attention to guys like Jerobeam Fenderson, Hainbach, Albert Novello and Derek Holzer. Jerobeam’s website Oscilloscope.com and bought his album of recorded waves, and those waves inspired me to make a synthesizer specifically for those “pretty” waveforms.
So, I took Jerobeam’s advice and installed a version of PD called PD Extended. Pure Data has been around since Miller Puckette wrote the first version. PD relies on a lot of “externals,” pieces of code either natively compiled for a specific platform, or bits of code written in PD. An effort was made to compile a new version, “Extended,” that had a more complete set of features. As I proceeded to slog thru making patches in PD Extended, I discovered that Extended had not been updated since 2012.
Some Notes About Pure Data
PD Extended was to old and orphan to be of any use, so I switched over to “Pd-l2ork” and it’s nice interface “Purr Data” for development on my PC. Purr was more full featured and supported, but still I was missing pieces of code I could not get working, and realizing a Pi was a better smaller, more portable platform, I switched again to “PD Vanilla, .50” which was largely devoid of some features, but is very much supported today. The numerous forks of different versions was frustrating. Plus, documentation for PD was spotty. Let me single out one website that has not seen an update in YEARS: FlossManuals.com. This pathetic excuse for a tutorial site was once the king of teaching PD, but again, it has not seen an update in a very long time, the tutorial files are nowhere to be found; links to chapters are broken. I found it to be half useful. Info about patching and the workings of PD are great, but anything “new,” just isn’t there.
Fortunately, there are tons of tutorials on Youtube: LWM Music has a bunch of hour-long videos, the first part of which is this. Cheetomoskeeto also has some great stuff, amid promises to go into more details about about some things “in future videos,” that never happened. Tutor Raphael Herndandez quit making PD videos about 10 years ago. Jerobeam’s YT list of videos is informative.
Raising my level of difficulty was my desire to get this happening on a Raspberry. Lots of code had only been compiled for Win or Mac, so I was SOL in some cases. BUT, PD has some great resources for locating needed parts. Help>Find Externals within PD will find them, if they exist. To save you hours of Googly fun, let me tell you now, that the Cyclone and Zexy libraries are mandatory libraries.
The Quadrature Oscillator
The theory behind “quadrature” is firmly rooted in math. If you plot a sine wave in the horizontal axis of an oscilloscope, and a cosine wave on the vertical axis, you will see a circle. If you mix in other quadrature signals AT EXACT MULTIPLE FREQUENCIES, you get more complex curves. When I specify perfect multiples of frequencies (harmonics), the patterns do not move. Detuning any of the components puts the pattern in motion. My patch “Complex14.pd” generates the first 13 harmonics, with control computer control of amplitudes. I can introduce randomness to parameters of almost all of the harmonics, so the program plays by itself at a variety of speeds.
Here’s the main patch of Complex14 (click to embiggen):
I colored in areas to show how they are separated.
Basically it is generating sin and cosine pairs (Jerobean Fenderson’s idea), with control over amplitude via sliders, or via random numbers. Harmonic #1 (sin1) and #2 (sin2) are modulated with another oscillator and there’s control of which harmonic they are and can be mistuned to put the curves in motion. The ring modulation for sin2 can be either a sine or a triangle wave. The sin/cosine pair oscillators are essentially the areas in yellow. The light blue area left is the “sin2” ring modulator, purple is “sin1” oscillator and sine ring mod. The sliders at the bottom right are main controls that can also be changed with the Korg. I added comments, but probably not enough of them.
A random number generator [RandHB] can be turned on that changes amplitudes of harmonics, and all of the amplitudes can be turned to zero with a bang from the Korg.
I realized I needed a smaller computer, thus the Pi. Making this for a Pi was a challenge because 1) I had no idea what I was doing and 2) stuff is scattered all over the web and I had no idea where to start looking. Eventually this will accompany my modular tuneage.
The “Scope Crazy” logo
The logo code is not in the Complex patch file, but let me tell you how I made such a crappy looking logo. This website let’s you draw on the screen and it will generate audio that displays it on a scope. It generates a JSON file and audio files. I found the .c code for the font used in the videogame Asteroids and hand plotted the letters, and manually entered them into a JSON file which made the audio. The wave file is easily loaded and played in PD.
The Korg NanoKontrol2
I originally envisioned another box with buttons and knobs to control Complex, but that meant an Arduino interfacing with the Pi, plus the cost of the hardware, finding the right code pieces and a ton of hassle. A friend of mine showed me his Korg NanoKontrol2 and I knew that was the answer. Midi devices are easy to interface with the Pi and PD. The Korg website is complete with info and Alsamidi is exactly what you need to get your nano talking to the Pi.
You would start pd with the console command “sudo pd -alsamidi” which loads pd with the Alsa drivers. You then run “AConnect GUI” and make the virtual connection to the nano (or your midi controller).
The korg-nanoKONTROL2.pd patch shows there are 8 sliders, 8 knobs and a bunch of buttons for triggering events for a total of 45 controls points. Another patch that comes with the collection is a map of all the individual controls, that I kind of dismantled and use to reroute controls to parameters in Complex.
About Audio Interfaces
The audio level form the speaker output of the Pi is way too low to drive a scope, so another interface was needed. I settled on a Hifiberry AMP2 to send to scope and speakers. It does work, but distorts the images a little. So, next-gen audio interface on the way is from AliExpress.
8 channels of audio out (great for running an ILDA laser) plus 2 inputs means I’ll eventually be able to feed signals from my modular synth into the Pi for control or who knows.
Here’s the computer, taped to the desk because it wants to escape all the time. So PureData is a journey, and it’s not for every one.
Here is a zip of my “Complex14” pieces. If you want to run this, you have some work to do, so, GOOD LUCK! Complex14.zip for Raspbian PD Vanilla
(Hoo Boy, this place is due for some new material!)
I’ve gotten really interested in “oscilloscope music,” which is sound generated expressly for the purpose of drawing on oscillosocpes. A fellow named Jerobeam Fenderson got me started down that road. One of the ways people are making “OM,” is with a program called Pure Data, which is a graphical interface for interconnecting pieces just like a modular synthesizer, except it’s more like building a city with individual molecules.
It’s a fact of trigonometry, that if you plot a sine wave on the y-axis of an X/Y oscilloscope, and a cosine wave on the x-axis, you will get a perfect circle.
Interesting things happen when you mix these pairs with ones of different frequencies.
I went “scope crazy.”
And then I revised the patch a little bit and made some more:
I now have this running on a Raspberry Pi, so we’ll see where this goes.
Here are some places you can hear my music on Teh Interwebz… https://soundcloud.com/dibcadbu
is my original home for music postings. I rotate new stuff thru here and take it down when it’s had its run.