Download presentation
Presentation is loading. Please wait.
Published byAmice Rice Modified over 9 years ago
1
Copyright © 2011 by Denny Lin1 Computer Music Synthesis Chapter 5 Based on “Excerpt from Designing Sound” by Andy Farnell Slides by Denny Lin
2
Copyright © 2011 by Denny Lin2 Abstraction 5.1 Subpatches 5.2 Instantiation 5.3 Editing 5.4 Parameters 5.5 Defaults and states 5.6 Common abstraction techniques
3
Copyright © 2011 by Denny Lin3 5.1 Sub-patches Any canvas may contain sub-patches Sub-patches are: –stored in the same file as the main (or parent) patch –useful for hiding code, but do not provide local scope –created by naming an object that starts with pd. For example, when creating a pd envelope object, pd will open a new canvas to define the envelope sub-patch
4
Copyright © 2011 by Denny Lin4 A parent patch… Generate a 440Hz sine wave Scale the patch volume using the envelope sub-patch; 100 is attack, 500 is decay Send stereo output to speakers
5
Copyright © 2011 by Denny Lin5 …and its sub-patch The attack inlet receives 100, while the decay inlet receives 500 Trigger sends a bang to the delay object first The delay object waits 100 ms before banging the rightmost float object with 500ms After the delay object is banged, 100 is sent to leftmost float; this 100 is the first item ($1) in the leftmost list, so a 1 100 message is sent to line~ At the end of the 100ms delay, the 500 in the rightmost float is the first item ($1) in the rightmost list, so a 0 500 message is sent to line~ The output of line~ is sent to the outlet of the sub-patch
6
Copyright © 2011 by Denny Lin6 Inlets and Outlets Within a sub-patch, an inlet object is used for taking in data; an outlet object is used to send output The internal ordering (i.e. left to right) of the inlet and outlet objects, determines the external layout of the sub-patch inlet(s) and outlet(s) It is a good idea to name inlets and outlets
7
Copyright © 2011 by Denny Lin7 Copying and Deep sub-patches Can easily duplicate sub-patches that do not require uniquely-named objects (for example, message objects used in envelopes) Sub-patches can contain other sub- patches Principle of Abstraction: “Can define new objects, build bigger objects from those, and still bigger objects in turn.”
8
Copyright © 2011 by Denny Lin8 Example of Deep Sub-Patches
9
Copyright © 2011 by Denny Lin9 Abstractions An abstraction is a sub-patch that exists in a separate file Reusable Pd component that can be loaded many times by different patches Each instance of an abstraction has different internal namespaces Can take different creation arguments, so multiple instances of a sub-patch behave like functions called by other parts of a program By default, a patch has access to an abstraction saved in the same directory as itself
10
Copyright © 2011 by Denny Lin10 Scope and $0 Scope is the context with which an object (or variable) can be accessed Duplicating some PureData objects (i.e. arrays, table oscillators that reference arrays, etc) may lead to erratic behaviors The $0 variable is used to provide unique access to objects within a patch. For example, $0-array1 can be used to localize the array1 object Pd internally replaces $0 with a four-digit number unique to the patch or instance of abstraction
11
Copyright © 2011 by Denny Lin11 5.2 Instantiation To instantiate is to call on an instance of an abstraction Type the name of a patch (without the extension.pd) in an object box Click or open the abstraction in a new window to edit the instance Objects that require unique identifiers should be named with a prefix of $0 Message boxes treat $0 as a selector, so they cannot directly access objects that have a $0 prefix; use the send object (see Fig. 5.8)
12
Copyright © 2011 by Denny Lin12 Base and Abstract Table Oscillators
13
Copyright © 2011 by Denny Lin13 5.3 Editing Fig. 5.9 contains three instances of the abstract table oscillator Unsaved changes will affect the edited instance The behavior of all instances are affected only when changes are saved Use project or version-specific file prefixes for abstractions Create help files using Pd and comment objects (file must be name of abstraction with a - help.pd suffix)
14
Copyright © 2011 by Denny Lin14 5.4 Parameters An abstraction can pass creation arguments to local parameter variables $1, $2, $3… Similar to parameters in functions of other programming languages, these parameter variables have local scope
15
Copyright © 2011 by Denny Lin15 5.5 Defaults and states When a float object is used to access a parameter, and the parameter is undefined, the float object’s default value of 0 can be used: –directly, if it is desirable for the objects within the abstraction to treat 0 as the default input –to drive a select 0 object, whose output (given an input of 0) triggers a message containing the desired default value Abstraction classes will retain a persistent state for all instances of an abstraction, rather than for all instances of an object
16
Copyright © 2011 by Denny Lin16 5.6 Common abstraction techniques Graph On Parent (GOP) Using list inputs Packing and unpacking Control normalization Summation chains Routed outputs
17
Copyright © 2011 by Denny Lin17 Graph On Parent This technique is used to expose GUI control interfaces and display graphs while hiding normal patch objects
18
Copyright © 2011 by Denny Lin18 Using list inputs
19
Copyright © 2011 by Denny Lin19 Packing and unpacking A programmer, or collection of sliders connected to a pack object, can be used to send a new message each time a fader moves (see Fig. 5.16a) Can save preset values by pre-pending the keyword set to a list (see Fig. 5.16b)
20
Copyright © 2011 by Denny Lin20 Packing and unpacking
21
Copyright © 2011 by Denny Lin21 Control normalization All control surfaces in an interface can have a standard range of 0.0 to 1.0 Patches using normalized control surfaces may need to be pre- conditioned, so input parameters are adapted to use the normalized control data
22
Copyright © 2011 by Denny Lin22 Summation of chains
23
Copyright © 2011 by Denny Lin23 Routed inputs Inputs are messages that contain named parameters The named parameter contained by the banged message is channeled into destinations defined by route objects
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.