Zum Hauptinhalt

Lesson 2 - My first sound

Abschlussbedingungen
Introduction to digital signal processing: objects capable of managing audio signal. Instatiate an oscillator, set its volume and display the resulting waveform. Display help files.

Lesson 2:

edu sharing object


Transcript:

00:09 - Lesson 2. My first sound. In this tutorial we are going to introduce the objects responsible for managing audio signals. In Pure Data there are two big categories of objects: those responsible for managing the audio signals and thus the sound, and those responsible for controlling messages, e.g. numbers, symbols and lists. 00:35 - What is the difference between them? The audio objects always have priority over the other ones and they are always computing, even when we cannot hear them. Furthermore, they are very fast and handle data at sampling rate, which is typically 44,100 times per second. The control message objects, such as those necessary to set the frequency of an oscillator or set the volume, have a lower priority. They compute a result only when they receive something as input, or when we explicitly ask them to compute something as we did using the “bang” in the previous tutorial. When I open Pure Data, control message objects work by default. The audio objects instead work only if I turn on the audio engine, by checking this box in the “Log” window. 01:29 - Now the engine is active. ‘DSP’ stands for digital signal processing, and anything which you have already done inside an open patch, in terms of audio signals, will start to play. Let’s open an empty patch, and I will show you what the steps are to get sounds out of a patch. 01:50 - All of the patches I am going to show you during this series will be provided as a didactical resource. Nevertheless I suggest you follow me step by step and try to reproduce the patch in order to become acquainted with Pure Data. 02:07 - The first thing we need is an object capable of generating a periodical waveform and thus sound. This kind of object is an oscillator. We now want to produce the easiest kind of periodical waveform, a sinusoidal wave. 02:25 - To do that we type ctrl_1/cmd_1 to create a new object, and inside the object we type “osc tilde”. Be careful because all the audio objects have as their last character a tilde (~). As I said before, even if we cannot hear our oscillator yet, it is actually already working. So what do we need to do to hear it? Just a few steps! 02:57 - First we need to set a frequency for our oscillator, and there are two ways of doing this: one is to type the frequency inside the object, and thus the frequency becomes the “argument” of our oscillator. The downside of doing this is that the frequency is now fixed and cannot be changed. The second way of setting the frequency is to create a “number box” with ctrl_3/cmd_3, and use it to set the frequency dynamically via |ˈvʌɪə| the oscillator’s first inlet. In this way we are able to change the frequency. 03:37 - The number we typed as argument in the oscillator, has been overwritten by the number set from the “number box”. 03:45 - The oscillator interprets the incoming number as a value in Hertz or cycles per second. This means now that it has been set to oscillate to an A of the fourth octave of a piano, corresponding to 440 Hertz. 04:04 - We now need another object that allows us to output the signal to our sound card. 04:11 - The name of this object is “dac tilde”, where ”dac” or d-a-c stands for “digital to analog converter”. 04:23 - If I now draw a patch cord from the oscillator to the dac’s left inlet, I will hear a sinusoidal wave in the left channel, and by doing the same for the dac’s other inlet I will hear the sinus wave in the right channel too. Let’s disconnect this, because we need to adjust the volume. To delete a patch cord, just hover over it until the cursor becomes an “X” and click on it. 05:00 - Now that it has been highlighted, you can remove it by pressing your delete key. The volume was too high, so we need to implement a volume control. How can we do that? It is really straightforward and what we need to do is to multiply all the samples coming out of our oscillator by a factor smaller than 1. Because if I multiplied the samples by 1, I wouldn’t get any change in the volume, but if I multiplied them by 0.5 I would cut the volume by half. So let’s do it. 05:40 - As you can see I typed the multiplication symbol plus the tilde because we want to multiply an audio signal and not a number. Since we are now multiplying by 0, we are not hearing any sound, but let’s add a “number box” to get some control over the multiplication. 06:14 - If I now type 0.2 I’m going to hear the signal at 20% of the original volume. If I go over 1 [one] I get a distorted signal, and for the moment it is better to avoid this. Furthermore, I can change the frequency and get all the notes I want. 06:37 - Lastly, we are going to see how we can get a graphical feedback of the waveform we are producing, and that is always a good practice. To do that we need a couple more objects. First we have to create a new object, and type inside “tabwrite tilde" and give it an argument name, for example “testwave”. 07:05 - The idea is to use this object to write the values of our samples, which oscillate between -1 and +1 at a given rate, inside an array or table, so that we can look at them in the form of a shape. 07:20 - We also need a “bang” connected to the “tabwrite” inlet to tell “tabwrite” when to write the values. 07:33 - Then we need to connect the “tabwrite” inlet to the outlet of our volume control. 07:40 -Finally, we need a table to visualize our samples’ values. Just go to “tabwrite”, right-click on it and select “help” to expose the help patch. 07:54 - Let’s go into “Edit mode” with ctrl_E/cmd_E and select the table on the right named “array99” Copy it with ctrl_C/cmd_C. Close the help patch and paste the table inside of our own patch using ctrl_V/cmd_V. Right-click on it and select “Properties”. In the “Array properties” window, change the name to the one we will assign as an argument of the “tabwrite” object. 08:34 - Let’s turn the volume on and assign a new frequency. 08:44 - Now by clicking on the “bang” we are able to get a graphical feedback. 08:50 - In the next videos we will see how to automate some of these processes.


Example patch:

 

edu sharing object
 

Zuletzt geändert: Dienstag, 12. September 2023, 18:05