Simplified, Physically-Informed Models of Distortion and Overdrive Guitar Effects Pedals
Total Page:16
File Type:pdf, Size:1020Kb
Proc. of the 10th Int. Conference on Digital Audio Effects (DAFx-07), Bordeaux, France, September 10-15, 2007 SIMPLIFIED, PHYSICALLY-INFORMED MODELS OF DISTORTION AND OVERDRIVE GUITAR EFFECTS PEDALS David T. Yeh, Jonathan S. Abel and Julius O. Smith Center for Computer Research in Music and Acoustics (CCRMA) Stanford University, Stanford, CA [dtyeh|abel|jos]@ccrma.stanford.edu ABSTRACT retained, however, because intermodulation due to mixing of sub- sonic components with audio frequency components is noticeable This paper explores a computationally efficient, physically in- in the audio band. formed approach to design algorithms for emulating guitar distor- tion circuits. Two iconic effects pedals are studied: the “Distor- Stages are partitioned at points in the circuit where an active tion” pedal and the “Tube Screamer” or “Overdrive” pedal. The element with low source impedance drives a high impedance load. primary distortion mechanism in both pedals is a diode clipper This approximation is also made with less accuracy where passive with an embedded low-pass filter, and is shown to follow a non- components feed into loads with higher impedance. Neglecting linear ordinary differential equation whose solution is computa- the interaction between the stages introduces magnitude error by a tionally expensive for real-time use. In the proposed method, a scalar factor and neglects higher order terms in the transfer func- simplified model, comprising the cascade of a conditioning filter, tion that are usually small in the audio band. memoryless nonlinearity and equalization filter, is chosen for its The nonlinearity may be evaluated as a nonlinear ordinary dif- computationally efficient, numerically robust properties. Often, ferential equation (ODE) using numerical techniques [7, 8]. How- the design of distortion algorithms involves tuning the parameters ever, the solution of nonlinear ODEs is computationally intensive, of this filter-distortion-filter model by ear to match the sound of and the differences are subtle. Therefore in this work, the nonlin- a prototype circuit. Here, the filter transfer functions and memo- earity is approximated by a static nonlinearity and tabulated. This ryless nonlinearities are derived by analysis of the prototype cir- can be justified on perceptual grounds. cuit. Comparisons of the resulting algorithms to actual pedals It is well known that nonlinearities cause an expansion of band- show good agreement and demonstrate that the efficient algorithms width that may lead to aliasing if the sampling rate is insufficiently presented reproduce the general character of the modeled pedals. high [3]. Consequently typical digital implementations of distor- tion upsample by a factor of eight or ten, process the nonlineari- 1. INTRODUCTION ties, and downsample back to typical audio rates[3, 9]. Frequency content tends to roll off with increasing frequency, and remaining Guitarists tend to feel that digital implementations of distortion aliases at oversampling factors of eight or above tend to be masked effects sound inferior to the original analog gear. This work at- by the dense spectrum of guitar distortion. tempts to provide a more accurate simulation of guitar distortion Because the filters in this work are derived from analog pro- and a physics based method for designing the algorithm according totypes, upsampling also increases the audio band accuracy of to the virtual analog approach[1, 2]. the discretization by bilinear transform. An alternate approach Often guitar effects are digitized from a high level understand- would be to design low order filters so that the response at Nyquist ing of the function of the effect [3, 4]. This work describes the matches the continuous time transfer function [10, 11]. results of a more detailed, physical approach to model guitar dis- The following is an analysis of the stages in two typical dis- tortion. This approach has been adopted previously in the context tortion pedals. of generating tube-like guitar distortion [5], not to model a specific effect as done here. This approach starts with the equations that de- scribe the physics of the circuit and is an alternative to obtaining the static transfer curves of a nonlinear system by measurement 2. FUNDAMENTAL TOOLS [6]. Many digital distortion pedals feature pre- and post-distortion filters surrounding a saturating nonlinearity. The filters are com- 2.1. SPICE simulation monly multiband (three or four bands) parametric filters that are tuned to taste. For circuits that are difficult to analyze, SPICE simulation pro- An analysis of the circuits shows that analog solid-state cir- vides detailed numerical analysis. DC analysis in SPICE performs cuits tend to use low-order filters. To keep costs down, circuits static sweeps of voltage or current sources to measure memory- are designed with minimal component count, which limits filter less transfer curves. AC analysis finds the frequency response of order. For the purpose of distortion effect modeling, the frequency a circuit linearized about an operating point. These responses can range of interest is from just above DC to 20 kHz. Features in the be imported into Matlab and converted to digital filters as in [1]. frequency domain above 20 kHz can be ignored, also contribut- SPICE also serves as a reference solver for numerical solutions of ing to low-order filters. Frequency features below 20 Hz must be the time domain response for nonlinear ODEs. DAFX-1 Proc. of the 10th Int. Conference on Digital Audio Effects (DAFx-07), Bordeaux, France, September 10-15, 2007 bjt buf Gain + filter Vi + Vo in out − 9V 4.5V bjt buf Saturating nonlin Tone filter "Distortion" effect Zf pwr supply Vo Zs+Zf Zs Figure 2: Block diagram of Distortion pedal. Vi= Zs it in the form shown in (1) allows the poles and zeros to be seen more easily: Figure 1: Non-inverting op amp gain Zf Zs Av(s)= + 1 (1) Zs Zf 2.2. Continuous time pole-zero analysis 2.4. Bilinear Transform of low order transfer functions Linear circuits are described by rational transfer functions. For Once a continuous time transfer function is obtained either by anal- most low-cost audio circuits such as guitar effects, the transfer ysis or by inspection of the magnitude response, the bilinear trans- functions are typically low order. The poles and zeros can be iden- form can be used to digitize this filter. First- and second-order tified on a log-frequency plot of magnitude in dB. In dB, it can continuous time systems are common, so their mappings are given be seen that the magnitude contributions of poles subtract and the below. magnitude contributions of zeros add. For the low pass filter, at The continuous time system, the pole frequency, the magnitude is 3 dB lower than at its low frequency asymptote. For the high pass filter, the magnitude at n bns + ... + b1s + b0 the pole frequency is 3 dB lower that at its high frequency asymp- H(s)= , (2) a sn + ... + a1s + a0 tote. Therefore, well separated pole and zero frequencies can be n identified from the decibel magnitude response by looking for the results in 3-dB points. These frequencies can then be used to reconstruct the −1 −n B0 + B1z + ... + B z rational expression for the transfer function. n (3) H(z)= −1 −n , A0 + A1z + ... + Anz 2.3. Analysis of operational amplifier circuits where for a second order system, coefficients of H(z) are 2 Transfer functions can be easily found analytically for circuits with B0 = b0 + b1c + b2c , (4) operational amplifiers (op amps). 2 B1 = 2b0 − 2b2c , (5) 2 B2 = b0 − b1c + b2c , (6) 2.3.1. Ideal op amp approximation 2 A0 = a0 + a1c + a2c , (7) The ideal op amp approximation states that if negative feedback is 2 present, A1 = 2a0 − 2a2c , (8) 2 A2 = a0 − a1c + a2c , (9) 1. V+ = V−, 2. I+ = I− = 0 and for a first-order system, coefficients of H(z) are − where V+ is the voltage at the + terminal of the op amp and V , B0 = b0 + b1c, (10) the voltage at the − terminal. I+ and I− are the currents flowing B1 = b0 − b1c, (11) into the two terminals. These conditions do not hold if negative feedback is not present, for example, if Vo is not connected to V− A0 = a0 + a1c, (12) or if the op amp output is close to the supply voltages, causing it A1 = a0 − a1c. (13) to clip. (14) 2.3.2. Non-inverting configuration Here c = 2/T is chosen as typical for the bilinear transform. An example of this analysis is done for the non-inverting op amp 3. CIRCUIT ANALYSIS OF DISTORTION PEDAL configuration shown in Fig. 1. The ideal op amp rule gives V− = Vi, so the current through Zs is Is = Vi/Zs. Because I− = 0, The block diagram of the Boss DS-1 Distortion pedal [12] is shown all the current flows across Zf , so V0 = Vi + IsZf = Vi + in Fig. 2. It is basically gain with a saturating nonlinearity sand- Vi/Zs. After algebraic manipulation, the transfer function is found wiched between filters. However, distortion from the bipolar tran- + to be Vo = Zs Zf . This results in a continuous time transfer Vi Zs sistor (BJT) emitter follower buffers and first gain stage are not function if complex impedances are used for Zf and Zs. Writing negligible. DAFX-2 Proc. of the 10th Int. Conference on Digital Audio Effects (DAFx-07), Bordeaux, France, September 10-15, 2007 Frequency response at opamp input 9V 40 4.5V 30 R2 4.5V 4.5V 470k R4 R5 20 R1 C1 Q1 100k 1M C2 C3 10 1k 0.047u 0 0.47u 0.047u R3 10k −10 Q1: 2SC732TM −20 Magnitude response (dB) −30 Figure 3: Input buffer: Emitter follower circuit. −40 0 2 4 6 10 10 10 10 9V Frequency (Hz) 10k Figure 5: Frequency response of BJT stage 250p The bilinear transform applied to with a sampling rate 470k gainout H(s) fs = 44.1 kHz gives a second order digital filter whose coeffi- 0.047u gainin Q2 cients can be found using (9).