Creating a simple synthesizer in Pure Data – Part III
Part I: Creating a simple synthesizer in Pure Data - Part I
Part II: Creating a simple synthesizer in Pure Data - Part II
The steps:
We now have two important steps to finish our little project: the first is to add a filter that will finally turn our synthesizer into a subtractive synthesizer and the second is to create a simple user interface to make our patch more intuitive and pleasant to the end user.
Adding the filter
So we&'re here, finally. As you may remember from Part I,
Filter |
---|
Filters are used to remove or attenuate frequencies from a signal. Since Pure Data has objects that implement different types of filters, you don't need to know exactly how this is achieved, but it's important to know what each type of filter does. The simplest filters that you can create in Pure Data are:
These 3 objects are very easy to use and you can check the documentation to learn how to use them. The reason why I'm not explaining this here is simple: we are not going to use any of these objects in our synthesizer. All of the objects listed above take a frequency ( |
vcf~ |
---|
This is the object that we are actually going to use to implement our filter. The The first outlet will output the result of a band pass filter applied to your original signal, while the second outputs a low pass filter. |
Let's start by adding some sliders to the main patch. You can add four sliders (Ctrl+Shift+H for horizontal and Ctrl+Shift+V for vertical, but you should already know that) and name them, respectively,
-
Start: set send symbol to
start and output range from 20 to 20000 in log mode -
End: set send symbol to
end and output range from 20 to 20000 in log mode -
Time: set send symbol to
time and output range from 10 to 10000 in log mode -
Q: leave send symbol blank and set output range from 1 to 256 in log mode, then connect the slider to a
- 1 object and this last object to as q object
The output of
When we're done, you can tweak all the values as you see fit. Other than the frequency values, I choose the maximum values in a somewhat arbitrary manner.
We are done with our main patch. Let's move on to note.pd.
The first thing to do in note.pd is to add the filter, by creating a
The second and third inlets of the filter are for center frequency and Q factor, respectively. Controlling the center frequency will be a slightly more complex task, so we're going to put it in a subpatch. Create a
The Q factor part is easier. Just create a
Now, all the remaining work to make our filter functional is inside of the
So, let's work inside the subpatch. Start by adding below the inlet, in this order, the following objects: a
Each time a note is played the
Now create a
Believe it or not, we are done with the filter. Yes, it was that easy. If you have problems, try to reload your patch, because sometimes the changes are not applied to all instances of edited abstractions.
What happens here is that
Creating an user interface
If you came all the way from the beginning of this tutorial, you probably had already enough experience to notice that the focus of Pure Data is not exactly to make things look good. But that does not means you need to see all the inner workings of your patch while you are using it. One of the most interesting uses of Pure Data is for live performance and you would imagine a nice interface would make things a lot easier for the performer.
I'll show three different things you can do to organize your patch and make it look better, so you can use your creativity to customize your patch to your liking.
Graph-On-Parent
Open your main synthesizer patch, then select everything (Ctrl+A) and cut (Ctrl+X). Now create a new object in this empty canvas called
Check the
Open the subpatch
If you close the subpatch and take a look at you main patch, you will see a very simple interface with the sliders and without the ugly and confusing connections.
Canvas
To better organize your interface you can use the
Open your subpatch and place a
Color
You probably have already noticed this, but you can change colors of some objects just like you did with the canvas. Just open the
Conclusion
That's it, we're done. I hope you had some fun and learned something by following this tutorial. This synthesizer is very poor if compared to any synthesizer you will find out there, but you can make something interesting and unique if you invest some time to learn and to implement your ideas.
I'll list here some ideas of projects that you can try to do by yourself to make your synthesizer more interesting.
-
Add a preset feature. Pure Data can manipulate files, meaning that you can save and load presets. You can use Pure Data's help to search for the objects that deal with files.
-
Make a better envelope for the filter. Instead of only Start and End, you can have a variation of the ADSR envelope or anything else you can imagine to make the sound more interesting.
-
Add a waveform selector, where you can select other kinds of wave instead of always using sawtooth. You can have square, sine, triangle and noise, for example. (The sine wave will not work well with the filter, because it does not contain harmonics)
-
Add an option to make the filter frequencies relative to the note played, instead of always using absolute frequencies.
-
Add a vibrato with a slider to control it. Also, optionally make it controllable by the MIDI controller.
-
Add an option to use it as a monophonic synthesizer with glide / glissando between notes.
-
Add additive synthesis capabilities by allowing more than one waveform to be used together. You can also make the second oscillator be at some interval from the first.
-
Add modulation. If you have no idea about what this is, search for Frequency Modulation and Amplitude Modulation (FM and AM).
-
Add a cool graph that shows the waveform of what you are playing in real time. You'll need to learn how to use arrays.
-
Change the MIDI channel that the synthesizer will "receive". By making this (and some other adjustments, like change the names of sends and receives to use the $0 variable) you should be able to launch various instances of the synthesizer with different sounds and play them by using different MIDI channels.
I'll not teach how to do any of these (I have done some of these, but I don't think I have the patience to even try some of the others) but if I see a lot of interest in some particular feature, I may write some kind of Appendix to this tutorial in the future.
Here's a picture of a synthesizer that I created when I was learning Pure Data. It has some of the features listed above, but not a lot of them.
Bye!
Written by Eduardo Mezêncio