Teensy Dynamic Sound Effects Processor Digital Signal Processing (DSP) with the Teensy 3.2 & Arduino Platform
Total Page:16
File Type:pdf, Size:1020Kb
Teensy Dynamic Sound Effects Processor Digital Signal Processing (DSP) with the Teensy 3.2 & Arduino Platform Matthew Ooi CMPEH 472 Final Project 12 December, 2017 Prepared for: Dr. Robert Gray CMPEH 472; Pennsylvania State University, Harrisburg Table of Contents: Equipment Used ..................................................................................................................5 Bill of Materials: .................................................................................................................5 Problem Statement ..............................................................................................................5 Abstract & Introduction .......................................................................................................6 Investigation and Research ..................................................................................................6 5.1. Objective ..........................................................................................................................6 5.2. The Teensy 3.2 .................................................................................................................7 5.2.1. Teensy Software ........................................................................................................7 5.2.2. Teensy 3.2 Hardware .................................................................................................8 5.3. Digital Signal Processing (DSP) Basics ............................................................................9 5.3.1. Analog to Digital Conversion (ADC) ....................................................................... 10 5.3.2. Digital to Analog (DAC) .......................................................................................... 10 5.3.3. System Latency ....................................................................................................... 10 5.4. Teensy Audio Shield ...................................................................................................... 11 5.4.1. SGTL5000 Stereo Codec Chip ................................................................................. 11 5.4.2. I2S Bus..................................................................................................................... 11 5.5. Audio Signal Qualities .................................................................................................... 12 5.5.1. Clipping ................................................................................................................... 12 5.5.2. Attenuation .............................................................................................................. 13 5.5.3. Multistage Audio-Mixer System .............................................................................. 13 5.6. Sound Reverberation ...................................................................................................... 14 5.6.1. Naturally Occurring Reverberation .......................................................................... 14 5.6.2. Artificial Reverb Audio Effect Using Software ........................................................ 14 5.6.3. Hardware Limitations of Artificial Reverb ............................................................... 15 5.6.4. Constructing a Simple Reverb .................................................................................. 15 5.7. Distortion Audio Effect .................................................................................................. 16 5.7.1. Clipping ................................................................................................................... 16 5.7.2. Soft Clipping ........................................................................................................... 16 5.7.3. Teensy Audio Library: Bitcrusher Effect .................................................................. 16 5.8. Logarithmic Gain ........................................................................................................... 16 Page 2 Construction and Implementation ...................................................................................... 17 6.1. Defining the Scope ......................................................................................................... 17 6.2. System Design ................................................................................................................ 17 6.2.1. Audio System Flow ................................................................................................. 18 6.2.2. System Layout ......................................................................................................... 21 6.3. Circuit Design ................................................................................................................ 22 6.4. Arduino Code ................................................................................................................. 23 6.4.1. Preprocessor Directives............................................................................................ 25 6.4.2. Including Libraries................................................................................................... 25 6.4.3. OLED Ascii Library ................................................................................................ 26 6.4.4. Defining Classes of Audio System Functions ........................................................... 26 6.4.5. Define Global Variables........................................................................................... 26 6.4.6. Create Object Class for Debounce ............................................................................ 26 6.4.7. Defined OLED I2C Address .................................................................................... 27 6.4.8. Declare Additional Functions ................................................................................... 27 6.4.9. Void Setup Function ................................................................................................ 27 6.4.10. Void Loop Function ............................................................................................... 28 6.4.11. Void Reverb Function ............................................................................................ 33 6.4.12. Void Distortion Function ....................................................................................... 35 6.4.13. Pass-Thru Function ................................................................................................ 36 6.4.14. Int avgDelayTime Function.................................................................................... 36 Analysis and Testing ......................................................................................................... 37 6.5. Testing OLED Display ................................................................................................... 37 6.6. Testing Reverb Effect ..................................................................................................... 38 6.7. Testing Distortion Effect ................................................................................................ 40 Final Evaluation ................................................................................................................ 43 Attachments ...................................................................................................................... 45 References ...................................................................................................................... 59 Page 3 Table of Figures: Figure 5-1: Teensy 3.2 Board [2] .................................................................................................7 Figure 5-2: DSP system stages .................................................................................................. 10 Figure 5-3: Naturally Occurring Reverberation ......................................................................... 14 Figure 6-1: Audio System Flow Design ..................................................................................... 18 Figure 6-2: Labeled Audio System Flow Design ....................................................................... 19 Figure 6-3: Teensy Audio Library Object .................................................................................. 20 Figure 6-4: Audio System Setup ................................................................................................ 21 Figure 6-5: Circuit Schematic .................................................................................................... 23 Figure 6-6: Arduino Software flowchart .................................................................................... 24 Figure 6-7: OLED Display, Mute and Unuted Text ................................................................... 30 Figure 6-8: Exponential Distortion-Effect Control Curve .......................................................... 36 Figure 7-1: OLED Functionality Testing ................................................................................... 38 Figure 7-2: Waveform, Testing Reverb Effect ........................................................................... 39 Figure 7-3: Waveform, Testing Reverb Effect, Maximum Delay ............................................... 39 Figure 7-4: Testing Maximum Reverb Delay............................................................................. 40 Figure 7-5: Distortion Effect Test .............................................................................................