Computer Music Synthesis

Download Report

Transcript Computer Music Synthesis

Computer Music Synthesis
Chapter 2
Based on “Excerpt from Designing Sound”
by Andy Farnell
Slides by Denny Lin
Copyright © 2011 by Denny Lin
1
Starting with Pure Data
•
•
•
•
2.1 Pure Data
2.2 How does Pure Data work?
2.3 Message data and GUI boxes
2.4 Getting help with Pure Data
Copyright © 2011 by Denny Lin
2
2.1 Pure Data
• Pure Data (Pd) is a visual signal dataflow
programming language
• Designed to process sound and MIDI
events. Has grown to process video and
inputs from a variety of general purpose
sensors
• Free alternative to MAX/MSP
• Runs on Linux, Macintosh, and Windows
computers
Copyright © 2011 by Denny Lin
3
Pure Data Console
Copyright © 2011 by Denny Lin
4
Pure Data Test Signal
Copyright © 2011 by Denny Lin
5
2.2 How does Pure Data work?
• Data flows between objects connected through
cords or wires
• Thin cords carry message data; fat cords carry
audio signals
• Objects take in data at inlets, and may send
output to outlets; inlets and outlets appear as
tabs at the edge of objects
• Types of object names:
– Object names with ~: Process signals
– Object names without ~: Process messages
Copyright © 2011 by Denny Lin
6
Patches
• A collection of objects wired together is a
dataflow graph program or patch. Name is
derived from analog electronic synthesizer
modules connected together with patch cords
• Patches are placed on a canvas
• Patches are navigated by the PD interpreter
depth first, from right to left (tries to go as deep
as possible in a graph, processing the right-most
branch first before a left branch)
Copyright © 2011 by Denny Lin
7
Dataflow computation
Copyright © 2011 by Denny Lin
8
Pure Data Software Architecture
• Pure Data consists of several programs:
– pd(main engine): the interpreter, scheduler and audio engine
– pd-gui: the interface you use to build Pure Data programs
– pd-watchdog: monitors the main engine and gui, and will attempt
to terminate unresponsive pd or pd-gui
Copyright © 2011 by Denny Lin
9
Some Command Shortcuts
•
•
•
•
•
•
•
•
•
•
•
CTRL+1: Put object
CTRL+3: Put number
CTRL+A: Select all objects on canvas
CTRL+C: Copy selection
CTRL+D: Duplicate selection
CTRL+E: Toggle Edit Mode
CTRL+O: Open file
CTRL+S: Save file
CTRL+V: Paste selection
CTRL+X: Cut selection
SHIFT: Select multiple objects
Copyright © 2011 by Denny Lin
10
Placing a new object
•
•
•
•
Can use Put->Object from menu, or use CTRL+1
An active dotted box (object) appears
Assign a name to the object
Depending on the object’s name, Pd assigns an
appropriate number of inlets and outlets, changing the
dotted box into a solid box; no changes and assignments
made to unrecognized objects
• To delete an object, click and hold to draw a selection
box around the target object, and press delete
Copyright © 2011 by Denny Lin
11
Wiring
• Hovering over an outlet changes the mouse
cursor to a wiring tool
• Click and hold the mouse when the wiring tool is
active, and drag a connection from the first
object; hover over another compatible object
and release the mouse to complete a connection
• To delete a connection, click on a connection to
select it and press delete
Copyright © 2011 by Denny Lin
12
Initial Parameters or Arguments
• Most objects can take default initial values,
which are specified as initial parameters or
arguments
• These parameters are not always required
• Uninitialized values generally are set to 0
Addition depends on inlet(s)
Add a 3 to its input by default
Copyright © 2011 by Denny Lin
13
Modifying Objects
• The name and function of an object, and
its parameters can be changed
• The following causes the multiply object to
always multiply its input by 5, and the
addition object to always add 3 to its input.
• When 4 is the input of the multiply object,
the output of the graph is (4 x 5) + 3 = 23
Copyright © 2011 by Denny Lin
14
Number Input and Output
• Number boxes can be used to enter
numbers, or view results
• Can use Put->Number from the menu or
use CTRL+3
• The following solves y = 5x + 3, where x =
10
Copyright © 2011 by Denny Lin
15
Toggle Edit Mode
• In edit mode, you can move or modify objects
• To use the patch, you must exit edit mode
• Pressing CTRL+E (or Edit->Edit from menu)
allows you to enter and exit edit mode
• While not in edit mode, place the mouse on the
top number box (fig. 2.9), then drag the mouse
up and down; this changes the computed result
in the second number box
Copyright © 2011 by Denny Lin
16
More Edit Operations
• Objects can be copied into the buffer using
familiar cut, copy, paste, and duplicate
commands
• Select multiple objects by holding Shift
while clicking on targets
• Duplicating groups of objects will also
duplicate connections between them
Copyright © 2011 by Denny Lin
17
Patch Files
• Pd files are text files that end with a .pd file
extension
• Novices should avoid modifying these text
files
• Can use File->Save or CTRL+S to save
the current canvas
• Can use File->Open or CTRL+O to load a
patch file
Copyright © 2011 by Denny Lin
18
2.3 Message data and GUI boxes
• Messages are events or data sent between two
objects
• A message can be:
– as short as a character or a number, or
– as long as an entire musical score or synthesizer
parameter set
• GUI boxes (objects) can be placed on a canvas
using the Put menu, or using CTRL+1 through
CTRL+8
• All GUI boxes have properties that can be
modified (in edit mode) by clicking on them and
selecting the properties pop-up menu item
Copyright © 2011 by Denny Lin
19
Selectors
• All messages (except bang) carry an invisible
selector that identifies the message type
(symbol, number, pointer, or list)
• When a message arrives at the inlet of an
object, the object examines the selector to see if
it has an appropriate method to handle the
message
• If the object does not have an appropriate
method, an error message reports the
incompatible data type
Copyright © 2011 by Denny Lin
20
Bang message and box
• The most fundamental and smallest message
• The bang is used to cause an object to output a
value or advance to a next state
• Other messages have an implicit bang
• A bang box sends and receives messages;
changes from white to black whenever it sends
or receives a bang
• Bang boxes can be used to initiate actions or as
indicators
Copyright © 2011 by Denny Lin
21
Float messages and Number boxes
• All numbers (even integers) are stored as 32 bit floating
point values in Pd
• A number box object has a beveled top right corner
• Number box values can be changed by using the mouse:
– Coarse control: drag the mouse up or down over the value field
– Fine control: hold shift while dragging the mouse up or down
• Number boxes display by default up to 5 digits including
a sign (-9999 to 99999). Can be changed in the
properties dialog
Copyright © 2011 by Denny Lin
22
Toggle box
• Toggle boxes work with floats to represent
on and off states. When clicked, a cross
appears in the box, and a number 1 is
sent. When the box is clear, a 0 is sent
• Sending a bang to the inlet of a toggle box
flips the toggle box to an opposite state
• Other non-zero values can be sent by
editing the properties dialog
Copyright © 2011 by Denny Lin
23
Sliders and other numerical GUI
elements
• GUI elements for horizontal and vertical sliders can be
used as input and display elements; has a default range
of 0 to 127
• Radio boxes provide mutually exclusive buttons which
output a number starting at zero; can be used either as
indicators or input elements
• VU meters can be used to indicate decibels (scale of 99.0 to +12.0), and can be used only as display (output)
element
Copyright © 2011 by Denny Lin
24
Message box
• Visual containers for user definable
messages
• Only has one inlet and one outlet
• When clicked or when a bang is received,
its contents are sent to the outlet
• Is aware of the type of data it stores, and
will output data of matching type
Copyright © 2011 by Denny Lin
25
Symbolic messages
• A symbol is usually a word or some text, and can
contain any printable or non-printable character
• Whitespace is used to separate symbols from
each other: cannot type a symbol that has a
space character in a message box
• Valid symbols:
– Badget, sound_2, or all_your_base
• Invalid symbols:
– Hello there (there are two symbols)
– 20 (interpreted as float 20.0)
Copyright © 2011 by Denny Lin
26
Symbol box
• The symbol box displays text, or can be
used to input
• Enter a valid symbol text, and a symbol
message will be sent to the outlet
• A symbol message received at the inlet
will be displayed as text
• Sending a bang message to a symbol box
causes it to output its contents
Copyright © 2011 by Denny Lin
27
Lists
• A list is an ordered collection of floats,
symbols, pointers, or any things
• This collection is treated as one set
• Lists have a list selector attached to the
beginning of its message
• Lists may contain mixed types:
– {5 6 pick up sticks} contains two floats and
three symbols
• A list of one float will be type cast to a float
Copyright © 2011 by Denny Lin
28
Tables, arrays and graphs
• A table is a way of using an array, and is a
two-dimensional data structure
• Arrays are invisible
• A graph can be used to view array
contents
Copyright © 2011 by Denny Lin
29
Creating a new array
•
•
•
•
•
•
Use Put->Array from the menu,
and complete the dialog box to set
up the array name, size, and
display characteristics
The Save contents option stores
array data with the patch file
The points, polygon, Bezier curve
show data with different degrees
of smoothing
Can put more than one array in
same graph to compare two or
more sets of data, by selecting the
last graph option
The tabwrite object writes data to
array
The tabread object reads data
from array
Copyright © 2011 by Denny Lin
30
Tabwrite and Tabread
• Tabwrite takes the array name as its
parameter, and writes data to array
– Right inlet sets the index
– Left inlet sets the value
• Tabread takes the array name as its
parameter, and reads data from the array
– The inlet specifies the index
– The outlet returns the array’s value
Copyright © 2011 by Denny Lin
31
2.3 Getting help with Pure Data
Original PD Documentation
• http://www.crca.ucsd.edu/~msp/Pd_documentation/index.htm
Online PD Users Forum
• http://puredata.hurleur.com
Tutorials
• http://www.pd-tutorial.com/english/index.html
• http://obiwannabe.co.uk/tutorials/html/tutorials_main.html
Textbooks used in MUET495
• http://aspress.co.uk/ds/pdf/pd_intro.pdf
• http://en.flossmanuals.net/PureData/_booki/pure-data/pure-data.pdf
Copyright © 2011 by Denny Lin
32