Proc. of the 10 th Int. Conference on Digital Audio Effects (DAFx-07), Bordeaux, France, September 10-15, 2007 SIMULATION OF THE DIODE LIMITER IN GUITAR DISTORTION CIRCUITS BY NUMERICAL SOLUTION OF ORDINARY DIFFERENTIAL EQUATIONS David T. Yeh, Jonathan 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 The diode clipper circuit with an embedded low-pass filter lies at the heart of both diode clipping “Distortion” and “Overdrive” or “Tube Screamer” effects pedals. An accurate simulation of this cir- cuit requires the solution of a nonlinear ordinary differential equa- tion (ODE). Numerical methods with stiff stability – Backward Euler, Trapezoidal Rule, and second-order Backward Difference Formula – allow the use of relatively low sampling rates at the cost of accuracy and aliasing. However, these methods require iteration at each time step to solve a nonlinear equation, and the tradeoff for this complexity must be evaluated against simple explicit meth- ods such as Forward Euler and fourth order Runge-Kutta, which require very high sampling rates for stability. This paper surveys and compares the basic ODE solvers as they apply to simulating circuits for audio processing. These methods are compared to a static nonlinearity with a pre-filter. It is found that implicit or semi- implicit solvers are preferred and that the filter/static nonlinearity approximation is often perceptually adequate. 1. INTRODUCTION Guitarists tend to feel that digital implementations of distortion effects sound inferior to the original analog gear. This work at- tempts to provide a more accurate simulation of guitar distortion and a physics-based method for designing the algorithm in the same manner physical modeling is done for acoustic instruments. Guitar effects consists of circuits that are accurately described in the audio frequency band by nonlinear ordinary differential equa- tions (ODEs). Often the circuits are comprised of linear stages that can be efficiently implemented by infinite impulse response (IIR) digital filters. The remaining nonlinear ODEs may need to be solved by a numerical method or other approximation. The diode clipper circuit with an embedded low-pass filter forms the basis of both diode clipping “Distortion” and “Over- drive” or “Tube Screamer” effects pedals[1]. An accurate simu- lation of this circuit requires the solution of a nonlinear ordinary differential equation (ODE). Numerical methods with stiff stabil- ity, Backward Euler, Trapezoidal Rule, and second order Back- ward Difference Formula (BDF, also called Gear) allow the use of low sampling rates at the cost of accuracy and aliasing[2]. How- ever, these methods require iteration at each time step to solve a nonlinear equation, and the tradeoff for this complexity must be evaluated against simple explicit methods such as Forward Euler and fourth-order Runge-Kutta, which require very high sampling rates for stability. 1.1. Related work A nonlinear system can be represented analytically as a Volterra series. There has been work to form finite-order Volterra series for simulating electronics [3, 4]. However, these are interesting only for low order, whereas for highly nonlinear systems, direct simu- lation by numerical methods is more computationally efficient [5]. Numerical solution of ODEs is a very mature topic in applied mathematics and many sophisticated algorithms exist for improv- ing accuracy and speed [2, 6, 7, 8]. Backward Euler, Trapezoidal Rule, and BDF (called Gear in SPICE) are options to solve the nonlinear ODEs in circuits [9, 10]. Most algorithms are designed with a variable step size (sampling rate) to maintain a specified ac- curacy. The error is typically specified in the time-domain and is related to an order of the step size. Matlab features a rich suite of ODE solvers [11] that can be used for experimentation and gaining experience with the solution of ODEs. Although not presented as such, an example of numerical sim- ulation of ODEs for musical application is [12]. The WDF is an alternate implementation of the trapezoidal rule. It is equivalent to trapezoidal rule integration and results in the same iterations being solved because the nonlinearity is expressed in K-variables. 1 1.2. Error criterion Most applications for ODE solvers have a different set of require- ments than those for audio. The error criterion for general solvers adaptively adjusts the step size to an excessively small value. A fixed sampling rate is better suited for implementation in real-time audio processing. In addition, borrowing from the field of perceptual audio coding [13], the error specification for audio is best defined perceptually in the short-time frequency domain. For audio, using a larger step size to reduce computational costs may increase aliasing, but this is tolerable if below the mask- ing threshold of the desired audio signal. Also, the original analog electronics have a relatively high noise floor which would mask low level aliasing. In this paper, the audio band is defined to be 0–20 kHz, where a match to the accurate solution of the ODE is desired. Subsonic frequencies are included because they may mix through the nonlin- earity and cause perceptible amplitude modulation of the output. High frequencies are assumed to be sufficiently low due to roll-off of typical spectra that mixing products are negligible. 1 The term “K-variable” means “Kirchoff variable,” such as a voltage or current. In contrast, WDFs use “W-variables” (“wave variables”). K- variables can be converted to W-variables and vice versa by means of a two-by-two matrix multiply as in (8). DAFX-1