E-Book, Englisch, 505 Seiten
Drymonitis Digital Electronics for Musicians
1. ed
ISBN: 978-1-4842-1583-8
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
E-Book, Englisch, 505 Seiten
ISBN: 978-1-4842-1583-8
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
This is the perfect book for musicians who want to dive into the world of computer music and physical computing. This book is aimed at adventurous musicians who want to learn about music programming with Arduino, sensors, and Pure Data, and how to make new interfaces and even new instruments with that knowledge. You'll learn the basics of the Pure Data and Arduino languages, how to incorporate sensors into your musical projects, and how to use embedded computers, like the Raspberry Pi, to create stand-alone projects. Along the way, you'll learn how to create a variety of innovative (Mark, Michelle, I guess they are innovative, but not 100% sure) musical projects, including an interactive bow for stringed instruments, a MIDI clavier synthesizer, an interactive drum set, a patch-bay matrix synthesizer, a guitar looper, and even a DIY theremin. If you are a musician or tinkerer who wants to explore the world of electronic and electroacoustic music and musical interfaces with Arduino, sensors, and Pure Data, Digital Electronics for Musicians is the book for you. What You Will Learn• Learn the basics of the Pure Data and the Arduino languages• Learn more about the available sensors on the market, and how you can incorporate them into your musical projects• Focus on physical computing by combining Arduino and Pure Data, bringing the physical world to the world of the computers• Make use of additional libraries that extend the capabilities of the Arduino• Make use of external objects in Pure Data that help achieve certain goals, depending on the project• Learn how a Pure Data patch functions and be able to modify other people's work that fits your needs• Learn how the Arduino language works, enabling the modification of already existing code, according to your needs• Get insight on the serial communication between the Arduino and Pure Data• Learn how to approach various programming challenges in different ways
Who This is For Musicians who want to explore the world of electronic and electroacoustic music and musical interfaces with Arduino, sensors, and Pure Data.
Alexandros Drymonitis is a musician from Athens, Greece. He studied at the Conservatory of Amsterdam where he got his first stimuli on music technology. Ever since he has been making electronic music using open source software and hardware, like Pure Data and Arduino, as well as giving workshops on electronic music programming and digital synthesizer building. He is also very keen on community building, and is a founding member of the Patching Circle Athens group, a group of users of visual programming languages.
Autoren/Hrsg.
Weitere Infos & Material
1;Contents at a Glance;4
2;Contents;5
3;About the Author;15
4;About the Technical Reviewer;16
5;Acknowledgments;17
6;Introduction;18
7;Chapter 1: Introduction to Pure Data;19
7.1; Pd Basics: How It Works;20
7.2; Our First Patch;21
7.2.1; The Control Domain;24
7.2.2; Execution Order;25
7.2.3; Bang!;26
7.2.4; Comments;28
7.3; Getting Help;28
7.4; GUIs;29
7.4.1; Pd Patches Behave Like Text Files;30
7.5; Making Oscillators in Pd;31
7.5.1; Making a Triangle Wave Oscillator;32
7.5.2; Making a Sawtooth Oscillator;33
7.5.3; Making a Square Wave Oscillator;34
7.6; Using Tables in Pd;35
7.7; Subpatches and Abstractions;38
7.8; Control Domain vs. Signal Domain;42
7.9; Audio Input in Pd;44
7.10; Basic Electronic Music Techniques;45
7.10.1; Additive Synthesis;45
7.10.2; Ring Modulation;46
7.10.3; Amplitude Modulation;47
7.10.4; Frequency Modulation;48
7.10.5; Envelopes;49
7.10.6; Delay Lines in Pd;52
7.10.7; Reverb;56
7.10.8; Filters;57
7.11; Making Wireless Connections;60
7.11.1; Audio and MIDI Settings;64
7.11.1.1;MIDI Settings on Linux;66
7.11.1.2;A Bit More on MIDI;67
7.12; Additional Thoughts;67
7.13; Conclusion;68
8;Chapter 2: Introduction to Arduino;69
8.1; Arduino Jump Start;69
8.2; Parts List;70
8.3; The Blink Sketch;71
8.4; Digital Input;77
8.4.1; Defining Variables in Arduino;78
8.4.2; Further Explanation of the Code;78
8.4.3; Classes in Arduino and the Serial Communication;79
8.4.4; Further Explanation;79
8.4.5; Building Circuits on a Breadboard;79
8.5; Pull-up vs. Pull-down Resistors;82
8.6; Both Digital Input and Output;84
8.7; Analog Input;87
8.8; Analog Input and Output;89
8.9; Reading More Than One Pin, Arrays, and the for Loop;92
8.9.1; Explaining the for Loop;92
8.9.2; Using Arrays in Arduino;93
8.10; Analog and Digital Input;95
8.11; Communicating with Pd;99
8.12; Sending Data from Pd to Arduino;109
8.13; Conclusion;113
9;Chapter 3: Embedded Computers and Going Wireless;115
9.1; Before You Begin;115
9.2; Parts List;116
9.3; Why Use Embedded Computers?;116
9.3.1; Which Embedded Computer?;117
9.4; Getting Started with the Pi;118
9.4.1; Getting Your Computer’s IP;119
9.4.2; Logging in the Pi from OS X and Linux;120
9.4.3; Logging in from Windows;120
9.4.4; Configure the Pi;124
9.5; Navigating Through the Linux system;125
9.5.1; Editing Text Files in Linux;127
9.6; Installing Software;128
9.6.1; Installing Pd;128
9.6.2; Launching Pd;129
9.6.3; Setting up External Libraries in Pd;130
9.6.4; Installing Arduino;132
9.6.5; Let’s Talk About Versions;133
9.7; Exchanging Files Between Your Computer and the Pi;134
9.7.1; Transfer Files from OS X and Linux to the Pi, and Vice Versa;134
9.7.2; Transfer Files from Windows to the Pi and Vice Versa;135
9.8; Changing the IP of the Pi;137
9.8.1; Setting a Static IP on Linux;138
9.8.2; Setting a Static IP on OS X;139
9.8.3; Setting a Static IP on Windows;140
9.8.4; Log in to the Pi Without a Router;141
9.8.4.1;Save Login Sessions on Windows;142
9.9; Shutting Down the Pi;142
9.10; Going Wireless;144
9.10.1; Bluetooth vs. XBee;144
9.10.2; Using a Bluetooth Module with Arduino;146
9.10.3; Using the XBee with Arduino;149
9.10.3.1;Connecting to the XBee from Linux and OS X;149
9.10.3.2;Connecting to the XBee from Windows;152
9.10.3.2.1;Configuring the XBee;153
9.11; Conclusion;156
10;Chapter 4: Getting Started with Musical Applications;158
10.1; Parts List;158
10.2; Phase Modulation Interface;158
10.2.1; How Phase Modulation Works;159
10.2.2; Making the Pd Patch;160
10.2.2.1;Receiving Values from the Arduino;160
10.2.2.2;Implementing Phase Modulation in Pd;160
10.2.2.2.1;Building the Modulator Oscillator;161
10.2.2.2.2;Mapping the Index Values;162
10.2.2.3;Handling the Values Received from the Arduino;162
10.2.2.4;Sending Data from Pd to the Arduino;163
10.2.3; Arduino Code for Phase Modulation Patch;163
10.2.3.1;Defining Constants, Variables, and Pin Modes;165
10.2.3.2; Handling Input from the Serial Line;165
10.2.3.3;Reading the Analog and Digital Pins and Writing the Values to the Serial Line;165
10.2.4; Circuit for Arduino Code;166
10.3; A Simple Drum Machine Interface;167
10.3.1; Building the Pd Patch;168
10.3.1.1;The Parent Patch;168
10.3.1.2;The arduino_stuff Subpatch;168
10.3.1.3;The sound_tabs Subpatch;169
10.3.1.4;The audio_out Subpatch;171
10.3.1.5;The metronome Subpatch;172
10.3.1.6;The set_sequence Subpatch;175
10.3.1.6.1;The diffuse_beats Subpatch;175
10.3.1.6.2;The set_tab Subpatch;178
10.3.1.7;Concluding the Patch and Explaining the Data received from the Arduino;179
10.3.2; Arduino Code for Drum Machine Patch;179
10.3.2.1;Circuit for Arduino Code;181
10.4; Drum Machine and Phase Modulation Combination;183
10.4.1; Arduino Code;183
10.4.2; Arduino Circuit;186
10.4.3; Pd Patch for Drum Machine-Phase Modulation Interface;187
10.4.3.1;The arduino_stuff Subpatch;187
10.4.3.2;The metronome Subpatch;189
10.4.3.3;The drum_machine Subpatch;190
10.4.3.4;The phase_modulation Subpatch;190
10.4.3.4.1;The modulator Subpatch;192
10.5; Conclusion;193
11;Chapter 5: A Simple Synthesizer Using a MIDI Keyboard and Arduino;194
11.1; Parts List;195
11.2; What Is MIDI?;195
11.3; Pd and MIDI;196
11.3.1; How [notein] Works;197
11.3.2; Using a Different Tuning and an Amplitude Envelope with [notein];198
11.3.2.1;Holding the Sustain Part of the Envelope;199
11.3.3; Polyphony with MIDI in Pd;200
11.3.4; MIDI Control Messages in Pd;203
11.3.5; Pitch Bend Messages in Pd;205
11.3.6; Program Change MIDI Messages in Pd;207
11.4; Arduino Code;208
11.4.1; Explaining the Code;211
11.4.1.1;The setup and loop Functions;212
11.4.1.2;Enter the New Technique;212
11.5; Pd Patch;213
11.5.1; The arduino_stuff Subpatch;214
11.5.2; The create_envelope and generic_data Subpatches;215
11.5.3; The [poly_synth~] Abstraction;217
11.5.4; The [pd $0-voice_creation_loop] subpatch;218
11.5.5; How Dollar Signs Work in Pd;220
11.5.6; The [synth_voice~] Abstraction;220
11.5.6.1;The modulator Subpatch and Its Subpatches;225
11.5.6.2;The carrier Subpatch;225
11.5.6.3;The Amplitude Envelope;226
11.5.6.4;The gate Subpatch, How It Works, and How We Manage the Audio of [synth_voice~];226
11.5.7; The filter~ Subpatch;227
11.5.8; Done with Patching, Time to Test;228
11.6; Arduino Receiving MIDI Messages from the MIDI Keyboard;230
11.6.1; Arduino Circuit Additions;230
11.6.2; Arduino Code Additions;232
11.6.3; Pd Patch Receiving MIDI Data from Arduino;234
11.6.3.1;Pd Patch Receiving a Constant Velocity;235
11.7; Running the Pd patch on Raspberry Pi;236
11.7.1; Launching Pd on Boot with the Raspbian Jessie Image;237
11.7.2; Launching Pd on Boot with the Raspbian Wheezy Image or with Another Embedded Computer Running Debian Jessie;238
11.7.2.1;Using a USB MIDI Keyboard with the Pi;239
11.7.3; Shutting Down the Pi (or Any Embedded Computer) While Running Headless;240
11.7.4; A Small Caveat for the Raspbian and Debian Wheezy Images;241
11.7.5; Using an External Sound Card with the Pi;242
11.7.6; Editing the Pd Patch When Pd is Running on Boot;244
11.8; Enclosing the Pi in the Keyboard;245
11.8.1; Choosing the Perforated Board;245
11.9; Reducing the Wires of Your Circuit Board;246
11.9.1; Choosing the Right Power Supply and Getting Access to the Power Pins;247
11.9.2; Accessing the MIDI Pins;247
11.9.3; Bringing the Power Input and Audio Output out of the Enclosure;249
11.10; Conclusion;249
12;Chapter 6: An Interactive Bow;250
12.1; Parts List;250
12.2; Writing Custom Functions;251
12.2.1; A Function of the Data Type void;253
12.2.2; Actual Code for the Project;254
12.2.2.1;Detecting Button Pressed and Acting Accordingly;255
12.2.2.2;The Custom Function of the Project;256
12.2.3; The Test Circuit of the Accelerometer;257
12.2.4; The Test Pd Patch;259
12.3; Building the Pd Patch;260
12.3.1; How to Use the Graph-On-Parent Feature;260
12.3.2; Setting the Properties of the GOP GUIs;262
12.3.3; What We Have Achieved So Far in this Project’s Pd Patch;262
12.3.4; Using the Canvas to Create Visual Feedback;263
12.3.5; Building the Audio Processing Part of the Patch;265
12.3.5.1;Pitch Shift Subpatch;265
12.3.5.2;Frequency Modulation Subpatch;268
12.3.6; The Finished Patch;272
12.4; Additions to the Arduino Sketch;275
12.5; Finalizing the Circuit;277
12.5.1; Using Bluetooth and a Voltage Divider Instead of the XBee;281
12.6; Conclusion;283
13;Chapter 7: An Interactive Drum Set;284
13.1; Parts List;284
13.2; Other Things We’ll Need;285
13.3; First Approach to Detecting Drum Hits;285
13.3.1; First Version of the Circuit;286
13.3.2; Read the Drum Hits in Pd;287
13.3.3; Getting the Maximum Value in Arduino;288
13.3.3.1;Updating the sensor_thresh Array;289
13.3.3.2;Reading All Values Above the Threshold Along with the Maximum Value;289
13.3.3.3; Debouncing the Fluctuation Around the Threshold;291
13.3.3.3.1; Getting Time Stamps;293
13.3.4; Getting the Maximum Value in Pd;294
13.4; Having Some Fun Before We Finalize;297
13.4.1; Working Further with the Circuit and Arduino Code;299
13.4.2; Adding Switches and LEDs to the Circuit and Code;299
13.4.2.1;Using the Switches to Control Either Playback Type or Sensor Activity;303
13.5; Building the Final Pd Patch;306
13.5.1; Building the Audio File Abstraction;306
13.5.1.1; Converting Samples to Milliseconds and Dealing with the Sampling Rate;307
13.5.1.2;Creating Different Types of Playback;308
13.5.1.2.1; The “$0-ascend” subpatch;310
13.5.1.3; The $0-descend Subpatch;311
13.5.1.4; The $0-repeatedly Subpatch;313
13.5.1.5; The $0-extract_list Subpatch;314
13.5.1.6; The $0-repeat_list Subpatch;315
13.5.1.7; The $0-set_ramp_length Subpatch;316
13.5.2; Building the Abstraction to Receive Input from the Arduino;318
13.5.3; Sending the Threshold and Debounce Values to the Arduino;319
13.5.4; The Main Patch;319
13.5.4.1;The sound_tabs Subpatch;320
13.5.4.2; The make-window Subpatch;321
13.5.4.3; The control_type Subpatch;323
13.5.4.4;Change the Properties of the Playback Type Canvases;325
13.5.4.5; Scaling the Output of the [read_samp] Abstractions in the Parent Patch;325
13.6; Finalizing the Arduino Code;325
13.7; Making the Circuit Enclosure;328
13.8; Conclusion;332
14;Chapter 8: A DIY Theremin;333
14.1; Parts List;333
14.2; Using a Proximity Sensor with the Arduino;334
14.2.1; Refreshing Our Memory on Serial.write;335
14.2.2; Proximity Sensor Circuit;335
14.2.3; Pd Patch That Reads the Proximity Sensor Data;336
14.2.4; Smoothing out the Sensor Values;337
14.2.4.1;Smoothing Out Even More;340
14.3; Using Two Proximity Sensors and Four Potentiometers;342
14.3.1; The Arduino Code;343
14.3.2; The Circuit;345
14.3.3; The Pd Patch;346
14.4; Building the Oscillators for the Theremin;347
14.4.1; Creating Band-Limited Waveforms;347
14.4.1.1;Creating a Triangle Waveform with sinesum;348
14.4.1.2; Creating a Sawtooth Waveform with sinesum;349
14.4.1.3; Creating a Square Waveform with sinesum;350
14.4.2; Reading the Stored Band-Limited Waveforms;351
14.4.2.1;Reading Waveforms with [tabosc4~];352
14.4.2.2; Reading Waveforms with [tabread4~];352
14.4.2.3; Applying Phase Modulation to a Band-Limited Oscillator;353
14.5; Finalizing the Interface;355
14.5.1; Adding Push Buttons to the Arduino Code to Control the Waveforms of the Oscillators;355
14.5.1.1;The Global Variables;357
14.5.1.2;The setup Function;357
14.5.1.3;Using the Push Buttons to Select a Waveform;358
14.5.1.4;Controlling the LEDs According to the Switch and the Push Buttons;358
14.5.1.5;Writing the Data to the Serial Line;359
14.5.2; Making the Circuit;359
14.5.3; Putting It All Together;361
14.5.3.1;Building the Final Pd Patch;365
14.5.3.2;The Subpatches for Choosing Waveform;367
14.5.3.3; Waveforms Subpatch;368
14.6; Enclosing the Project with an Embedded Computer;370
14.6.1; Adding a Push Button for Switching off the Embedded Computer;372
14.6.2; Reading the Extra Push Button in Pd;374
14.6.3; Writing the Script to Shut the Embedded Computer Down;376
14.6.4; Loading the Pd Patch on Boot;376
14.6.4.1;Launching Pd on the Raspberry Pi with the Raspbian Jessie Image;376
14.6.4.2;Launching Pd on Other Embedded Computers or on the Raspberry Pi with the Raspbian Wheezy Image;377
14.7; Conclusion;378
15;Chapter 9: Making a Looper;379
15.1; Parts List;379
15.2; What Is a Looper?;380
15.3; Recording Our First Sounds in Pd;380
15.3.1; Playing Back the Recorded Sound;381
15.3.1.1;Smoothing the Start and End of the Recording;383
15.3.2; Changing the Direction of the Playback;386
15.4; Making Recordings of Arbitrary Lengths;388
15.4.1; Retrieving the Length of the Recording;390
15.5; Overdubbing;392
15.5.1; Getting Rid of Clipping;392
15.5.2; Getting the Start Position of the Overdubbing;393
15.5.3; Knowing When to Stop Overdubbing;394
15.6; Synchronizing End of Recording with Beginning of Playback;396
15.7; Start Building the Interface;397
15.7.1; Writing the Arduino Code;397
15.7.1.1;Writing Functions for the Foot-Switches;398
15.7.1.1.1;The Recording Foot-Switch Function;398
15.7.1.1.2; The Forward Playback Function;399
15.7.1.1.3;The Backward Playback Function;400
15.7.1.2;Calling the Foot-Switch Functions Dynamically;401
15.7.1.2.1;Introducing Pointers in C++;401
15.7.1.2.2;Using Pointers to Functions;403
15.7.1.2.3;Defining a New Data Type for the Function Pointer;404
15.7.1.3;The First Version of the Arduino Code;405
15.7.2; Building the Circuit on a Breadboard;408
15.8; Working Further on the Pd Patch;409
15.8.1; The Recording Module;409
15.8.2; The Phase Module;410
15.8.3; The Playback Module;412
15.8.4; The Overdub Module;412
15.8.5; The Overdub Position Module;413
15.8.6; The Arduino Module;415
15.8.7; The Table Copying Module;416
15.8.8; Putting It All Together;419
15.9; Making Some Final Improvements;422
15.9.1; Modifying the Arduino Code;422
15.9.1.1;Modifying the Recording Function;422
15.9.1.2; Modifying the Forward Playback Function;423
15.9.1.3;Modifying the Backward Playback Function;424
15.9.1.4; Modifying the Beginning of the loop Function;425
15.9.2; Modifying the Pd Patch;425
15.9.2.1;Modifying the Phase Module;425
15.9.2.2;Modifying the Overdub Module;427
15.9.2.3; Modifying the Table Copying Module;427
15.10; Enclosing the Circuit in a Box;430
15.11; Conclusion;432
16;Chapter 10: A Patch-Bay Matrix Synthesizer;433
16.1; Parts List;433
16.2; What We Want to Achieve in this Chapter;434
16.3; Extending the Arduino Analog Pins;435
16.3.1; How a Multiplexer Works;437
16.3.2; Writing Code to Control a Multiplexer;438
16.3.2.1;Defining Preprocessor Directives;439
16.3.2.2; Explaining the Code Further;440
16.3.2.3;Setting the Control Pin Numbers and the Binary Masks;440
16.3.2.4;Reading the 16 Values of the Multiplexer;440
16.3.3; Wiring 16 Potentiometers to the Multiplexer;442
16.3.4; Reading the 16 Potentiometers in Pd;443
16.4; Extending the Arduino Digital Pins;444
16.4.1; Using the Input Shift Register;444
16.4.1.1;Writing the Arduino Code;444
16.4.1.1.1;Including the SPI Library;445
16.4.1.1.2;Defining the Global Variables and Setting up Our Program;445
16.4.1.1.3;The Main loop of the Program;445
16.4.1.2;Making the Input Shift Register Circuit;446
16.4.1.3;The Pd Patch That Reads the Eight Switches;447
16.4.1.4;Daisy Chaining the Input Shift Registers;448
16.4.1.4.1;Extending the Pd Patch to Read 16 Push Buttons;449
16.4.2; Using the Output Shift Register;450
16.4.2.1;Writing the Arduino Code;450
16.4.2.1.1;The bitSet and bitClear Functions;451
16.4.2.2;Making the Output Shift Register Circuit;452
16.4.2.3;Daisy Chaining The Output Shift Registers;454
16.4.3; Combining the Input and Output Shift Registers;455
16.5; Making a Patch-Bay Matrix;457
16.5.1; Implementing a Patch-Bay Matrix with the Arduino;457
16.5.1.1;The Main Mechanism of the Code;460
16.5.1.1.1;The check_connections Function;460
16.5.1.1.2;Continuing with the loop Function;460
16.5.2; Making the Pd Patch That Reads the Connections;461
16.5.2.1;Explaining the Pd Patch;462
16.5.2.1.1;The Heart of the Patch Mechanism;462
16.5.2.1.2;Detecting Connections;463
16.5.3; Making the Patch-Bay Matrix Circuit;463
16.6; Start Building the Audio Part of the Pd Patch;465
16.6.1; A Signal Matrix in Pd;465
16.6.2; Building the Modules for the Synthesizer;467
16.6.2.1;The First Module, a Non-Band Limited Oscillator;467
16.6.2.1.1;The get_inlet_outlet_switch Subpatch;468
16.6.2.1.2;The choose_ndx_input Subpatch;469
16.6.2.1.3;The choose_amp_input Subpatch;471
16.6.2.1.4;The waveforms Subpatches;472
16.6.2.2;The Second Module, a Band-Limited Oscillator;474
16.6.2.2.1;The tables Subpatch;476
16.6.2.2.2;The triangle Subpatch;476
16.6.2.3;Third Module, a Multiple Type Filter;476
16.6.2.3.1;The choose_filter_type Subpatch;477
16.6.2.3.2;The get_inlet_outlet_ switch Subpatch;478
16.6.2.4;The Fourth Module, Two Envelopes;479
16.6.2.4.1;The envelope1 Subpatch;480
16.6.2.4.2;The get_inlet_switch Subpatch;481
16.7; The Final Patch;482
16.7.1; The arduino_stuff Subpatch;483
16.7.1.1;The potentiometers Subpatch;483
16.7.1.2;The create_mtx_msg Subpatch;484
16.7.1.3;The get_switches Subpatch;486
16.8; The Final Arduino Code;487
16.8.1; Using Binary Numbers for Masking;491
16.8.2; The check_connections Function;491
16.8.3; The Main loop Function;491
16.8.4; Controlling the LEDs with the Switches of the Shift Registers;492
16.9; The Final Circuit;492
16.10; Making an Enclosure;493
16.10.1; Shutting down the Embedded Computer;494
16.11; Conclusion;495
17;Index;496




