Simulating Modular Acoustic Systems
Given a complex, heterogeneous acoustic system, but absent a closed-form analytic solution to the acoustic wave equation governing its behavior, two natural approaches to modeling it arise: analyze, or decompose the system into smaller modules, or components (for which closed-form analytic solutions to the corresponding wave equations may, or may not, exist); or approximate those solutions numerically that cannot otherwise be solved.
Modular and numerical approaches are themselves naturally synergistic, as numerical approaches work essentially locally (in time or space), and modular setups provide the 'locales', or distributed elements on which numerical simulation can then be carried out. An example of a mathematical and corresponding computational model for a modular framework which leverages numerical methods is presented in [1]. It is a model of acoustic wave propagation for a class of systems comprised of distributed instances of canonical elements of bar and plate type, which are connected using instances of an auxiliary coupling type interaction. The continuous mathematical description is presented in a corresponding discrete form by way of time domain finite difference approximations to the corresponding exact partial differential equations governing acoustic wave propagation. The model is parametric in the set of the acoustic objects, as well as the set of coupling interactions which connect them.
The following documents mainly the results of my attempt to implement a simplified version of the model in [1], as well as contains certain remarks which have followed from contemplation of the general role of such models, what it seems historically to have been, and would seem poised going forward to be in the field of computational acoustics.
It contains: (1) a summary of the model in [1]; (2) a simplified version, with discretization, of the model in [1]; (3) an overview of a corresponding C++ implementation of the simplified model; (4) a demonstration of some audio and visual examples generated using the implementation; (5) some remarks on possible generalizations and directions for future work.
Part 1. Mathematical Model
The mathematical model for continuous vibration of a single plate (I’ll exclusively treat plates in what follows) presented in [1] is the following equation:
\[u_{tt} = -\kappa^2 \Delta \Delta u - 2 \sigma_0 u_{t} + 2 \sigma_{1} \Delta u_{t} + \sum_q E_q F_q\]Here, \(u_{x,y,t}\) represents transverse displacement of the plate; \(\kappa\) is a parameter controlling the plate stiffness, the terms with coefficients \(\sigma_{0}\) and \(\sigma_{1}\) correspond, respectively, to frequency independent, and dependent decay, and the summation is taken over a set q of couplings or external excitations, each of which is localized by a corresponding Dirac delta-type distribution, \(E_{q}\). The operators \(\Delta\) and \(\Delta^2 = \Delta \cdot \Delta\) are the Laplacian and its square, the Biharmonic operator or Bilaplacian, discussion of which both will be deferred until later.
Dirichlet (clamped) boundary conditions of the form
\[u = u_{n} = 0\]are exclusively treated in what follows, but pivoting (Neumann), free, mixed, etc. boundary condition types are also possible.
Connections are encoded as pairs of coupled differential equations, of the form:
\[{u}_{tt}^{(1)}\ = \cdots + F_{c}{E}_{c}^{(1)}\] \[{u}_{tt}^{(2)}\ = \cdots + {F}_{c}^{*} {E}_{c}^{(2)}\]In [1], \(F_{c}\) and \({F}_{c}^{*}\) are related by a nonlinear spring type interaction,
\[F_{c} = -{\omega}_{0}^{2}\eta - {\omega}_{1}^{4}\eta^3 - 2 \sigma \cdot \frac{\partial }{\partial t}\eta\] \[{F}_{c}^{*} = M_{(1/2)} F_{c},\]where \(M_{(1/2)}\) is a constant representing the mass ratio of the two plates. Such a choice of connection element is perhaps attractive for being simple enough to have a tractable semi-implicit solution, yet still nonlinear and so potentially producing of interesting dynamics, and perhaps most importantly, it exhibits a symmetry which will lead to a quantity of the system being conserved.
(However, \(F\) and \(F^*\) need, in principle, not be related symmetrically, nonlinearly, or in any particular way. In the simplified model below, we will take the approach that the flow of interaction across a coupling is directed, and model it simply as a sum of acoustic potential or velocity over the region of contact. Symmetric connections are then recovered as pairs of directed ones.)
A complete system is then comprised of an indexed set of instances of plates and connections between them, where at each time \(t\) inputs flow to the plates from excitations or coupling interactions, and the plates then evolve according to the above equations. The output of the system is then given by the collection of height fields representing transverse displacements, and can be sampled as:
\[y = \left\langle E_{o}, u_{t} \right\rangle\]where the brackets indicate an \(L^2\) inner product. Output may then feed back, through the couplings, into the system as input.
Part 2. Simplified Model and Discrete Formulation
I consider the following simplified form of the above equation for plate vibration:
\[u_{tt} = \alpha \Delta ^2 u - \beta \Delta u_{t} + \sum_q E_q F_q\]with simplified directed connections:
\[{u}_{tt}^{(1)}\ = \cdots\] \[{u}_{tt}^{(2)}\ = \cdots + F_{c} {E}_{c}^{(2)}\]where
\[F_{c} = \sigma \cdot \frac{\partial }{\partial t}\eta ,\]and
\[\eta = \left\langle {u}^{(1)}, {E}_{c}^{(1)} \right\rangle\]is the inner product of the height field \(u\) with the localizing distribution \(E_{c}\).
It is an augmented inhomogeneous acoustic wave equation, in the sense that it combines contributions from the Laplacian and at least one of its powers, as well as a sum of forcing terms, which arise from the simplified, directed (non-conservative) couplings:
This continuous-time model can be discreted using finite differences as follows. A common approximation to the Laplacian, used in [1], is::
\[\delta_{\Delta}{u}_{l,m}^n = \frac{1}{h^2}({u}_{l,m+1}^n + {u}_{l,m-1}^n + {u}_{l+1,m}^n + {u}_{l-1,m}^n - 4{u}_{l,m}^n)\]Where \(h\) is the grid spacing. Applying this formula for all points in the domain corresponds to convolving the function \(u\) with the well-known 5-point stencil. A similar formula for the Bilaplacian, which aggregates values from two rings of neighbors around the central point, is given by convolution with the following 13-point stencil:
Finally, an approximation to the first temporal derivative is given by the backward difference operator:
\[{\delta}_{-}{u}_{l}^{n} = \frac{1}{k}({u}_{l}^{n}-{u}_{l}^{n-1}) ,\]where \(k\) is the sample period, or time-step (and so \(\frac{1}{k}\) the sampling rate).
Part 3. Overview of Implementation
(Note: I developed the C++ implementation for this project prioritizing speed; consequently, I eschewed certain good-practices, such as keeping member variables private or accessible only by getters and setters.)
The above simplified and discrete model was implemented in C++ using a small set of C++ classes and structures. The essential class was Surface, whose .hpp file looked like this:
Surface.hpp
Click to expand
Each surface is simply a square, whose basepoint and global normal vector situate it in \({\mathfrak{R}^3}\). It contains a C++ vector of Vertices, which are very simple structures designed simply to store the all of the values (heights, spatial and temporal first and second derivatives) defined over the Surface; the vertices are indexed by Cartesian coordinates over the surface, so in aggregate they store matrices of each of the above different types of values.
The core of the methods implemented in Surface.cpp (i.e., excluding methods related, e.g., to preparing vertices for rendering in OpenGl) are the following:
Surface.cpp methods
Click to expand
I won’t expound what’s going on above, beyond merely mention that perhaps the subtlest aspect of the above evolution algorithm is getting the order of operations (see the function evolve()) right. If you update values in the wrong order, you may get numerical chaos, or zero response from the system.
The coupling structure is comparatively simple; it simply indexes a pair of surfaces, and identifies points where the interaction is to take place:
Coupling.hpp
Click to expand
Everything is then tied together in Main, where graphics run in a separate thread to the audio and numerical simulation. On a 2-core, 2015 Macbook Pro, with three Surfaces of sizes 100x100, 80x80, and 60x60 (see GIF) and three couplings, the system audio rate was between 3-400 fps.
Part 4. Examples
Below is an example of a modular system that was simulated using the implementation. The graphics appear fine at 60 Hz, but for the audio, a sample rate of 3-400 Hz is barely enough to resolve any frequency above the lower limit of what is audible to human hearing. In an attempt to reveal some information about the system through its audio output, I’ve sped-up the audio samples which follow – which were sampled from the centers of the middle, and bottom plates, respectively, and were initially ~two minutes long each – by a factor of 60 and looped them a few times. The result is low rumbles, each somehow a (very noisy) filter of the input signal coming from the top plate, which is evolving by the Bilaplacian.
The expense of numerically simulating 2- and higher dimensional wave equations unfortunately precludes one from obtaining sound results of any interest, if one is running their experiments, as I did, on standard hardware like a phone or laptop in 2020. However, as demonstrated by the investigations documented in [2], and by the NESS Project [3], real-time simulation of 2- and 3- dimensional acoustic systems is possible using parallelization and hardware acceleration. In fact, the statement that such real-time results are possible is banal on a conceptual level, since the actions of the operators involved in the wave equations are all local and ‘embarrassingly-parallel’. I.e., improvement in the execution time of an algorithm to compute acoustic wave equations, of the form described above, by addition of further processing units will increase essentially linearly, according to Amdahl’s Law. However, constructing actual examples of such real-time systems, in practice, is another matter.
Part 5. Closing Remarks: Generalizations and Future Work
The power of a modular approach such as the one in [1] comes from its ability to decompose certain complex systems into, or synthesize them from, sets of canonical elements for which localized solutions to governing equations exist, and are tractable. For any such modeling framework, the class of complex systems that can be approximately analyzed or synthesized within the framework will depend upon the set of canonical elements, and different ways of connecting, or composing instances of those elements together. For the model in [1], the class of approximable systems corresponds precisely to all combinations of rectangular plates (and bars) connected via the defined type of coupling interaction. Such a characterization of the space of models possible within a given modular framework then raises the obvious question - by generalizing or refining the set of canonical elements and couplings, can the space of approximable systems within the framework correspondingly be expanded or refined?
In the case of the model from [1], perhaps the most obvious such approach to varying the underlying set of elements is to replace the notion of bar and plate with the more general mathematical one of manifold – a shape which looks essentially the same, locally, everywhere – or hypersurface (manifold of dimension \(N-1\) embedded in an ambient space of dimension \(N\)). Substituting such a more general notion of shape then correspondingly requires providing a modified scheme for numerically simulating acoustic wave propagation over the domain which that shape parameterizes. In the case of at least a surface (understood as a manifold) which admits a triangulation, this can be achieved by replacing the expression of the Laplacian given in Cartesian coordinates with a more general formulation (see [6] for details), known as the Cotangent Laplacian:
\[(\Delta u)_{i} := \frac{1}{2}\sum_{ij}(cot(\alpha_{ij}) + cot (\beta_{ij}))(u_{j} - u{i})\]where the \(u_{j}\) are neighbors of the central vertex \(u_{i}\):
Further generalizations are certainly possible - for example, to situations in which the underlying geometry is not static, but dynamic, and somehow coupled, itself, to the functions which are defined upon it. This is the case, e.g., in so-called adaptive finite element methods, and can be instrumental in minimizing noise due to, e.g., anistropy.
Lastly, the corresponding notion of connection between elements also must be changed once that of the underlying elements is, and when the prototypical notion of shape becomes that of a manifold, that of connection must be adapted somehow to involve the notion of a map or attachment between manifolds.
References
[1] A Modular Percussion Synthesis Environment; Bilbao (2009)
[2] On the Limits of Real-Time Physical Modeling Synthesis with a Modular Environment; Webb, Bilbao (2015)
[3] NESS Project, https://www.ness.music.ed.ac.uk/archives/systems/modular-environments
[4] Finite Difference Schemes in Musical Acoustics: A Tutorial; Bilbao, Hamilton, Harrison, Torin (2018)
[5] “We’ve had Laplacian, yes. What about Bilaplacian?”; Stein (2020)
[6] Laplace-Beltrami:The Swiss Army Knife of Geometry Processing; Crane, Solomon, Vouga (2014)