Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Multimedia Programming with Pure Data

You're reading from  Multimedia Programming with Pure Data

Product type Book
Published in Jul 2013
Publisher Packt
ISBN-13 9781782164647
Pages 350 pages
Edition 1st Edition
Languages
Author (1):
Bryan, Wai-ching CHUNG Bryan, Wai-ching CHUNG
Profile icon Bryan, Wai-ching CHUNG

Table of Contents (17) Chapters

Multimedia Programming with Pure Data
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1. Getting Started with Pure Data 2. Computer Graphics with the GEM Library 3. Image Processing 4. Interactivity 5. Motion Detection 6. Animation with Particle System 7. Audio Programming 8. Interface with the Outside World 9. Extending Pure Data Communities and References Index

Displaying messages


The Hello World example is straightforward. It involves one piece of data—a Hello World message, and one object to print out the message in the console window.

Create a new Pure Data patch. Save it to your folder with name helloWorld.pd. Clear the console window by navigating to Edit | Clear console. To create anything for your Pure Data patch, choose from the Put menu item.

It may take a few seconds for new comers to learn the operations of the Pure Data interaction sequence. First, we select a Message box (Command + 2 or Ctrl + 2). After you select Message, move your cursor back to the empty patch window helloWorld.pd. The message icon will move along with your cursor. You can click anywhere on the empty patch to fix the position of the message icon.

A data entry cursor (a blinking vertical bar) will appear in the left hand side of the message box. Now, you can type in Hello World inside this message box.

Click anywhere outside the message box to confirm the text. Note that the data entry cursor will disappear after you confirm the text. You can click on the message box again if you want to change the text later. You can also click-and-drag the message box to change its position within the patch window.

Now, we create the second item. Navigate to Put | Object (Command + 1 or Ctrl + 1) from the menu bar to create an empty object in the patch window.

Type the word print inside the object box. Note that the empty object box is a regular rectangle with dotted outline. After you type print, click outside the object box. The object box now has a solid outline. A message box is a rectangle with a curved right edge.

If you take a closer look at the message and object boxes, you will notice two tiny rectangles along the left edge of the message box on the top and bottom. For the object box, there is only one such rectangle on the top. They are the inlet and outlet mentioned earlier. Those on the top are inlets and those on the bottom are outlets.

Connecting one outlet to another inlet is the programming in Pure Data. Now, we connect the outlet of the Hello World message box to the inlet of the print object box. First, move your cursor towards the outlet of the Hello World message box. It will turn into a small circle.

Click-and-drag to draw a line from the outlet of the Hello World message box. While dragging, move toward the inlet of the print object box. The cursor will also turn into a small circle.

Release the mouse button to confirm the connection.

This is your first working Pure Data patch, the Hello World program. To execute the patch, we have to switch from Edit Mode to Run Mode by choosing Edit | Edit mode (Command + E or Ctrl + E). Note the mouse cursor changes into the regular pointer shape. Open the console window if it is hidden. You can do it by navigating to Window | Pd window (Command + R or Ctrl + R). Arrange the two windows side by side such that you can see the message in the console window when you work on the patch window. Move your cursor toward the Hello World message box. Note the cursor changes again. It is now an upward pointing arrow.

Click on the message box and note what happens in the console window. A message print: Hello World appears whenever you click on the message box. Yes, it is the Hello World program you have just achieved.

The message box in Run Mode functions like a button. When you click, it sends out the message text Hello World through its outlet along the connection line to the inlet of the print object box. A print object will just show the message it received onto the console window.

Note

In Edit Mode, you can also hold down the Command key or the Ctrl key to enter the Run Mode temporarily.

You have been reading a chapter from
Multimedia Programming with Pure Data
Published in: Jul 2013 Publisher: Packt ISBN-13: 9781782164647
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime}