
Appendix A Introduction to Pure Data A.1 Introduction Pure Data is a free, open-source visual programming environment and run-time platform for interactive audio applications. It was developed by Miller Puckette and was first released in 1996. Despite its age, it remains popular in electronic music where it is often used in live performances, and it is, as we shall see, a useful tool for learning audio processing. Curiously, there exists a commercial product that was derived from Pure Data called Max/MSP. Technically speaking, Pure Data belongs to the class of dataflow program languages, which take their starting point in the movement of data. For the purpose of learning audio processing, Pure Data is well-suited because it provides a solution that works on a multitude of platforms (e.g., Windows, Linux, and MacOS) and it is easy to use in real-time, interactive applications, something that is difficult with other solutions. This means that students (or other readers) can easily apply what they have learned and make it available for use, for example in live music performances with minimal extra effort. Thus, there is a short way from idea to product with Pure Data. As always, however, there is no free lunch. While it is comparably easy to create interactive, real-time software that is ready for use with Pure Data, it is not so easy to test the algorithms, like for example a filter, in Pure Data, while this would be easy in more traditional software such as MATLAB. In what follows, a brief introduction to Pure Data will be given. It is intended to get the reader acquainted with Pure Data and introduce the basic principles and objects needed to solve the exercises in this book. Thus, it is not intended as a comprehensive introduction to Pure Data. For that, we refer the interested reader to the many tutorials that can be found online, like FLOSS Manuals.1 The introduction will also put some emphasis on how to test audio processing algorithms, e.g., filter 1http://write.flossmanuals.net/pure-data/. © Springer Nature Switzerland AG 2019 193 M. G. Christensen, Introduction to Audio Processing, https://doi.org/10.1007/978-3-030-11781-8 194 A Introduction to Pure Data designs, in Pure Data. When reading this appendix, the reader is encouraged to create the examples him-/herself in Pure Data at the same time, as this is really the only way to really learn how to do it, like any other kind of programming or math. It is recommended that the Purr Data implementation of Pure Data is used, which is based on Miller Puckette’s original version. It can be downloaded from GitHub.2 This introduction is also based on Purr Data, although we shall simply refer to it as Pure Data or Pd for simplicity. A Pure Data reference card with all the most commonly used objects can be found online.3 A.2 Getting Started Once Pure Data has been installed, the user will be met with the window shown in Fig. A.1 upon launching the program. This is the main window where text output, error messages, etc. will be printed. The DSP on/off button in the top left corner indicates whether Pure Data is processing audio. You can turn it on by simply clicking the button or choosing Media and then Audio On. Before we get started with creating programs in Pure Data, it is important to check the audio settings. By clicking Edit and then Preferences, the settings window will open. There are several tabs in this window, but the most important one is the one called Audio. Depending on your platform (Windows, Linux, MacOS, etc.), it should look something like Fig. A.2. In this tab, you can see important settings like the sampling frequency, the number of channels, the block size, and the input and output devices. In this case, the input device is the microphone in the Webcam and the output is channels 1 and 2 in a Roland Quad-Capture USB device. The block size determines the size of the block (or frame, segment, buffer, etc.) of samples that Pure Data will use to process the audio. This means that the number of samples of the block size will be collected before the audio will be processed, and it thus introduces a delay. For real-time, interactive applications, you would like this to be as low as possible. However, there is an overhead associated with processing each block regardless of its size, so it is also less efficient to use a small block size. Pure Data programs are comprised of patches, starting with the main patch. To create a patch, choose File and then New in the window. This creates an empty patch as shown in Fig. A.3. Programs are then designed by placing objects in this patch and connecting the inputs and outputs of the objects. To place an object on a patch, simply click Put and then select the type of object you desire. Then, you can put the object wherever you desire in the patch. 2https://github.com/agraef/purr-data/releases. 3https://puredata.info/docs/tutorials/pd-refcard. A Introduction to Pure Data 195 Fig. A.1 The main window in Purr Data Fig. A.2 Audio settings in Pure Data 196 A Introduction to Pure Data Fig. A.3 An empty patch A.3 A Simple Example Let us start by building a simple patch in Pure Data where we simply take the input from the microphone of the computer and pass it on to the output of the soundcard. Such a program is sometimes called talkthru and is used to test that things are working properly. In Fig. A.4, a patch doing this is shown. Before creating this patch, we must make sure that we are in the Editmode. To check this, click Edit in your patch window and see whether the Editmode is turned on or not. When the Editmode is turned on, we can modify our patch (e.g., edit, move, and create objects), while we can only interact with a patch via its user interface (e.g., sliders) when it is off. To create the talkthru patch, start by simply selecting Put and then Object and then writing adc~ in the object. This object represents your input device, and its name derives from analog-to-digital converter. The inlet at the top of an object is where the input should be connected and the outlet at the bottom of the object is where the output appears. In this case, the object has one inlet (which actually is not used for anything) and two outlets, the left and right channel of the input device. To pass the input on to the output, repeat the process by selecting Put and then Object but this time the object should be called dac~, which refers to digital-to-analog converter. We can now connect the output of the adc~ object to the input of the dac~ object. To do this, hover your mouse pointer over the output of one object, click and hold the first mouse button, and then drag the connection to the desired input of the other object. Once the objects have been connected as shown in the figure, we can turn Pure Data on by selecting Media and then Audio On, but before you do this, make sure you have the audio volume turned down. A Introduction to Pure Data 197 Fig. A.4 Talkthru patch where the input is passed on without modification to the output Fig. A.5 Patch for loading and playing back a wav file (a), and a patch for selecting, loading, and playing back a wavfileusingtheGUI(b) We also recommend that headphones are used to avoid feedback issues (and to not annoy your neighbors too much). There are two kinds of data in Pure Data, control messages and signals. Signals are of course the stream of audio that we wish to somehow process, but control messages are all the other quantities that we need, such as filter coefficients. The ~ of the object indicates that the two objects in Fig. A.4 both operate on signals. Objects without ~ thus operate on control messages, and there are several kinds of control messages that we can use, many of which you will encounter in the examples to follow. Similarly, connections and object inlets/outlets can be for signals or control messages. Fat connections and dark inlets/outlets are for signals, while thin connections and light inlets/outlets are for control messages. To load an audio file from the computer, we can use the readsf~ object. To understand what a built-in object does, you can, after creating the object, right- click the object and then choose Help. Then, a window will appear where the object is explained in detail and its inlets, outlets, and creation arguments are listed. Creation arguments are arguments that are written alongside the object name when the object is created. In this case, for example, the arguments are the number of channels and the buffer size per channel. To open and play an audio file using the readsf~ object, you must create a patch as shown in Fig. A.5a, only you must replace clean.wav with a file on your computer. The two inputs to the readsf~ object are messages. To create these, simply click Put and then Message. Once you have created the patch, turn the DSP on, turn the edit mode off and then click the two messages (first open..
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages32 Page
-
File Size-