floss manual pure data

320

Upload: jopamo

Post on 20-Jan-2016

71 views

Category:

Documents


2 download

TRANSCRIPT

  • Table of Contents Pure Data............................................................................................................................................................1

    Real Time Graphical Programming..................................................................................................................2Graphical Programming...........................................................................................................................2Real Time.................................................................................................................................................3

    What is digital audio? ........................................................................................................................................4Frequency and Gain.................................................................................................................................4Sampling Rate and Bit Depth..................................................................................................................4Speed and Pitch Control..........................................................................................................................5Volume Control, Mixing and Clipping....................................................................................................6The Nyquist Number and Foldover/Aliasing...........................................................................................6DC Offset.................................................................................................................................................7Block Size................................................................................................................................................7It's All Just Numbers ...............................................................................................................................7

    Installing on OS X...............................................................................................................................................9Status: X11 Library not loaded..............................................................................................................11Installing X11 on Mac OS X 10.3 Panther and 10.4 Tiger....................................................................12

    Installing on Windows......................................................................................................................................16

    Installing on Ubuntu........................................................................................................................................26 Installing libflac7 and libjasper.............................................................................................................26 Installing Pure Data...............................................................................................................................28

    Installing on Debian..........................................................................................................................................31

    Configuring Pure Data....................................................................................................................................35Basic configuration................................................................................................................................35 Audio drivers........................................................................................................................................35 MIDI drivers (Linux only)....................................................................................................................36Audio Settings........................................................................................................................................36

    Sample rate......................................................................................................................................36 Delay (msec)...................................................................................................................................36 Input Device...................................................................................................................................37 Output Device.................................................................................................................................37

    MIDI Settings.......................................................................................................................................37 Test Audio and MIDI............................................................................................................................38

    Advanced configuration...................................................................................................................................39 Startup Flags.........................................................................................................................................40Path........................................................................................................................................................41Platform-Specific Configuration Tools..................................................................................................42

    Pd-extended.....................................................................................................................................42Pure Data vanilla.......................................................................................................................42

    Linux...............................................................................................................................................43OS X................................................................................................................................................43Windows..........................................................................................................................................44

    Starting Pure Data...........................................................................................................................................46 Starting via an icon...............................................................................................................................46 Starting via command line....................................................................................................................46

    Linux (from xterm).........................................................................................................................46i

  • Table of Contents Starting Pure Data

    Mac OSX (from Terminal.app)......................................................................................................46Windows (from the DOS shell or Command Prompt)....................................................................46

    Starting from a script.............................................................................................................................47Windows..........................................................................................................................................48Linux and OS X...............................................................................................................................48

    Advanced scripting for starting Pd........................................................................................................48

    The Interface....................................................................................................................................................50Starting a new Patch...............................................................................................................................51Interface differences in Pure Data..........................................................................................................52

    Linux...............................................................................................................................................52Mac OS X........................................................................................................................................53

    Placing, connecting and moving Objects in the Patch...........................................................................53Edit Mode and Play Mode.....................................................................................................................56Messages, Symbols and Comments.......................................................................................................59GUI Objects...........................................................................................................................................60

    GUI Object Properties.....................................................................................................................60Arrays and graphs..................................................................................................................................61

    Graph...............................................................................................................................................62A Note on using GUI Objects................................................................................................................62

    Troubleshooting...............................................................................................................................................63

    Building a Simple Synthesizer.........................................................................................................................68Downloads.............................................................................................................................................69

    Oscillators..........................................................................................................................................................70Sine Wave Oscillator.............................................................................................................................70Sawtooth Wave Oscillator.....................................................................................................................70Square Wave Oscillator.........................................................................................................................70Other Waveforms...................................................................................................................................71

    Frequency..........................................................................................................................................................72Audio vs Message Cables......................................................................................................................72MIDI and Frequency..............................................................................................................................72

    Additive Synthesis.............................................................................................................................................74

    Amplitude Modulation.....................................................................................................................................76Simple AM Synthesis............................................................................................................................76Tremolo..................................................................................................................................................76Ring Modulation....................................................................................................................................77

    Frequency Modulation.....................................................................................................................................78

    Square Waves and Logic..................................................................................................................................80Pulse Width Modulation........................................................................................................................80Math & Logic Operations......................................................................................................................81

    Generating Waveforms....................................................................................................................................83Outline...................................................................................................................................................83Introduction............................................................................................................................................83Using Sinesum.......................................................................................................................................83

    ii

  • Table of ContentsGenerating Waveforms

    Sawtooth Wave......................................................................................................................................84Playback of the Graphed Waveforms....................................................................................................85Triangle Wave........................................................................................................................................86Square Wave..........................................................................................................................................86

    Normalizing & DC Offset.................................................................................................................................88

    Antialiasing........................................................................................................................................................92Outline...................................................................................................................................................92Introduction: What is Aliasing?.............................................................................................................92The Problem: an Aliasing Oscillator......................................................................................................92Oversampling and Filtering...................................................................................................................92Bandlimited Waveforms........................................................................................................................93

    Filters.................................................................................................................................................................95Low Pass Filter......................................................................................................................................95High Pass Filter......................................................................................................................................95Band Pass Filter.....................................................................................................................................96Voltage Controlled Filter.......................................................................................................................97

    The Envelope Generator..................................................................................................................................99Simple Envelope Generator Using [line]...............................................................................................99Complex Envelope Generator Using [vline~].....................................................................................100Envelopes Stored In Arrays.................................................................................................................101

    The Amplifier..................................................................................................................................................104 Using a Slider......................................................................................................................................104Using [line~], [vline~] and [tabread4~]...............................................................................................104

    Controlling the Synthesizer............................................................................................................................106Input from the Computer Keyboard.....................................................................................................106Input from a MIDI Keyboard...............................................................................................................107

    Building a 16-Step Sequencer........................................................................................................................109A Counter.............................................................................................................................................109Hot and Cold........................................................................................................................................109Storing and Retrieving MIDI Note Values..........................................................................................110The Finished 16-Step Sequencer Patch................................................................................................111

    A Four Stage Filtered Additive Synthesizer.................................................................................................113The Input Stage....................................................................................................................................113The Oscillator Stage.............................................................................................................................114The Filter Stage....................................................................................................................................114The Amp Stage....................................................................................................................................114Subpatches...........................................................................................................................................115

    Dataflow Tutorials..........................................................................................................................................118

    Building a Simple Sequencer: A step by step guide.....................................................................................119...........................................................................................................................................................................120

    ...........................................................................................................................................................................120...........................................................................................................................................................................121iii

  • Table of ContentsMessages...........................................................................................................................................................126

    Anatomy of a message.........................................................................................................................126Standard Message Types......................................................................................................................126Message Boxes.....................................................................................................................................127

    Special Methods of Message Boxes.............................................................................................128 Packing elements and variables into a list..........................................................................................128Deconstructing messages: unpack and route.......................................................................................129

    Math.................................................................................................................................................................132Simple arithmetic.................................................................................................................................132Higher math.........................................................................................................................................133Trigonometry.......................................................................................................................................133Fraction work.......................................................................................................................................134Numbers and ranges.............................................................................................................................134Random numbers.................................................................................................................................135Relational operators.............................................................................................................................136Conversion between acoustical units...................................................................................................136Bit twiddling........................................................................................................................................137Expr......................................................................................................................................................137Audio math..........................................................................................................................................137

    Lists..................................................................................................................................................................138Lists vs. list-messages..........................................................................................................................138

    Order of Operations ......................................................................................................................................139Hot and Cold Inlets..............................................................................................................................139Order of Connecting............................................................................................................................140

    Trigger...........................................................................................................................................140Depth first message passing.................................................................................................................140

    Wireless Connections......................................................................................................................................142What kind of data can be sent?............................................................................................................143Throw and Catch..................................................................................................................................143

    Subpatches.......................................................................................................................................................145Subpatch Inlets and Outlets.................................................................................................................146Closing and Reusing Subpatches.........................................................................................................147

    Abstractions.....................................................................................................................................................148Saving Abstractions.............................................................................................................................148Calling and Editing Abstractions.........................................................................................................149

    Dollar Sign Arguments...................................................................................................................................150In Object Boxes....................................................................................................................................150In Message Boxes................................................................................................................................152

    Graph on Parent.............................................................................................................................................153

    Arrays, Graphs and Tables............................................................................................................................156Creating an Array ................................................................................................................................156Using Arrays to Display Audio ...........................................................................................................157Writing Data to an Array ....................................................................................................................157Reading Data from Arrays...................................................................................................................158Using Arrays to Play Back Samples....................................................................................................159

    iv

  • Table of ContentsGEM.................................................................................................................................................................161

    What GEM Is For...........................................................................................................................................162GEM & OpenGL..................................................................................................................................162The Very Basics of Rendering.............................................................................................................162[gemwin]..............................................................................................................................................162gemhead...............................................................................................................................................163Let's get started....................................................................................................................................163.............................................................................................................................................................164pix_objects and and 3D Shapes...........................................................................................................164

    Images, Movies and Live Video.....................................................................................................................165[pix_image]..........................................................................................................................................165[pix_film].............................................................................................................................................165[pix_movie]..........................................................................................................................................166[pix_video]...........................................................................................................................................166Related Objects....................................................................................................................................167

    GEM mini-video mixer.. ................................................................................................................................168...........................................................................................................................................................................169

    1.5. Alpha, size.....................................................................................................................................1691.6. Color............................................................................................................................................1692- Adding webcam / live video input:..................................................................................................1703-chroma key ......................................................................................................................................171

    Pix Effects........................................................................................................................................................173[pix_lumaoffset]...................................................................................................................................173[pix_duotone].......................................................................................................................................173[pix_gain].............................................................................................................................................174.............................................................................................................................................................174[pix_threshold].....................................................................................................................................174

    Recording.........................................................................................................................................................176

    GEM window properties:..............................................................................................................................1771- fullscreen.........................................................................................................................................1772-Extended desktop, ............................................................................................................................177

    Video Tracking................................................................................................................................................179[pix_movement]...................................................................................................................................179

    [pix_background]..........................................................................................................................179[pix_blob]................................................................................................................................179Getting the coordinates...........................................................................................................180

    Game Controllers............................................................................................................................................181Start with the Keyboard.......................................................................................................................181Mouse Cursor.......................................................................................................................................181USB HID..............................................................................................................................................182

    What do "abs", "rel", and "key" mean?.........................................................................................185Make Your Own HID..........................................................................................................................185 HID to Pd............................................................................................................................................186

    Pduino: ............................................................................................................................................................188

    v

  • Table of Contents Installing Arduino on Fedora 12 (x86_32)...................................................................................................189

    Installing Externals.........................................................................................................................................193Downloading and Installing.................................................................................................................193Installing Any External........................................................................................................................194

    Pduino Light Sensor.......................................................................................................................................203

    [netsend] and [netreceive]..............................................................................................................................206[netsend]...............................................................................................................................................206[netreceive]..........................................................................................................................................206Connecting with other applications.....................................................................................................207

    Open Sound Control (OSC)...........................................................................................................................208Setting up an OSC connection.............................................................................................................208

    Sending a simple message.............................................................................................................208Receiving a simple message..........................................................................................................208IP addresses, hostnames................................................................................................................209Ports...............................................................................................................................................209UDP vs. TCP.................................................................................................................................209

    The OSC address pattern.....................................................................................................................209OSC arguments....................................................................................................................................210Types....................................................................................................................................................211Bundles................................................................................................................................................213Designing your namespace..................................................................................................................214

    Connecting to hardware or external applications..........................................................................214Connecting to another PureData patch or to your own application written in another

    language.................................................................................................................................214Using a predefined namespace......................................................................................................215

    Midi..................................................................................................................................................................216

    Setup.................................................................................................................................................................217

    Channels and Ports.........................................................................................................................................218Multiple Devices..................................................................................................................................218

    3-Midi hardware: ...........................................................................................................................................219

    4- Making notes in pd, Sending / reciving notes. .......................................................................................221

    5- Midi controllers...........................................................................................................................................222

    6- Sending midi to other softwares, sending CC (control change)...........................................................224

    7- Another midi objects:................................................................................................................................225

    Streaming Audio............................................................................................................................................226 1. Create the mp3cast object...............................................................................................................226 2. Connect an osc~ object...................................................................................................................226 3. Settings............................................................................................................................................226 4. Start the Stream..............................................................................................................................228 5. Streaming from The Mic................................................................................................................2286. Disconnect........................................................................................................................................229

    vi

  • Table of Contents oggcast~...........................................................................................................................................................230

    Parameters...........................................................................................................................................230Streaming from your Sound Card........................................................................................................231Streaming from Pure Data audio..........................................................................................................231

    Tips................................................................................................................................................232

    Object List.......................................................................................................................................................233Dataflow...............................................................................................................................................233

    Audio.............................................................................................................................................233Patch Management........................................................................................................................233External libraries...........................................................................................................................233

    Vanilla and Extended Objects..............................................................................................................233Organisation.........................................................................................................................................234Name....................................................................................................................................................234Library/Path.........................................................................................................................................234Function...............................................................................................................................................234

    GLUE...............................................................................................................................................................235Name....................................................................................................................................................241Library/Path.........................................................................................................................................241Function...............................................................................................................................................241

    Math.................................................................................................................................................................242Name....................................................................................................................................................246Library/Path.........................................................................................................................................246Function...............................................................................................................................................246

    Time..................................................................................................................................................................247Name....................................................................................................................................................247Library/Path.........................................................................................................................................247Function...............................................................................................................................................247

    Midi..................................................................................................................................................................248Name....................................................................................................................................................248Library/Path.........................................................................................................................................248Function...............................................................................................................................................248

    Tables...............................................................................................................................................................249Name....................................................................................................................................................249Library/Path.........................................................................................................................................249Function...............................................................................................................................................249

    Misc..................................................................................................................................................................250Name....................................................................................................................................................251Library/Path.........................................................................................................................................251Function...............................................................................................................................................251

    Audio Glue.......................................................................................................................................................252Name....................................................................................................................................................253Library/Path.........................................................................................................................................253Function...............................................................................................................................................253

    vii

  • Table of ContentsAudio Math......................................................................................................................................................254

    Name....................................................................................................................................................255Library/Path.........................................................................................................................................255Function...............................................................................................................................................255

    Audio Oscillators and Tables.........................................................................................................................256Name....................................................................................................................................................257Library/Path.........................................................................................................................................257Function...............................................................................................................................................257

    Audio Filters....................................................................................................................................................258Name....................................................................................................................................................261Library/Path.........................................................................................................................................261Function...............................................................................................................................................261

    Audio Delay.....................................................................................................................................................262Name....................................................................................................................................................262Library/Path.........................................................................................................................................262Function...............................................................................................................................................262

    Subwindows.....................................................................................................................................................263Name....................................................................................................................................................263Library/Path.........................................................................................................................................263Function...............................................................................................................................................263

    Data Templates and Acessing Data...............................................................................................................264Name....................................................................................................................................................264Library/Path.........................................................................................................................................264Function...............................................................................................................................................264

    GEM.................................................................................................................................................................265Name....................................................................................................................................................269Library/Path.........................................................................................................................................269Function...............................................................................................................................................269

    PDP...................................................................................................................................................................270Name....................................................................................................................................................271Library/Path.........................................................................................................................................271Function...............................................................................................................................................271

    Physical Modelling..........................................................................................................................................272Name....................................................................................................................................................272Library/Path.........................................................................................................................................272Function...............................................................................................................................................272

    Obsolete............................................................................................................................................................273

    Glossary...........................................................................................................................................................274Glossary Terms....................................................................................................................................274Abstraction...........................................................................................................................................274ADC.....................................................................................................................................................274ADSR...................................................................................................................................................274Aliasing................................................................................................................................................274ALSA...................................................................................................................................................274

    viii

  • Table of ContentsGlossary

    AM Synthesis.......................................................................................................................................274Amplitude Modulation Synthesis........................................................................................................274Anything..............................................................................................................................................275Argument.............................................................................................................................................275Array....................................................................................................................................................275ASIO....................................................................................................................................................275Attack...................................................................................................................................................275Atom....................................................................................................................................................275Audio Driver........................................................................................................................................275Bandlimited..........................................................................................................................................275Bang.....................................................................................................................................................276Bit Depth..............................................................................................................................................276Buffer...................................................................................................................................................276Canvas..................................................................................................................................................276Carrier..................................................................................................................................................276Clipping...............................................................................................................................................276Cold and Hot........................................................................................................................................276Comment..............................................................................................................................................277Creation Argument...............................................................................................................................277Cutoff Frequency.................................................................................................................................277DAC.....................................................................................................................................................277DC Offset.............................................................................................................................................277Decay...................................................................................................................................................277Decibel.................................................................................................................................................277Delay....................................................................................................................................................277Distortion.............................................................................................................................................278Dollar Sign...........................................................................................................................................278Dynamic Range....................................................................................................................................278Edit Mode............................................................................................................................................278Envelope..............................................................................................................................................278External................................................................................................................................................278External Library...................................................................................................................................279Filter.....................................................................................................................................................279Feedback..............................................................................................................................................279Float orFloating Point..........................................................................................................................279FM Synthesis.......................................................................................................................................279Foldover...............................................................................................................................................279Frequency.............................................................................................................................................279Frequency Modulation Synthesis.........................................................................................................280Gain......................................................................................................................................................280Glitch...................................................................................................................................................280Graph....................................................................................................................................................280Graph on Parent...................................................................................................................................280GUI element.........................................................................................................................................280Harmonics............................................................................................................................................280HID......................................................................................................................................................280Hot and Cold........................................................................................................................................281Hradio..................................................................................................................................................281Hslider..................................................................................................................................................281Hertz or Hz...........................................................................................................................................281Human Interface Device......................................................................................................................281Index number.......................................................................................................................................281Inlet......................................................................................................................................................281

    ix

  • Table of ContentsGlossary

    Integer..................................................................................................................................................281JACK...................................................................................................................................................281Latency.................................................................................................................................................282Linear...................................................................................................................................................282List.......................................................................................................................................................282Logarithmic..........................................................................................................................................282Loudness..............................................................................................................................................282Message................................................................................................................................................282MIDI....................................................................................................................................................282MME....................................................................................................................................................283Modulator.............................................................................................................................................283Monophonic.........................................................................................................................................283Noise Floor..........................................................................................................................................283Normalize.............................................................................................................................................283Note......................................................................................................................................................283Number................................................................................................................................................283Nyquist Frequency...............................................................................................................................283Object...................................................................................................................................................284Octave..................................................................................................................................................284Oscillator..............................................................................................................................................284OSS......................................................................................................................................................284Outlet...................................................................................................................................................284Oversampling.......................................................................................................................................284Pass Band.............................................................................................................................................284Patch.....................................................................................................................................................285Path......................................................................................................................................................285Pitch.....................................................................................................................................................285Play Mode............................................................................................................................................285Pointer..................................................................................................................................................285Polyphonic...........................................................................................................................................285Portaudio..............................................................................................................................................285Property................................................................................................................................................285Radio....................................................................................................................................................286Real-time..............................................................................................................................................286Release.................................................................................................................................................286Resonance............................................................................................................................................286Sample.................................................................................................................................................286Sampler................................................................................................................................................286Sampling Rate......................................................................................................................................286Scalar....................................................................................................................................................287Sequencer.............................................................................................................................................287Selector................................................................................................................................................287Self-noise.............................................................................................................................................287Send and Receive.................................................................................................................................287Shell.....................................................................................................................................................287Slider....................................................................................................................................................287Startup Flag..........................................................................................................................................287Stop Band.............................................................................................................................................287Struct....................................................................................................................................................288Subpatch...............................................................................................................................................288Sustain..................................................................................................................................................288Symbol.................................................................................................................................................288Symbol Message..................................................................................................................................288

    x

  • Table of ContentsGlossary

    Truncate...............................................................................................................................................288Variable................................................................................................................................................288Vector Based Graphics........................................................................................................................288Velocity................................................................................................................................................289Voices..................................................................................................................................................289Vradio..................................................................................................................................................289Vslider..................................................................................................................................................289VU........................................................................................................................................................289Word Length........................................................................................................................................289Working Directory...............................................................................................................................289

    Pd Links..........................................................................................................................................................290Pure Data Software..............................................................................................................................290Externals..............................................................................................................................................290Linux Distributions with Pd.................................................................................................................290Tutorials & Examples..........................................................................................................................290Getting Help.........................................................................................................................................291

    License..............................................................................................................................................................292

    Authors............................................................................................................................................................293

    General Public License..................................................................................................................................304

    xi

  • Pure DataPure Data (or Pd) is a real-time graphical programming environment for audio, video, and graphicalprocessing. Pure Data is commonly used for live music performance, VeeJaying, sound effects, composition,audio analysis, interfacing with sensors, using cameras, controlling robots or even interacting with websites. Because all of these various media are handled as digital data within the program, many fascinatingopportunities for cross-synthesis between them exist. Sound can be used to manipulate video, which couldthen be streamed over the internet to another computer which might analyze that video and use it to control amotor-driven installation.

    Programming with Pure Data is a unique interaction that is much closer to the experience of manipulatingthings in the physical world. The most basic unit of functionality is a box, and the program is formed byconnecting these boxes together into diagrams that both represent the flow of data while actually performingthe operations mapped out in the diagram. The program itself is always running, there is no separationbetween writing the program and running the program, and each action takes effect the moment it iscompleted.

    The community of users and programmers around Pure Data have created additional functions (called"externals" or "external libraries") which are used for a wide variety of other purposes, such as videoprocessing, the playback and streaming of MP3s or Quicktime video, the manipulation and display of3-dimensional objects and the modeling of virtual physical objects. There is a wide range of external librariesavailable which give Pure Data additional features. Just about any kind of programming is feasible using PureData as long as there are externals libraries which provide the most basic units of functionality required.

    The core of Pure Data written and maintained by Miller S. Puckette (http://crca.ucsd.edu/~msp/) and includesthe work of many developers (http://www.puredata.org/), making the whole package very much a communityeffort. Pd runs on GNU/Linux, Windows, and Mac OS X, as well as mobile platforms like Maemo,iPhoneOS, and Android.

    Pure Data 1

  • Real Time Graphical ProgrammingTraditionally, computer programmers used text-based programming languages to write applications. Theprogrammer would write lines of code into a file, and then run it afterwards to see the results. Many sound orvisual artists, as well as other non-programmers, find this a difficult and non-intuitive method of creatingthings however.

    ({// example by James McCartneyvar signal, delay, reverb;

    // 10 voices of a random sine percussion sound:signal = Mix.fill(10, {Resonz.ar(Dust.ar(0.2, 50), rrand(200.0, 3200.0), 0.003)});

    // reverb predelay time:delay = DelayN.ar(signal, 0.048);

    // 7 length modulated comb delays in parallel:reverb = Mix.fill(7,{CombL.ar(delay, 0.1, LFNoise1.ar(0.1.rand,0.04,0.05), 15)});

    // two parallel chains of 4 allpass delays (8 total):4.do{ reverb = AllpassN.ar(reverb, 0.050, [ 0.050.rand, 0.050.rand ], 1) };

    // add original sound to reverb and play it:signal + (reverb * 0.2)}.play)

    SuperCollider: an example of text-based programming for audio.

    Graphical ProgrammingPure Data, on the other hand, is a graphical programming environment. What this means is that the lines ofcode, which describe the functions of a program and how they interact, have been replaced with visual objectswhich can be manipulated on-screen. Users of Pure Data can create new programs (patches) by placingfunctions (objects) on the screen. They can change the way these objects behave by sending them messagesand by connecting them together in different ways by drawing lines between them.

    A Pure Data patch...

    Real Time Graphical Programming 2

  • This visual metaphor borrows much from the history of 20th Century electronic music, where sounds werecreated and transformed by small electronic devices which were connected together via patch cables.

    ...and an analog synthesizer patch.

    The sounds that were heard were the result of the types of devices the composer used and the way in whichshe or he connected them together. Nowadays, much of this electronic hardware has been replaced bycomputer software capable of making the same sounds, and many more.

    Real TimeThe real advantage of Pure Data is that it works in "real time". That means that changes can be made in theprogram even as it is running, and the user can see or hear the results immediately. This makes it a powerfultool for artists who would like to make sound or video in a live performance situation.

    Graphical Programming 3

  • What is digital audio? Since we'll be using Pure Data to create sound, and since Pd treats sound as just another set of numbers, itmight be useful to review how digital audio works. We will return to these concepts in the audio tutorial lateron.

    A diagram showing how sound travels through your computer. The "Analog to Digital" & "Digital to AnalogConversion" is done by the soundcard. The "Digital System" in this case is Pure Data.Source: http://en.wikipedia.org/wiki/Image:Analogue_Digital_Conversion.png

    Frequency and GainFirst, imagine a loudspeaker. The move the air in front of it and make sound, the membrane of the speakermust vibrate from it's center position (at rest) backwards and forwards. The number of times per second itvibrates makes the frequency (the note, tone or pitch) of the sound you hear, and the distance it travels fromit's resting point determines the gain (the volume or loudness) of the sound. Normally, we measure frequencyin Hertz (Hz) and loudness or gain in Decibels (dB).

    A microphone works in reverse - vibrations in the air cause its membrane to vibrate. The microphone turnsthese acoustic vibrations into an electrical current. If you plug this microphone into your computer'ssoundcard and start recording the soundcard makes thousands of measurements of this electric current persecond and records them as numbers.

    Sampling Rate and Bit DepthTo make audio playable on a Compact Disc, the computer must make 44,100 measurements (called samples)per second, and record each one as a 16-bit number. One bit is a piece of information which is either 0 or 1,

    What is digital audio? 4

  • and if there are 16 bits together to make one sample then there are 216 (or2x2x2x2x2x2x2x2x2x2x2x2x2x2x2x2 = 65,536) possible values that each sample could have. Thus, we cansay that CD-quality audio has a sampling rate of 44,100 Hz and a bit-depth or word length of 16 bits. Incontrast, professional music recordings are usually made at 24-bit first to preserve the highest amount of detailbefore being mixed down to 16-bit for CD, and older computer games were famous for having a distinctivelyrough 8-bit sound. By increasing the sampling rate, we are able to record higher sonic frequencies, and byincreasing the bit-depth or word length we are able to use a greater dynamic range (the difference betweenthe quietest and the loudest sounds it is possible to record and play).

    An example of 4-bit sampling of a signal (shown in red). This image shows that 16 possible values can bemade from 4-bits--a very low dynamic range indeed! In Pd, our scale of numbers goes from -1 to 1, with 0 inthe middle. Source: http://en.wikipedia.org/wiki/Image:Pcm.svg

    The number we use to record each sample has a value between -1 and +1, which would represent the greatestrange of movement of our theoretical loudspeaker, with 0 representing the speaker at rest in the middleposition.

    Graphical depiction of a sine wave, which crosses zero from the negative to the positive domain.

    When we ask Pd to play back this sound, it will read the samples back and send them to the soundcard. Thesoundcard then converts these numbers to an electrical current which causes the loudspeaker to vibrate the airin front of it and make a sound we can hear.

    Speed and Pitch ControlIf we want to change the speed at which the sound is played, we can read the samples back faster or slower

    Sampling Rate and Bit Depth 5

  • than the original sampling rate. This is the same effect as changing the speed of record or a tape player. Thesound information is played back at a different speed, and so the pitch of the sound changes in relation to thechange in speed. A faster playback rate increases the pitch of the sound, while a slower playback rate lowersthe pitch.

    Volume Control, Mixing and ClippingIf we want to change the volume of the sound, we have to multiply the numbers which represent the sound byanother number. Multiplying them by a number greater than 1 will make the sound louder, and multiplyingthem by a number between 1 and zero will make the sound quieter. Multiplying them by zero will mute them- resulting in no sound at all. We can also mix two or more sounds by adding the stream of numbers whichrepresent them together to get a new stream of sound. All of these operations can take place in real-time as thesound is playing.

    However, if the range of numbers which represents the sound becomes greater than -1 to 1, any numbersoutside of that range will be truncated (reduced to either -1 or 1) by the soundcard. The resulting sound will beclipped (distorted). Some details of the sound will be lost and frequencies that were not present before will beheard.

    The waveform on the left is at full volume (i.e. it's peaks are at -1 and 1). The volume of the waveform on theright has been doubled, so that it peaks at -2 and 2. The graph shows what would be heard from thesoundcard: a clipped signal with the peaks of the sinewave removed.

    The Nyquist Number and Foldover/AliasingAnother problem occurs if one tries to play back a frequency which is greater then half the sampling ratewhich the computer is using. If one is using a sampling rate of 44,100 Hz, the highest frequency one couldtheoretically play back without errors is 22,050 Hz. The reason being, a computer needs at least two samplesto reproduce a single frequency. The number that represents half the sampling rate is called the Nyquistnumber.

    If you were to tell Pd to play a frequency of 23,050 Hz, what you would hear is one tone at 23,050 Hz, and asecond tone at 21,050 Hz. The difference between the Nyquist number (22,050 Hz) and the synthesized sound(23,050 Hz) is 1,000 Hz, which you would both add to and subtract from the Nyquist number to find theactual frequencies heard. So as one increased the frequency of the sound over the Nyquist number, you wouldhear one tone going up, and another coming down. This problem is referred to as foldover or aliasing.

    Speed and Pitch Control 6

  • Here we can see two possible waveforms which could be described by the samples show. The red line showsthe intended waveform, and the blue line shows the "aliased" waveform at - ( - ).Source: http://en.wikipedia.org/wiki/Image:AliasingSines.png

    DC OffsetDC offset is caused when a waveform doesn't cross the zero line, or has unequal amounts of signal in thepositive and negative domains. This means that, in our model speaker, the membrane of the speaker does notreturn to its resting point during each cycle. This can affect the dynamic range of the sound. While DC offsetcan be useful for some kinds of synthesis, it is generally considered undesirable in an audio signal.

    An example of DC offset: the waveform is only in the positive domain.

    Block SizeComputers tend to process information in batches or chunks. In Pd, these are known as Blocks. One blockrepresents the number of audio samples which Pd will compute before giving output. The default block size inPd is 64, which means that every 64 samples, Pd makes every calculation needed on the sound and when allthese calculations are finished, then the patch will output sound. Because of this, a Pd patch cannot containany DSP loops, which are situations where the output of a patch is sent directly back to the input. In such asituation, Pd would be waiting for the output of the patch to be calculated before it could give output! In otherwords, an impossible situation. Pd can detect DSP loops, and will not compute audio when they are present.For more information, see the "Troubleshooting" section.

    It's All Just Numbers The main thing to keep in mind when starting to learn Pure Data is that audio and everything else is justnumbers inside the computer, and that often the computer doesn't care whether the numbers you are playingwith represent text, image, sound or other data. This makes it possible to make incredible transformations insound and image, but it also allows for the possibility to make many mistakes, since there is no 'sanity checks'in Pure Data to make sure you are asking the program to do something that is possible. So sometimes theconnections you make in Pd may cause your computer to freeze or the application to crash. To protect againstthis save your work often and try not to let this bother you, because as you learn more and more about thislanguage you will make fewer and fewer mistakes and eventually you will be able to program patches whichare as stable and predictable as you want them to be.

    The Nyquist Number and Foldover/Aliasing 7

  • It's All Just Numbers 8

  • Installing on OS XSoftware name : Pd-extendedHomepage : http://puredata.infoSoftware version used for this installation: Pd-extended 0.39.3Operating System use for this installation: Mac OS 10.4.11Recommended Hardware : Any Mac running Mac OS X 10.4 or later

    To begin the installation visit the download page for Pure Data ( http://puredata.info/downloads ) :

    You can download either Miller Puckette's version of Pure Data, or Pd-extended. Miller's version of Pure Datais called "Pd-vanilla" because it has just the basic minimum set of functionality. It does not contain anyexternal libraries or any of the features developed by the Pure Data community which are included inPd-extended. We will use Pd-extended for this manual, so chose your installer from the "Pd-extended" sectionof this webpage.

    Since there is not a "Universal Binary" for Pd-extended, you will want to select the Mac OS X installer thatbest suits your computer. Use the one labelled "Mac OS X i386" for the newer, Intel-processor equipped Maccomputers. For example, any Mac Pro or MacBook is an Intel Mac. Any iMac that is less that a couple yearsold is an Intel Mac.

    Use the "Mac OS X PowerPC" installer if you have a PowerMac, PowerBook, or iBook with a G4 or G5processor running Mac OS 10.4 "Tiger" or later. Older iMacs use G4 and G5 processors, so they use thePowerPC version as well.

    If your computer has a G3 processor or is running Mac OS X 10.3 Panther, then you will need to use olderversion of Pd-extended, 0.39.3. You can see all of the older versions on the downloads page by clicking on .There you can also find installers for versions of Mac OS X older than 10.3 Panther.

    Installing on OS X 9

  • Once you've downloaded the right installer, you'll have a .dmg (Disk Image) on your harddrive.

    Double click to open and mount it, and you will have a chance to read and accept the License Agreement.

    Once you click "Agree", the Disk Image will mount and automatically open. Then simply drag thePd-extended.app to the provided shortcut to your Applications folder (or to another location of your choice.)This will copy Pd-extended to your harddrive.

    Installing on OS X 10

  • After that, make sure to check the "ReadMe" file for important installation information.

    As indicated, the Pd-extended.app is setup by default to load most of the included external libraries. If youwant to change the libraries which are loaded at startup time, or any of the other startup settings, please noticethe instructions here in the "ReadMe", and be sure to read the chapter "Configuring Pure Data" in thismanual.

    From here, you can open up your "Applications" folder in the Finder, and start Pd by clicking the"Pd-extended.app" icon found there.

    Status: X11 Library not loadedWhen starting Pd-extended it will check to see if all standard libraries are loaded. The X11 library is anexpected fundamental graphics library. If you see the following error message in the Pd window, you do nothave X11 installed on your Mac. Instructions to install X11 follow.

    Status: X11 Library not loaded 11

  • Installing X11 on Mac OS X 10.3 Panther and 10.4 TigerPd-extended needs X11 for some graphics libraries. Starting with Mac OS X 10.5 Leopard, X11 comesinstalled by default. If you are running Mac OS X older than 10.5 Leopard, then you will need install ityourself, if you haven't already. It comes on your Mac OS X DVD or CD. If you no longer have that DVD orCD, then you can find it online. The FAQ on puredata.info has the current links:http://puredata.info/docs/faq/macosx

    Insert your OS X Tiger Install Disc (#1). Scroll down to locate the Optional Installs icon anddouble-click it

    1.

    Click Continue on the first screen2.

    Installing X11 on Mac OS X 1