## 3 Generation of Equations
### Realizability Analysis
#### 3.2.2 Algorithm
The magnitudes of transfer functions obtained from fast Fourier transform are given in Figure 8 for the two extreme positions of the pedal. These results are in accordance with LT-Spice. Secondly, a VST plugin [43] to simulate the Cry-Baby in real-time is made from Algorithm 2. First, a C++ code is automatically generated; Second, this code is encapsulated in a Juce template to compile the audio plugin (see [44]). The sample rate \(f_{\mathrm{s}}\) is imposed by the host digital audio workstation (here Ableton Live! ), and we force five Newton-Raphson iterations. The simulation performed well

Figure 8: Simulations of the Cry-Baby’s circuit of Figure 9, for the potentiometer parameter \(\alpha=0\) (\(\mathbf{a}\)) and \(\alpha=1\) (\(\mathbf{b}\)) in the frequency domain, compared with LT-Spice simulations on the audio range 20 Hz-20 kHz. Figure 9: Schematic of the Cry-Baby wah pedal. Note the IN/OUT terminals and the 9 V supply. The potentiometer P controls the effect. (audio examples are available at the url [45]). The CPU load on a laptop (Macbook 2.9 GHz Intel Core i7 with 8 Go RAM) is 37% for \(f_{\mathrm{s}}=96\) kHz, and 20% for \(f_{\mathrm{s}}=48\) kHz. **Remark 6** (Time-varying stability): _The use of the Newton-Raphson method can hamper the stability of the numerical solution for time-varying systems, especially in the case of fast variations (here, of the potentiometer) for which the Jacobian matrix of the implicit Function (28) can be ill-conditioned. For linear storage components, a solution is to use the K-method instead (see Remark 5)._

## 6 Conclusions

We have established a method to automatically recast an analog audio circuit into PHS formalism, which guarantees passivity of the continuous time model. The generation of the PHS from a given schematic lies on two points:

1. the graph theory to describe the interconnection network of a given circuit's schematic,
2. a dictionary of elementary components which are conformable with PHS formalism. Then, we transposed this physical principle to the digital domain by properly defining the discrete gradient of the Hamiltonian, such that a discrete time version of the power balance is satisfied. The resulting stable numerical scheme is of second order (restoring the midpoint rule for linear systems). It has been shown that the K-method is always applicable to PHS (providing efficient implementations of the implicit relation due to the proposed numerical scheme). Offline simulations are consistent with LT-Spice results. The whole method allows the automatic generation of C++ simulation code to be used in the core of a real-time VST audio plug-insimulating the Dunlop Cry-Baby wah pedal. A first perspective on this work is to consider higher-order numerical schemes (namely, the class of Runge-Kutta schemes). Moreover, it would be possible to symmetrize the roles of the voltages and the currents at the interconnection by applying the _Cayley transform_ to the PHS structure, thus adopting _wave variables_, with possible connection with the WDF formalism. Additionally, an automated analysis of the original schematic could be developed, so as to identify the unimportant or degenerate states and to reduce the dimensionality of the system. Finally, it could be possible to exploit the compatibility of the proposed method with the K-method to alleviate the numerical cost due to Newton-Raphson iterations. The authors acknowledge the members of the french National Research Agency project HaMecMoPSys for support in port-Hamiltonian theory. Also, the authors acknowledge [PERSON] and [PERSON] for careful proofreading. The scientific work has been achieved by both authors at IRCAM Laboratory, Paris, within the context of the French National Research Agency sponsored project HaMecMoPSys. Further information is available at [[http://www.hamecmopsys.ens2m.fr](http://www.hamecmopsys.ens2m.fr)]([http://www.hamecmopsys.ens2m.fr](http://www.hamecmopsys.ens2m.fr)). The numerical experiments have been performed by [PERSON]. The authors declare no conflict of interest.