ebook img

Digital Electronics for Musicians PDF

505 Pages·2015·17.8 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Digital Electronics for Musicians

Digital Electronics for Musicians D TECHNOLOGY IN ACTION™ r y m Digital Electronics for Musicians is the perfect book for musicians who want to dive into the Related Titles o world of computer music and physical computing. This book is aimed at adventurous musicians n who want to learn about music programming with Arduino, sensors, and Pure Data, and how i t to make new interfaces and even new instruments with that knowledge. i s 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 D stand-alone projects. Along the way, you’ll learn how to create a variety of innovative musical i projects, including an interactive bow for stringed instruments, a MIDI clavier synthesizer, an g interactive drum set, a patch-bay matrix synthesizer, a guitar looper, and even a DIY theremin. i t If you are a musician or tinkerer who wants to explore the world of electronic and electroacoustic a music and musical interfaces with Arduino, sensors, and Pure Data, Digital Electronics for l Musicians is the book for you. E •Learn the basics of the Pure Data and the Arduino languages l e •Learn more about the available sensors on the market, and how you can incorporate c them into your musical projects t •Focus on physical computing by combining Arduino and Pure Data, bringing the r physical world to the world of the computers o •Make use of additional libraries that extend the capabilities of the Arduino n •Make use of external objects in Pure Data that help achieve certain goals, depending i on the project c •Learn how a Pure Data patch functions, being able to create your own, or use already s Digital Electronics existing patches being able to modify them in order to f it your needs f •Learn how the Arduino language works, being able to write code from scratch, or modify o already existing code, according to your needs r •Get insight on the serial communication between the Arduino and Pure Data M for Musicians •Learn how to approach various programming challenges in diff erent ways u s i c i a n Build Intuitive Electronic and s Electroacoustic Music Interfaces — US $39.99 Alexandros Drymonitis Shelve in: ISBN 978-1-4842-1584-5 53999 Computer Hardware/General User level: Beginning–Intermediate 9781484215845 SOURCE CODE ONLINE www.apress.com Digital Electronics for Musicians Alexandros Drymonitis Digital Electronics for Musicians Copyright © 2015 by Alexandros Drymonitis This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Exempted from this legal reservation are brief excerpts in connection with reviews or scholarly analysis or material supplied specifically for the purpose of being entered and executed on a computer system, for exclusive use by the purchaser of the work. Duplication of this publication or parts thereof is permitted only under the provisions of the Copyright Law of the Publisher’s location, in its current version, and permission for use must always be obtained from Springer. Permissions for use may be obtained through RightsLink at the Copyright Clearance Center. Violations are liable to prosecution under the respective Copyright Law. ISBN-13 (pbk): 978-1-4842-1584-5 ISBN-13 (electronic): 978-1-4842-1583-8 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Lead Editor: Michelle Lowman Technical Reviewer: Johan Eriksson Editorial Board: Steve Anglin, Pramila Balan, Louise Corrigan, James T. DeWolf, Jonathan Gennick, Robert Hutchinson, Celestin Suresh John, Michelle Lowman, James Markham, Susan McDermott, Matthew Moodie, Jeffrey Pepper, Douglas Pundick, Ben Renow-Clarke, Gwenan Spearing Coordinating Editor: Mark Powers Copy Editor: Kimberly Burton Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit www.apress.com. Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales–eBook Licensing web page at www.apress.com/bulk-sales. Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com/9781484215845. For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/. Readers can also access source code at SpringerLink in the Supplementary Material section for each chapter. Contents at a Glance About the Author �����������������������������������������������������������������������������������������������������xv About the Technical Reviewer �������������������������������������������������������������������������������xvii Acknowledgments ��������������������������������������������������������������������������������������������������xix Introduction ������������������������������������������������������������������������������������������������������������xxi ■ Chapter 1: Introduction to Pure Data ���������������������������������������������������������������������1 ■ Chapter 2: Introduction to Arduino ����������������������������������������������������������������������51 ■ Chapter 3: Embedded Computers and Going Wireless ����������������������������������������97 ■ Chapter 4: Getting Started with Musical Applications ��������������������������������������141 ■ Chapter 5: A Simple Synthesizer Using a MIDI Keyboard and Arduino �������������177 ■ Chapter 6: An Interactive Bow ���������������������������������������������������������������������������233 ■ Chapter 7: An Interactive Drum Set �������������������������������������������������������������������267 ■ Chapter 8: A DIY Theremin ��������������������������������������������������������������������������������317 ■ Chapter 9: Making a Looper ������������������������������������������������������������������������������363 ■ Chapter 10: A Patch-Bay Matrix Synthesizer ����������������������������������������������������417 Index ���������������������������������������������������������������������������������������������������������������������481 iii Contents About the Author �����������������������������������������������������������������������������������������������������xv About the Technical Reviewer �������������������������������������������������������������������������������xvii Acknowledgments ��������������������������������������������������������������������������������������������������xix Introduction ������������������������������������������������������������������������������������������������������������xxi ■ Chapter 1: Introduction to Pure Data ���������������������������������������������������������������������1 Pd Basics: How It Works ���������������������������������������������������������������������������������������������������2 Our First Patch������������������������������������������������������������������������������������������������������������������3 The Control Domain ��������������������������������������������������������������������������������������������������������������������������������6 Execution Order ��������������������������������������������������������������������������������������������������������������������������������������7 Bang! ������������������������������������������������������������������������������������������������������������������������������������������������������8 Comments ��������������������������������������������������������������������������������������������������������������������������������������������10 Getting Help ��������������������������������������������������������������������������������������������������������������������10 GUIs ��������������������������������������������������������������������������������������������������������������������������������11 Pd Patches Behave Like Text Files ��������������������������������������������������������������������������������������������������������12 Making Oscillators in Pd �������������������������������������������������������������������������������������������������13 Making a Triangle Wave Oscillator ��������������������������������������������������������������������������������������������������������14 Making a Sawtooth Oscillator ���������������������������������������������������������������������������������������������������������������15 Making a Square Wave Oscillator ���������������������������������������������������������������������������������������������������������16 Using Tables in Pd ����������������������������������������������������������������������������������������������������������17 Subpatches and Abstractions �����������������������������������������������������������������������������������������20 Control Domain vs� Signal Domain ���������������������������������������������������������������������������������24 Audio Input in Pd ������������������������������������������������������������������������������������������������������������26 v ■ Contents Basic Electronic Music Techniques ��������������������������������������������������������������������������������27 Additive Synthesis ��������������������������������������������������������������������������������������������������������������������������������27 Ring Modulation ������������������������������������������������������������������������������������������������������������������������������������28 Amplitude Modulation���������������������������������������������������������������������������������������������������������������������������29 Frequency Modulation ��������������������������������������������������������������������������������������������������������������������������30 Envelopes ���������������������������������������������������������������������������������������������������������������������������������������������31 Delay Lines in Pd ����������������������������������������������������������������������������������������������������������������������������������34 Reverb ��������������������������������������������������������������������������������������������������������������������������������������������������38 Filters ����������������������������������������������������������������������������������������������������������������������������������������������������39 Making Wireless Connections ����������������������������������������������������������������������������������������42 Audio and MIDI Settings �����������������������������������������������������������������������������������������������������������������������46 Additional Thoughts ��������������������������������������������������������������������������������������������������������49 Conclusion ����������������������������������������������������������������������������������������������������������������������50 ■ Chapter 2: Introduction to Arduino ����������������������������������������������������������������������51 Arduino Jump Start ��������������������������������������������������������������������������������������������������������51 Parts List ������������������������������������������������������������������������������������������������������������������������52 The Blink Sketch ������������������������������������������������������������������������������������������������������������53 Digital Input ��������������������������������������������������������������������������������������������������������������������59 Defining Variables in Arduino ����������������������������������������������������������������������������������������������������������������60 Further Explanation of the Code �����������������������������������������������������������������������������������������������������������60 Classes in Arduino and the Serial Communication �������������������������������������������������������������������������������61 Further Explanation ������������������������������������������������������������������������������������������������������������������������������61 Building Circuits on a Breadboard ��������������������������������������������������������������������������������������������������������61 Pull-up vs� Pull-down Resistors �������������������������������������������������������������������������������������64 Both Digital Input and Output �����������������������������������������������������������������������������������������66 Analog Input �������������������������������������������������������������������������������������������������������������������69 Analog Input and Output �������������������������������������������������������������������������������������������������71 Reading More Than One Pin, Arrays, and the for Loop ���������������������������������������������������74 Explaining the for Loop �������������������������������������������������������������������������������������������������������������������������74 Using Arrays in Arduino ������������������������������������������������������������������������������������������������������������������������75 vi ■ Contents Analog and Digital Input �������������������������������������������������������������������������������������������������77 Communicating with Pd �������������������������������������������������������������������������������������������������81 Sending Data from Pd to Arduino �����������������������������������������������������������������������������������91 Conclusion ����������������������������������������������������������������������������������������������������������������������95 ■ Chapter 3: Embedded Computers and Going Wireless ����������������������������������������97 Before You Begin ������������������������������������������������������������������������������������������������������������97 Parts List ������������������������������������������������������������������������������������������������������������������������98 Why Use Embedded Computers? �����������������������������������������������������������������������������������98 Which Embedded Computer? ���������������������������������������������������������������������������������������������������������������99 Getting Started with the Pi �������������������������������������������������������������������������������������������100 Getting Your Computer’s IP �����������������������������������������������������������������������������������������������������������������101 Logging in the Pi from OS X and Linux �����������������������������������������������������������������������������������������������102 Logging in from Windows �������������������������������������������������������������������������������������������������������������������102 Configure the Pi ����������������������������������������������������������������������������������������������������������������������������������106 Navigating Through the Linux system ��������������������������������������������������������������������������107 Editing Text Files in Linux �������������������������������������������������������������������������������������������������������������������109 Installing Software �������������������������������������������������������������������������������������������������������110 Installing Pd ����������������������������������������������������������������������������������������������������������������������������������������110 Launching Pd ��������������������������������������������������������������������������������������������������������������������������������������111 Setting up External Libraries in Pd �����������������������������������������������������������������������������������������������������112 Installing Arduino ��������������������������������������������������������������������������������������������������������������������������������114 Let’s Talk About Versions �������������������������������������������������������������������������������������������������������������������115 Exchanging Files Between Your Computer and the Pi ��������������������������������������������������116 Transfer Files from OS X and Linux to the Pi, and Vice Versa �������������������������������������������������������������116 Transfer Files from Windows to the Pi and Vice Versa ������������������������������������������������������������������������117 Changing the IP of the Pi ����������������������������������������������������������������������������������������������119 Setting a Static IP on Linux �����������������������������������������������������������������������������������������������������������������120 Setting a Static IP on OS X ������������������������������������������������������������������������������������������������������������������121 Setting a Static IP on Windows �����������������������������������������������������������������������������������������������������������122 Log in to the Pi Without a Router ��������������������������������������������������������������������������������������������������������123 vii ■ Contents Shutting Down the Pi ����������������������������������������������������������������������������������������������������124 Going Wireless ��������������������������������������������������������������������������������������������������������������126 Bluetooth vs� XBee������������������������������������������������������������������������������������������������������������������������������126 Using a Bluetooth Module with Arduino ���������������������������������������������������������������������������������������������128 Using the XBee with Arduino ��������������������������������������������������������������������������������������������������������������131 Conclusion ��������������������������������������������������������������������������������������������������������������������138 ■ Chapter 4: Getting Started with Musical Applications ��������������������������������������141 Parts List ����������������������������������������������������������������������������������������������������������������������141 Phase Modulation Interface������������������������������������������������������������������������������������������141 How Phase Modulation Works ������������������������������������������������������������������������������������������������������������142 Making the Pd Patch ���������������������������������������������������������������������������������������������������������������������������143 Arduino Code for Phase Modulation Patch �����������������������������������������������������������������������������������������146 Circuit for Arduino Code ����������������������������������������������������������������������������������������������������������������������149 A Simple Drum Machine Interface��������������������������������������������������������������������������������150 Building the Pd Patch �������������������������������������������������������������������������������������������������������������������������151 Arduino Code for Drum Machine Patch ����������������������������������������������������������������������������������������������162 Drum Machine and Phase Modulation Combination ����������������������������������������������������166 Arduino Code ��������������������������������������������������������������������������������������������������������������������������������������166 Arduino Circuit ������������������������������������������������������������������������������������������������������������������������������������169 Pd Patch for Drum Machine-Phase Modulation Interface�������������������������������������������������������������������170 Conclusion ��������������������������������������������������������������������������������������������������������������������176 ■ Chapter 5: A Simple Synthesizer Using a MIDI Keyboard and Arduino �������������177 Parts List ����������������������������������������������������������������������������������������������������������������������178 What Is MIDI? ���������������������������������������������������������������������������������������������������������������178 Pd and MIDI ������������������������������������������������������������������������������������������������������������������179 How [notein] Works ����������������������������������������������������������������������������������������������������������������������������180 Using a Different Tuning and an Amplitude Envelope with [notein] ����������������������������������������������������181 Polyphony with MIDI in Pd ������������������������������������������������������������������������������������������������������������������183 viii ■ Contents MIDI Control Messages in Pd ��������������������������������������������������������������������������������������������������������������186 Pitch Bend Messages in Pd ����������������������������������������������������������������������������������������������������������������188 Program Change MIDI Messages in Pd�����������������������������������������������������������������������������������������������190 Arduino Code ����������������������������������������������������������������������������������������������������������������191 Explaining the Code ����������������������������������������������������������������������������������������������������������������������������194 Pd Patch �����������������������������������������������������������������������������������������������������������������������196 The arduino_stuff Subpatch ���������������������������������������������������������������������������������������������������������������197 The create_envelope and generic_data Subpatches �������������������������������������������������������������������������198 The [poly_synth~] Abstraction �����������������������������������������������������������������������������������������������������������200 The [pd $0-voice_creation_loop] subpatch ����������������������������������������������������������������������������������������201 How Dollar Signs Work in Pd ��������������������������������������������������������������������������������������������������������������203 The [synth_voice~] Abstraction ����������������������������������������������������������������������������������������������������������203 The filter~ Subpatch ���������������������������������������������������������������������������������������������������������������������������210 Done with Patching, Time to Test ��������������������������������������������������������������������������������������������������������211 Arduino Receiving MIDI Messages from the MIDI Keyboard ����������������������������������������213 Arduino Circuit Additions ��������������������������������������������������������������������������������������������������������������������213 Arduino Code Additions ����������������������������������������������������������������������������������������������������������������������215 Pd Patch Receiving MIDI Data from Arduino ���������������������������������������������������������������������������������������217 Running the Pd patch on Raspberry Pi �������������������������������������������������������������������������219 Launching Pd on Boot with the Raspbian Jessie Image ���������������������������������������������������������������������220 Launching Pd on Boot with the Raspbian Wheezy Image or with Another Embedded Computer Running Debian Jessie �����������������������������������������������������������������������������������������������������������������������221 Shutting Down the Pi (or Any Embedded Computer) While Running Headless ���������������������������������������������������������������������������������������������������������������������223 A Small Caveat for the Raspbian and Debian Wheezy Images �����������������������������������������������������������224 Using an External Sound Card with the Pi ������������������������������������������������������������������������������������������225 Editing the Pd Patch When Pd is Running on Boot �����������������������������������������������������������������������������227 Enclosing the Pi in the Keyboard ����������������������������������������������������������������������������������228 Choosing the Perforated Board �����������������������������������������������������������������������������������������������������������228 ix ■ Contents Reducing the Wires of Your Circuit Board ���������������������������������������������������������������������229 Choosing the Right Power Supply and Getting Access to the Power Pins ������������������������������������������230 Accessing the MIDI Pins ���������������������������������������������������������������������������������������������������������������������230 Bringing the Power Input and Audio Output out of the Enclosure ������������������������������������������������������232 Conclusion ��������������������������������������������������������������������������������������������������������������������232 ■ Chapter 6: An Interactive Bow ���������������������������������������������������������������������������233 Parts List ����������������������������������������������������������������������������������������������������������������������233 Writing Custom Functions ��������������������������������������������������������������������������������������������234 A Function of the Data Type void ��������������������������������������������������������������������������������������������������������236 Actual Code for the Project �����������������������������������������������������������������������������������������������������������������237 The Test Circuit of the Accelerometer �������������������������������������������������������������������������������������������������240 The Test Pd Patch �������������������������������������������������������������������������������������������������������������������������������242 Building the Pd Patch ���������������������������������������������������������������������������������������������������243 How to Use the Graph-On-Parent Feature ������������������������������������������������������������������������������������������243 Setting the Properties of the GOP GUIs �����������������������������������������������������������������������������������������������245 What We Have Achieved So Far in this Project’s Pd Patch �����������������������������������������������������������������245 Using the Canvas to Create Visual Feedback ��������������������������������������������������������������������������������������246 Building the Audio Processing Part of the Patch ��������������������������������������������������������������������������������248 The Finished Patch �����������������������������������������������������������������������������������������������������������������������������255 Additions to the Arduino Sketch �����������������������������������������������������������������������������������258 Finalizing the Circuit �����������������������������������������������������������������������������������������������������260 Using Bluetooth and a Voltage Divider Instead of the XBee����������������������������������������������������������������264 Conclusion ��������������������������������������������������������������������������������������������������������������������266 ■ Chapter 7: An Interactive Drum Set �������������������������������������������������������������������267 Parts List ����������������������������������������������������������������������������������������������������������������������267 Other Things We’ll Need �����������������������������������������������������������������������������������������������268 First Approach to Detecting Drum Hits �������������������������������������������������������������������������268 First Version of the Circuit ������������������������������������������������������������������������������������������������������������������269 Read the Drum Hits in Pd �������������������������������������������������������������������������������������������������������������������270 x

Description:
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 th
See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.