Pd Machine Learning Fail

A failed attempt at machine learning for real-time sound design in Pure Data Vanilla.

I’ve previously shown artificial neurons and neural networks in Pd, but here I attempted to take things to the next step and make a cybernetic system that demonstrates machine learning. It went good, not great.

This system has a “target” waveform (what we’re trying to produce). The neuron takes in several different waveforms, combines them (with a nonlinearity), and then compares the result to the target waveform, and attempts to adjust accordingly.

While it fails to reproduce the waveform in most cases, the resulting audio of a poorly-designed AI failing might still hold expressive possibilities.

0:00 Intro / Concept
1:35 Single-Neuron Patch Explanation
3:23 The “Learning” Part
5:46 A (Moderate) Success!
7:00 Trying with Multiple Inputs
10:07 Neural Network Failure
12:20 Closing Thoughts, Next Steps

More music and sound with neurons and neural networks here:

Pd Comb Filter Patch from Scratch

Building a comb filter in Pure Data Vanilla from scratch.

A comb filter is a filter created by adding a delayed signal to itself, creating constructive and destructive interference of frequencies based on the length of the delay. All we have to do is delay the signal a little bit, feed it back into itself (pre-delay), and we get that pleasing, high-tech robotic resonance effect.

There’s no talking on this one, just building the patch, and listening to it go.

0:00 Playing back a recorded file
0:35 Looping the file
1:00 Setting up the delay
2:08 Frequency controls for the filter
2:52 Setting the range
3:48 Automatic random frequency
4:25 Commenting the code
5:39 Playing with settings

More no-talking Pd patch from scratch:

Pure Data Clamping VCA with [clip~]

Creating an ambient music machine in Pure Data Vanilla with a “clamping VCA” that adds subtle distortion, imitating the envelopes in Roland TR-808.

I made a clamping VCA in Reaktor a few weeks back, and now here’s another example in Pd. Normally, amplitude envelopes in synths are a control envelope on the amplitude of the signal. When we use a “clamping VCA”, though, instead of controlling the amplitude of the waveform, we clip it at the desired maximum envelope. This means, when the VCA is all the way up, it sounds the same, but during the attack and release, we’ll get the addition of subtle (or perhaps not-so-subtle) distortion to our waveform.

I use [clip~] in Pd to achieve this effect, stealing the idea from Noise Engineering’s “Sinclastic Empulatrix” module, which, in turn, stole the idea from from the Roland TR-808 drum machine’s cymbal envelopes.

More Pure Data Tutorials:

Interactive Holiday Noise Machine

Doing some live processing of sleigh bells in Pure Data to create an “Interactive Holiday Noise Music System.”

Since it’s mid-December, let’s make some holiday music. If you’re sick of the standard cloying Muzak fare, though, you can make your own feedback delay sample-crushing interactive music system in Pure Data in an afternoon.

The main point here is getting a “trigger” from audio input crossing a loudness threshold. Once we have that trigger, we can use it to make changes in live-processing of a sound and trigger other sounds too. This is a simple idea, but its effectiveness is going to depend on what these changes are and how we play with the system.

0:00 Demo
0:26 Introduction / Goals
1:23 Input Monitoring
2:41 Direct (“Dry”) Output
4:08 Feature Extraction with [sigmund~]
6:55 Amplitude as Trigger
8:43 Triggering Changes in Delay
12:44 Sample-Crushing
17:03 Triggering an Oscillator
19:37 Oscillators into Harmony
23:35 Putting it all together
25:33 Closing Thoughts

More experimental Christmas music:

Pure Data Artificial Neural Network Patch from Scratch

Coding (well, “patching”) an artificial neural network in Pure Data Vanilla to create some generative ambient filter pings.

From zero to neural network in about ten minutes!

In audio terms, an artificial neuron is just a nonlinear mixer, and, to create a network of these neurons, all we need to do is run them into each other. So, in this video, I do just that: we make our neuron, duplicate it out until we have 20 of them, and then send some LFOs through that neural network. In the end, we use the output to trigger filter “pings” of five different notes.

There’s not really any kind of true artificial intelligence (or “deep learning”) in this neural network, because the output of the network, while it is fed back, doesn’t go back an affect the weights of the inputs in the individual neurons. That said, if we wanted machine learning, we would have to have some kind of desired goal (e.g. playing a Beethoven symphony or a major scale). Here, we just let the neural network provide us with some outputs for some Pure Data generative ambient pings. Add some delay, and you’re all set.

There’s no talking on this one, just building the patch, and listening to it go.

0:00 Demo
0:12 Building and artificial neuron
2:00 Networking our neurons
3:47 Feeding LFOs into the network
4:20 Checking the output of the network
5:00 Pinging filters with [threshold~]
8:55 Adding some feedback
10:18 Commenting our code
12:47 Playing with the network

Creating an artificial neuron in Pd:

Pinging Filters in Pd:

More no-talking Pure Data jams and patch-from-scratch videos:

Pd Patch from Scratch: Filter Pinging

Doing some filter “pinging” use the resonant [bob~] filter in Pd Vanilla.

Filter pinging is a synthesis technique where you sent a “pop” (i.e. an audible click) to a resonant filter to create a percussive plucking sound around that filter’s cutoff frequency. Since we’re in Pd Vanilla, the easiest way to get a resonant filter is with [bob~], the “Runge-Kutte numerical simulation of the Moog analog resonant filter.”

There’s no talking on this one, just building the patch, and listening to it go.

0:00 Setting up the filter
0:40 Filtering a sawtooth wave
1:35 Subaudio [phasor~]
2:04 Randomizing cutoff frequency each ping
3:33 Commenting the code
5:12 Oops

Pure Data introductory tutorials here:


Pure Data Artificial Neuron Patch from Scratch

Patching up an artificial neuron in Pure Data Vanilla for some nonlinear mixing. There’s no talking on this one, just building the patch, and listening to it go.

An artificial neuron is basically just a mixer: inputs come in, and are weighted differently, modelling the dendrites of a biological neuron; then the mixed signal is transformed by an “activation function”, usually nonlinear, and output, modelling the axon.

Now, we can say that “learning” occurs when we adjust the weights (levels) of the inputs based on the output, but let’s not do that here, let’s just revel in our our nonlinear mix.

More details in my blog post here

0:00 Nonlinear Mixing and Artificial Neurons
1:17 Adding “Bias”
2:28 Neuron Complete
3:27 Automating the Weights
7:09 Adding Feedback
8:42 Adding Noise
9:58 Commenting our Code
11:25 Trying the ReLU Activation Function
12:04 Linear Mixing (with Hard Clipping)

Pure Data introductory tutorials here
More no-talking Pure Data jams and patch-from-scratch videos

Pure Data Screaming Metal Feedback Loop

A simple digital feedback patch in Pure Data build from just delay, ring-modulation, and saturation.


Building on my digital feedback video from a few weeks ago, here’s a quick patch for setting up a dynamic controllable feedback loop in Pd Vanilla. I’ve set up a way to get things going with a little sine-wave beep, and you can hear that the feedback loop makes things pretty complex pretty quickly.

WATCH THOSE LEVELS!
It gets loud in the middle.

More no-talking Pd videos here.
More music and sound design with cybernetics and feedback.

Making a Bad Sine Wave in Pure Data Vanilla

Building a “wab-sabi” oscillator in Pd to celebrate the beauty of imperfection and impermanence.

Sine waves are great! The perfection of a pure, single frequency can be both expressively and technically very useful in pursuing our musical goals. There are, however, lots of musical reasons that we might want to intentionally make our oscillators a little more rough around the edges.

Performance on traditional, acoustic instruments, of course, produces a huge amount of micro-variation across each note, and so it can be expressively engaging for us to be able to introduce that same imperfection (analog warmth?) in our digital instruments as well.

In this video, I build a bad sine wave by frequency-modulating my oscillator with noise, and then feeding back the output back into the modulation. While I build this out in Pure Data, the same can be done in Reaktor, Kyma, Max/MSP or any other synthesis environment.

More Pd Tutorials here.
No-talking Pure Data jams and patch-from-scratch.

0:00 Introduction, The Beauty of Imperfection
1:26 Slider-Controlled Sine Wave
3:28 Adding Noise
4:35 Frequency Modulating with Noise
7:24 Filtering the Noise
8:20 Feeding Back into FM
9:55 I’ve gone too far
13:26 Reaktor Examples
14:18 Closing Thoughts, Next Steps