Download Arduino for musicians : a complete guide to Arduino and teensy microcontrollers PDF

TitleArduino for musicians : a complete guide to Arduino and teensy microcontrollers
File Size27.6 MB
Total Pages453
Table of Contents
                            Cover
Arduino™ for Musicians: A Complete Guide to Arduino and Teensy Microcontrollers
Copyright
Dedication
Contents
Preface
	What is Arduino?
	Extension of the Creative Process
	The Road to Parnassus
	How to Use the Book
	Why I Wrote the Book
	Safety Tips
Acknowledgments
About the Companion Website
Arduino™ for Musicians
	1: Getting Started
		Who This Book Is For
		What Is Arduino?
		What You Can Do with Arduino
		What You Can’t Do with Arduino
			The Lay of the Land
				The Arduino Family
				Programming and the Arduino IDE
				Circuitry
				Review
			Design Cycle
			Organization of the Book
			Things You Will Need to Get Started
				Beginner
				Intermediate
				Advanced
				Purchasing Parts
			Conclusion
	2: Introduction to Programming
		What Is a Programming Language?
		Why the C Language?
		Getting Started
		Writing Your First Sketch
			Error Messages
			Uploading a Program
		“Hello, world!” in Detail
			Functions
			Serial Output
			Adding Comments
			Code Improvisation
		Variables, Data Types, and Operators
		Initializing Variables
			Operators
			Code Improvisation
			Data Types
				Bits
			Signed and Unsigned Data Types
			Universal Data Types
		Constants
		Enumerations
		Comparison Operators and Control Structures
			“If” Statements
		Boolean Operators
		Switch Statements
			Code Improvisation
		Control Loops
			While Loop
			Do While Loop
			For Loop
			Endless Loops
		Practical Application
			Code Improvisation
		Writing a First Function
			Function Parameters
			Using a Custom Function
		A First Sketch Involving Hardware
		Introduction to Arrays
			Array Syntax
			Array Initialization
		The Ugly Truth: Working with Text in C
			String Literals
			Character Arrays
			An Easier Way: Using the String Class
			String Class Example
		A Complete Demonstration Program
			Playing the Tempo Game
			Setup
			newGame() Function
			Helper Functions
			Main loop()
		Conclusion
	3: Introduction to Electronics
		Overview
		Pep Talk
		Safety Warning
		Tools and Process
		A First Circuit
			9V Battery
			SPST Switch
			Resistor
			LED
		Using a Breadboard
			A First Breadboard Project
		Ohm’s Law
			Conceptualizing Voltage, Current, and Resistance
			Using Ohm’s Law
		Units of Measurement
			Practical Example of Ohm’s Law
		Using a Digital Multimeter
			Measuring Voltage
				A Few Words About Ground
			Measuring Current
			Measuring Resistance
				Series Circuit
				Parallel Circuit
			A Word About Resistor Color Codes
			Safety Diode and Potentiometer
		Emergency Music Stand Light
			Transistors
			Incorporating a Photoresistor and Transistor
		Cigar Box Amplifier
			Operational Amplifier
			Capacitors
			Calculating Capacitance
				Parallel Circuit
				Series Circuit
			Connecting an Audio Signal to the Amplifier
			Completed Project
		Simple Theremin
			Hex Inverter
			Phase-Locked Loop IC
			Mocking Up the Simple Theremin
		Conclusion
	4: Interfacing with Arduino
		Overview of Arduino UNO
			A Caution
		Overview of the Metronome Project
			Metronome with Speaker
			Metronome with Potentiometer
			Metronome with Pushbutton Switch
				Switch with Resistor
				Switch with Pullup Resistor
				Debouncing
				Improving Tone-Generation Logic
			Complete Source Code
			Metronome with Quadrature Rotary Encoder
				Rotary Encoder
		Conclusion
	5: Music Instrument Digital Interface I/O
		What Is MIDI?
		MIDI Ports
			MIDI OUT Port
			MIDI IN Port
			MIDI THRU Port
		MIDI Messages
			Status Byte
			Data Byte
		Channel Messages and System Messages
			Channel Voice Messages
				Note-Off Message
				Polyphonic Key Pressure (Aftertouch)
				Channel Pressure (aftertouch)
				Program Change
				Pitch Wheel Change
				Control Change
			Other Control Changes and Mode Changes
			Channel Mode Messages
				Reset All Controllers
		System Messages
			System Common Messages
			System Real-Time Messages
			System Exclusive Messages
			Universal System Exclusive Messages
				MIDI Machine Control
		MIDI Hardware
			MIDI Output
				Testing the Output Circuit
				Aleatoric Music Generator
				Using a MIDI Library for Output
			MIDI Receiver Circuit
			MIDI THRU
			Creating Permanent MIDI Circuits
				Reading MIDI Data
		USB MIDI with Teensy
			Configuring Teensy
		Conclusion
	6: Real-Time Input Musical Expression
		Force-Sensitive Resistor
			Wiring an FSR
			Force-Sensitive Drum Pad
				FSR Caution
		Nintendo DS Touch Screen
			Wiring
			Reading the X and Y Positions
		Pressure Sensor
			Pressure Sensor Unit
			Wiring the Pressure Sensor
			Reading Values from the Pressure Sensor
		Joystick
			Wiring a Joystick
			Reading Values from a Joystick
			Joystick Sensitivity
		Wii Nunchuck
			Nunchuck Library
				Nunchuck Code
		Conclusion
	7: Music-Making Shields
		Overview
		Music Instrument Shield (SparkFun Electronics)
			Using the Shield
			“Steve Reich” Sketch
				Panning
		Adafruit Wave Shield
			Wave Shield Library
			Pin Assignments
			Preparing Audio Files for Use with the Wave Shield
			Loading a File
			WaveHC Member Functions and Data Members
				Playing a Wave File
			Demonstration Sketch
		GinSing
			Voice Mode
				Pointers and the Voice Object
				Speech
				Voice Mode Demonstration
			Synthesizer Mode
				Setting Up the Synthesizer
			Mini Synthesizer Project
		Gameduino
			Using the Gameduino
			Additive Synthesis
			Additive Gameduino Synthesizer
			Using a Structure and an Array
				Initializing a Sawtooth Waveform
				Updating the Fundamental Frequency
			Main Loop()
		Codec Shield
			Using the Codec Shield
		Conclusion
	8: Introduction to C++ Programming
		Overview: Moving Away from a Procedural Approach
			Using Objects
			Moving to C++
		Classes
			Anatomy of a Class
				Preprocessor Directives
			Member Variables
			Public and Private Keywords
			Constructors and Destructors
			Source File
			Destructor
			Class Methods
			Using a Class
			More on Overriding Methods
			Other Topics
		Developing a Rotary Encoder Class
			trackShaftPosition()
			Using RotaryEncoder
		Making Your Own Library
		Developing a 12-Tone Matrix Class
			Tone Row
			Overview of Design
				Pseudo-code Logic
			Header File
			Source File
				Bounds Checking
			Using ToneRow in a Sketch
				Helper Functions
		Conclusion
	9: Audio Output and Sound Synthesis
		Analog vs. Digital
		Sample Rate and Resolution
		Resolution
		Conceptualizing a Digital Audio Converter
		Digital Audio Conversion
			R2R Ladder
				DC Component
				Passive Low-Pass Filter
				Setting Up a Timer
				Establishing a Sampling Rate
			DAC Integrated Circuit
			TLC7226 Pinout
				Changes to Boilerplate Code
		Sound Synthesis
			Waveforms
			Generating a Waveform
			Synthesizing a Ramp Waveform
		Fixed-Point Math
			Example 1
			Example 2
		Tuning Oscillator
			Volatile Variables
		Developing an Oscillator Class
			Inheritance
			An Oscillator Base Class
				Default Constructor
				Access Methods
				MIDI-to-Frequency Conversion
				Calculating an Increment Value
				Virtual Methods
			Using Inheritance to Create a Ramp Oscillator
			Sawtooth Oscillator
			Pulse-Width Oscillator
			Triangle Oscillator
			Noise Generator
				Linear Congruential Random Number Generation
			Using a Lookup Table
				Creating a Sine Wave Oscillator
		Using Oscillators
			Modulation
				Control Voltage: VCO vs. DCO
				Modulating a Signal
		Introduction to Mozzi
			Pulse-Width Modulation
			Circuit for PWM Output
		A First Mozzi Sketch
			Incorporating a Filter
			Summing Signals and Adjusting Levels
			Further Exploration
		Audio Output with Teensy 3
			Exploring Teensy 3
	10: Audio Input
		Overview
		Analog-to-Digital Conversion
			Preparing a Signal for Input
				Simple Input Circuit
			Setting Up a Timer for Analog-to-Digital Conversion
				Prescalars
			Building a Simple Arduino Preamp
			Building an Electret Microphone
		Visualizing Audio Data
			Interfacing with Processing
				Waveform View Application
			Testing Waveform View
		Fourier Transform
			Using Data from the FHT
			Spectrum Analyzer
			Other Uses for FFT and FHT
		A Brief Introduction to Signal Processing
			A Few Words About Buffers
			Delay
			Variable Delay
			Tremolo
		High-End Audio Using the Open Music Labs Codec Shield for Real-Time Processing
		Using Mozzi for Audio Input and Processing
			Hardware Setup
			Software Setup
			Setting Up a Low-Pass Filter
			updateControl() Mechanism
			Using mozziAnalogRead()
			Scaling Amplitude in updateAudio()
		Conclusion
	11: Finalizing Projects
		Creating a Permanent Project
			Personal Safety
			Fire Safety
			Protecting Sensitive Electronic Components
		Tools
			Essential Tools
			Helpful Tools
		Visualizing a Final Project
			Prototype
			Component Connections
			Attaching Components
			Consider the Enclosure
			Paper Panel Mock-up
			Print Drilling/Cutting Guides
			Test Drill Bits
		Moving from a Solderless Breadboard to a Solder Breadboard
			Staying Neat: Layout and Wires
			Consistent Layout
			IC Sockets
			Solder Breadboard Options
				Multipurpose Board
				Perforated Board
				Stripboard
			Homemade Printed Circuit Boards
			Ordering Online Printed Circuit Boards
		Soldering
			Solder
			Tinning
			Soldering Process
			Speed
			Appearance
			Holding Parts in Place
		Practical Application
			Soldering Étude 1
			Soldering Étude 2
		Project Boxes
			Wood Box
				Preparing the Front and Back
				Standoffs
				Finishing the Box
			Plexiglas Enclosure
		Front Panels
		Conclusion
	12: Standalone Arduino
		Why Standalone Arduino?
		Parts
			7805 Voltage Regulator
			ATmega328
				Pins
				Connections
		Burning a Bootloader to a Blank ATmega328
			Programming Options
			Other Programming Options
		A Demonstration Project
			Rotary Encoder with Switch
			Complete Circuit
			Code
			7-Segment Serial Display
			Finalizing the Project
	13: MIDI Hand Drum Project
		Overview
		Mongo: MIDI Bongo Drum
		Hardware
			Getting Started
			Making Connections
		Developing the Mongo Firmware
			Software Setup, Global Constants, and Variables
			TouchPad Class
			Program Logic
			Storing Data
			Helper Functions
				playMidiAlert()
				flashLED()
				factoryReset()
		Building the Mongo Drum
			Circuit Design
			Creating an Enclosure
				Installing the Optional Panel Mount Adapter
			Joining the Sides
			Attaching the Bottom
			Adding Corner Posts and Circuit Base
			Installing Components on the Face Plate
			Finishing the Build
			Moving On
	14: Stella Synthesizer Project
		Stella Digital/Analog Synthesizer
			Front Panel
			Circuitry
			Software: Encoders and Buttons
		Serial7Segment Class
		Preamble
		Setup()
			Stella Synth Tasks
				Tracking Potentiometers
				Handling the LFO
				Handling Pushbuttons and Encoder Movement
				Oscillator Button Selection Function
				LFO Selection Function
				Oscillator Value Change Function
			SetFrequencyFromMidiNote()
				Responding to Incoming MIDI Data
			updateAudio()
		Stella Synth in Action
		Enhancements
		Conclusion
	15: Step Sequencer Project
		Hardware and Function
		Getting Started
			Making Connections
				Shift Register
			Step Sequencer Software
				StepSequence class
				StepSequencer class
			Program Logic
				handleModeButton()
				handlePitchEncoder()
				handleStepButtons()
				handleStartStopButton()
				handleStoreButton()
				handleWaveToggleButton()
				handleRatePotentiometer()
				handleLEDs()
			Using the Shift Out IC: turnOnLED()
			Playback
		Building the Step Sequencer
			Primary Circuit
			LED Circuit
			Shift-Register Circuit
			Enclosure
		Other Enhancements
	16: Emöte MIDI Controller
		Circuit
		Enclosure
		Code
			Constants and Variables
			MIDI Breath Controller Class
			MIDI Joystick Class
			Mapping Modulation Values (Y-Axis)
			Mapping Pitch Bend (X-Axis)
			Main loop()
		Conclusion
Conclusion
Appendix A
	MIDI Control Changes
Appendix B
	MMC Commands
	MMC Command Structure
	Single-Byte MMC Commands
	Go To/Locate (multi-byte)
	Shuttle (multi-byte)
Appendix C
	Introduction to Bit Twiddling
	Right- and Left-Shift
	Working with Individual Bits
	Setting a Bit
	Clearing a Bit
	Toggling a Bit
	Checking the Value of a Single Bit
	Exploring the printValue() Function
	Conclusion
	Sources
Notes
	Preface
	Chapter 1
	Chapter 2
	Chapter 3
	Chapter 4
	Chapter 5
	Chapter 6
	Chapter 7
	Chapter 8
	Chapter 9
	Chapter 10
	Chapter 11
	Chapter 12
	Chapter 14
	Conclusion
Bibliography
Index
                        

Similer Documents