Implement a Chorus Effect in a Real-Time Embedded System
Total Page:16
File Type:pdf, Size:1020Kb
Universitat Polit`ecnicade Catalunya (UPC) Escola T`ecnicaSuperior d'Enginyeria de Telecomunicaci´ode Barcelona (ETSETB) Implement a chorus effect in a real-time embedded system by Gerard Amposta Boquera Advisor: Asunci´onMoreno Bilbao Barcelona, September 2016 \I was left with an urge to make the guitar sound like things it shouldn't be able to sound like." Adrian Belew (1949 - ) Universitat Polit`ecnicade Catalunya (UPC) Abstract Escola T`ecnicaSuperior d'Enginyeria de Telecomunicaci´ode Barcelona (ETSETB) Departament de Teoria del Senyal i Comunicacions by Gerard Amposta Boquera An implementation of a chorus effect in an embedded device has been devised. Some objective and subjective qualities of this implementation have been analyzed, with the purpose of being tested for their adequacy for usage in the music industry. These qualities include, but are not limited to: maximum delay, number of delayed copies of the original signal, waveshape of the signal modulating the delay, dependency of parameters of the modulating signal from parameters from the input signal, adaptability of the architecture to accommodate further effects without increasing significantly resources usage. It is encountered that a scientific approach to this study has either not been taken, or the results of this research are privately held, therefore being adequate to start this research for the public interest. The system has been implemented in a dsPIC33FJ256GP506 digital signal controller using a standard development board, and results show that this is a promising approach that could be industrializable using audio-grade components for the analog stages and a slightly more powerful DSC. Acknowledgements When my family and friends finally managed to overcome my stubbornness and con- vinced me to put it together and write this thesis, I knew what I was heading into was though. What I happily ignored at that moment was how though. This last year has been a challenging tour de force on juggling with my time: time for work, time for the thesis, time for resting, when feasible, and all while trying (and failing) to avoid losing contact with the same family and friends that talked me into writing my thesis. It's been some difficult times, but I also learnt a lot, so I am grateful that I actually did it. None of this would have been possible without the help of a lot of people. First and foremost, I would like to thank my advisor, Asunci´onMoreno, for her time, her patience, her wise advice, her kindness, and specially for stepping up at crucial times, steering the ship in the right direction when it was necessary. For the very same reasons, I would also like to thank Antonio Bonafonte, whose early insights about the project were incredibly helpful. A large share of the gratitude that I owe for being able to finish this thesis is due to the sole person that has been with me every single day during this period: thanks Montse for your kindness, patience, love and understanding. I also need to thank all my family, specially Mom and Dad, for their unconditional support. Is difficult to go through this without your peers comprehension, so is lovely to be able to count upon friends who have gone through the same as you to for some morale boosting. Thanks Marc, Jordi, Marc, V´ıctor,Miquel, Dani, Jes´us,Albert, and all of you guys, for being there during the last 10 years, and for the years to come. Since this is, in the end, about music, I would also like to thank my \road family", for allowing me to skip rehearsals and such. Thanks Manel, Esteve, Josep and Maurici for making me laugh like crazy during that last year every single time we met. Being now a quite experienced engineer, I have had the opportunity to observe in others how determinant is the influence of senior engineers in juniors, and the importance of blossoming in the right environment, and picking the right role models. For this reason, although they have not been linked to this project whatsoever, I would not feel right finishing this acknowledgements section without thanking Sergio Casanova and Oriol Sol`a.I feel fortunate to have had the opportunity to grow up with them both personally and professionally, and I hope I can keep learning from them for the years being. And, well. the little furry dudes can't actually read, but their unparalleled comforting abilities have helped me to keep my sanity during those very stressful times, so thanks Neko and Pam. iii This page is intentionally left blank Contents Abstract ii List of Figures vii List of Tables viii Acronyms ix 1 Introduction1 1.1 Motivation...................................1 1.2 A brief introduction to music effects.....................3 1.2.1 A brief history of music effects....................4 1.2.2 Modulation effects explained.....................5 1.3 State of the art.................................6 1.4 Objectives....................................6 2 Technical description8 2.1 System design..................................8 2.1.1 Features................................. 10 2.2 System description............................... 12 2.3 Modules..................................... 15 2.3.1 Filters.................................. 16 2.3.2 RNG................................... 20 2.3.3 Envelope follower............................ 20 2.3.4 Pitch change detector......................... 21 2.3.5 Oscillators................................ 22 3 Implementation 24 3.1 MCU choice................................... 24 3.2 CPU architecture and peripherals....................... 27 3.3 Module implementation & technical details................. 29 3.3.1 Audio path............................... 29 3.3.2 Trigonometric functions........................ 29 3.3.3 Filters.................................. 30 3.3.4 Oscillators................................ 31 v Contents vi 3.3.5 RNG................................... 33 3.3.6 Envelope follower............................ 34 3.3.7 Pitch change detector......................... 34 4 Results 36 4.1 Results obtained................................ 36 4.1.1 Objective quality............................ 36 4.1.2 Subjective quality........................... 38 4.1.3 Comparison with similar products.................. 39 5 Conclusions and future work 41 5.1 Conclusions................................... 41 5.2 Future work................................... 41 A Project source code 43 B Test subjects demographics 44 Bibliography 46 List of Figures 2.1 Basic chorus architecture...........................9 2.2 Leaky integrator................................ 16 2.3 Low-pass filter frequency response for N = 2, 4, 8 and 16 (dB)...... 17 2.4 High-pass filter................................. 17 2.5 High-pass filter frequency response for N = 2, 4, 8 and 16 (dB)...... 18 2.6 Band-pass resonator.............................. 19 2.7 Band-pass resonator frequency response for fc = 4KHz, 8KHz, 12KHz and 16KHz (dB)................................ 20 2.8 Envelope follower................................ 21 2.9 Pitch change detector............................. 21 3.1 Low-pass and high-pass filter topology.................... 31 4.1 Square wave output signal as received by the oscilloscope (mV)...... 37 4.2 Sinusoidal wave output signal as received by the oscilloscope (mV).... 37 vii List of Tables 2.1 Fixed system parameters............................ 11 2.2 Reconfigurable parameters and their default values............. 12 2.3 Configurable options.............................. 12 2.4 Band-pass filter central frequencies fm(Hz)................. 22 B.1 Subject relationship with music industry................... 44 B.2 Subject primary instrument.......................... 44 B.3 Subject musical education........................... 44 B.4 Subject musical interests............................ 45 viii Acronyms AGC Automatic Gain Compensation. 23 CLT Central Limit Theorem. 33 CPU Central Processing Unit.v,6, 26, 27, 34 DAW Digital Audio Workstation.3 DCI Data Converter Interface. 28, 29 DF1 Direct Form 1. 25, 41 DSC Digital Signal Controller. ii, 29, 30, 41 DSP Digital Signal Processor. 25, 26, 27, 28, 29, 30, 32 FFT Fast Fourier Transform. 25 FIR Finite Impulse Response. 16 FPU Floating Point Unit. 25, 26, 28, 29, 30 HAL Hardware Abstraction Layer.6 HW Hardware. 25, 26, 27, 28, 29, 32, 41 I2C Inter-Integrated Circuit. 28 IDE Integrated Development Environment. 25, 26 IEEE Institute of Electrical and Electronics Engineers. 46 IIR Infinite Impulse Response. 16, 18, 21, 25, 30, 31, 34, 41 LFO Low Frequency Oscillator.5, 10, 11, 13 LPF Low Pass Filter. 20 ix List of Acronyms x LSb Least Significant Bit. 33 LUT Least Significant Bit. 29, 30 MAC Multiply-and-Accumulate. 25, 26, 28 MCU MicroController Unit.v,2, 24, 25, 26, 27, 28, 29, 30, 33, 34 PC Personal Computer. 39 RNG Random Number Generator.v, 11, 13, 15, 19, 33 SIMD Single Instruction, Multiple Data. 26 SW Software. 28, 29, 33, 34 TI Texas Instruments. 26 TRS Tip, Ring, Sleeve. 25, 29 VST Virtual Studio Technology.2,3, 39 Dedicated to Montse, for her support, dedication and patience during this journey. xi Chapter 1 Introduction 1.1 Motivation Short and clear, the motivation for this project is to conjugate my passion for embedded systems programming and digital signal processing with my passion for music. I am myself a regular user of chorus and other effects units. When using them, I often wonder about the design choices taken on their design. Why the range of this parameter is constrained to those values? Why did not they include a low-pass filter in this side-chain? Why there isn't any