Tumgik
#digital waveguide synthesis
Text
There's something vaguely disconcerting about the knowledge that one can stick a bunch of numbers into a circular buffer, do a little bit of feedback with averaging and it will come out sounding like a plucked string
Tumblr media
Is this cosmic horror?
19 notes · View notes
divorce · 6 months
Text
cool chats
this may not work, but its cool conceptually
Yes, you can use Common Lisp to implement physical modeling synthesis and simulate the sound of a resonating gourd on a rudra veena.
Here are the steps you can follow to simulate the sound of a resonating gourd on a rudra veena using physical modeling synthesis in Common Lisp:
Install the "cl-dsm" library, which is a Common Lisp implementation of the Digital Waveguide Mesh (DWM) physical modeling method.
lisp
(ql:quickload :cl-dsm)
Define the physical parameters of the rudra veena, such as its length, diameter, and material properties. You can adjust these parameters to achieve the desired sound.
lisp
(defparameter *length* 1.5) ; meters (defparameter *diameter* 0.05) ; meters (defparameter *density* 7850) ; kg/m^3 (steel) (defparameter *tension* 500) ; N (approximate) (defparameter *E* 2e11) ; Pa (steel) (defparameter *nu* 0.3) ; Poisson's ratio (steel) (let ((area (* pi (expt (/ *diameter* 2) 2))) (I (* pi 1/4 (expt (/ *diameter* 2) 4))) (c (sqrt (/ *tension* *density* area))) (k (sqrt (/ (* *E* I) (* *density* area (expt *length* 4)))))) (setf *area* area *I* I *c* c *k* k))
In the above code, *length* is the length of the string, *diameter* is its diameter, *density* is its density, *tension* is the tension applied to the string, *E* is the Young's modulus of the material, *nu* is the Poisson's ratio of the material, *area* is the cross-sectional area of the string, *I* is the moment of inertia of the string, *c* is the wave speed, and *k* is the stiffness parameter.
Define the digital waveguide mesh (DWM) of the string using the "cl-dsm" library.
lisp
(defparameter *n-samples* 44100) ; sampling rate (defparameter *duration* 2) ; seconds (let ((ks (dsm:make-karplus-strong *n-samples* *duration*)) (wg (dsm:make-waveguide-mesh))) (dsm:init-waveguide-mesh wg ks (floor (/ *length* *n-samples*)) *k* *c*) wg)
In the above code, *n-samples* is the sampling rate, *duration* is the duration of the string in seconds, ks is a Karplus-Strong string synthesis object that generates an initial excitation for the DWM, and wg is the waveguide mesh object that models the physical behavior of the string.
Add a resonating chamber to the DWM to simulate the resonating gourd.
lisp
(defparameter *chamber-length* 0.3) ; meters (defparameter *chamber-diameter* 0.2) ; meters (let ((chamber-area (* pi (expt (/ *chamber-diameter* 2) 2))) (chamber-volume (* pi (expt (/ chamber-diameter 2) 2) chamber-length)) (rho-air 1.2) ; kg/m^3 (air) (c-air 343) ; m/s (speed of sound in air) (alpha 0.05)) ; absorption coefficient (assumed) (let ((port-length (* 2 (floor (/ (* c-air duration n-samples) (* 2 chamber-length))))) (dsm:add-closed-cylinder wg length area density tension E nu chamber-area chamber-length volume port-length rho-air c-air alpha)))
In the above code, `*chamber-length*` is the length of the resonating chamber, `*chamber-diameter*` is its diameter, `chamber-area` is its cross-sectional area, `volume` is its volume, `rho-air` is the density of air, `c-air` is the speed of sound in air, and `alpha` is the absorption coefficient of the chamber walls. The `add-closed-cylinder` function adds a resonating chamber to the DWM, with a closed end on one side and a port on the other side. The length of the port is calculated based on the speed of sound and the duration of the simulation. 5. Excite the DWM with an impulse and simulate the sound. ```lisp (dsm:excite-waveguide-mesh wg (make-array *n-samples* :element-type 'single-float) :method :impulse) (dsm:run-waveguide-mesh wg) (dsm:get-waveform wg)
In the above code, excite-waveguide-mesh excites the DWM with an impulse, run-waveguide-mesh runs the simulation, and get-waveform retrieves the resulting waveform.
You can play the resulting waveform using the "cl-fad" and "sndfile" libraries to write it to a WAV file and play it back.
lisp
(ql:quickload :cl-fad) (ql:quickload :sndfile) (let ((filename "rudra-veena.wav")) (sndfile:with-sound-file (out filename :mode :output :channels 1 :samplerate *n-samples*) (let ((samples (dsm:get-waveform wg))) (loop for sample across samples do (write-single-float sample out)))))
This code saves the waveform to a WAV file named "rudra-veena.wav" and plays it back. You can adjust the physical parameters of the rudra veena and the resonating chamber to achieve different sounds.
1 note · View note
vias3d · 2 years
Text
CST Studio - Vias3D - 3DEngineering
Tumblr media
SIMULIA offers an advanced simulation product portfolio. It covers simulation disciplines such a structural mechanics, computational fluid dynamics, acoustics, plastic injection molding and electromagnetic field simulation, for a true multiphysics simulation approach.SIMULIA’s realistic simulation solutions accelerate the process of making highly-informed, mission-critical design and engineering decisions before committing to costly and time-consuming physical prototypes.
ELECTROMAGNETIC PRODUCTS
CST STUDIO SUITE
(*) High-performance 3D EM analysis software package for designing, analyzing and optimizing electromagnetic (EM) components and systems.
(*) Electromagnetic field solvers for applications across the EM spectrum are contained within a single user interface.
Coupled simulation: System-level, hybrid, multiphysics, EM/circuit cosimulation.
(*) All-in-one fully parametric design environment.
(*) Import/export wide variety of CAD and EDA files.
(*) Wide range of complex material models.
(*) Complementary tools for Filter Design: Filter Designer 2D (FD2D) and Filter Designer 3D (FD3D).
(*) Powerful post-processing and visualization tools with built-in optimizers.
(*) Common subjects of EM analysis include the performance and efficiency of antennas and filters, EMC/EMI, exposure of the human body to EM fields, electro-mechanical effects in motors and generators, and thermal effects in high-power devices.
ANTENNA MAGUS
(*) Is the most extensive antenna synthesis tool available on the market today.
(*) Its large database of over 350 antennas, transitions and feed structures can be explored to choose the optimal topology.
(*) Validated antenna models can be exported to CST STUDIO SUITE.
(*) Has proven to be an invaluable aid to antenna design engineers and to anyone who requires antenna models for antenna placement and/or electromagnetic interference studies.
SPARK3D
MULTIPACTORAND CORONA ANALYSIS
Spark3D is a unique simulation tool for determining the RF breakdown power level in a wide variety of passive devices, including cavities, waveguides, microstrip and antennas.
(*) Spark3D is a unique simulation tool for determining the RF breakdown power level in a wide variety of passive devices, including cavities, waveguides, microstrip and antennas.
(*) Spark3D is an optional part of CST STUDIO SUITE and is also available as a standalone offering.
(*) Field results from CST STUDIO SUITE simulations can be imported directly into Spark3D to analyze vacuum breakdown (multipactor) and gas discharge.
The main Spark3D features are:
(*) Import the electromagnetic (EM) fields from EM solvers.
(*) Automatic determination of the breakdown power threshold.
(*) Analysis boxes can be defined in order to choose the critical regions to be analyzed.
(*) Real-time output interface with rich simulation data, in table, plot and 3D view forms.
FEST3D
MICROWAVE FILTER DESIGN SOFTWARE
(*) Capable of analyzing complex passive microwave components based on waveguide and coaxial cavity technology.
(*) Fest3D is an optional part of CST STUDIO SUITE and is also available as a stand-alone offering.
Some of the components that can be analyzed with Fest3D are:
(*) Filters (Comb-line, Inter-digital, waffle-iron, dual-mode, bandstop, etc.)
(*) Multiplexers (Diplexers, OMUXs, etc.)
(*) Couplers
(*) Polarizers
(*) OMTs
IDEM
ELECTRONIC DEVICE CHARACTERIZATION
(*) Best-in-class tool for generation of broadband macromodels of linear lumped multi-port structures (via fields, connectors, packages, discontinuities, etc.), known from their input-output port responses.
(*) The raw characterization of the structure can come from measurement or simulation, either in frequency domain or in time domain.
(*) Enables SPICE model extraction and processing for any kind of linear structure, component, interconnect, package, whatever your native characterization and application area.
(*) Is an optional part of CST STUDIO SUITE and is also available as a stand-alone offering.
Contact Us:
16000 Park Ten Place,
Suite 301,
Houston, TX 77084.
Phone: +1 (832) 301-0881
0 notes
coconut2877-blog · 5 years
Text
9/18/19 standing ground
This week I focus on the historical context of physical modeling. 
What has been done? 
What are the similarities and differences among the three commonly used approaches? 
To what extent are people modeling shapes and materials?
How are people simulating resonating bodies?
Am I sure about my own PDE (partial differential equations) formulations?
How to do sanity checks for the sounds I fabricated ?
My reference would be “Digital Sound Synthesis by Physical Modeling Using the Functional Transformation Method” by Lutz Trautman and Rudolf Rabenstein, and Dr. Julius O Smith’s online book “Physical Audio Signal Processing”. The former outlines theoretical proofs and applications of FTM, and the latter focuses on another method developed in CCRMA called DWG (Digital WaveGuide Networks).
How they used to do it
Classically physical modeling is done in roughly 4 ways - FDM (Finite difference method), DWG (Digital waveguide method), MS (model synthesis), and the relatively newer method FTM (functional transformation method), aka my approach(although not exactly as I discovered and would explain later). FDM and DWG are time-based synthesis while MS and FTM are frequency-based approaches. Both FDM and FTM relies on formal physical formulation, while MS and DWG start from analyzing existing recorded sounds. I will briefly describe all the approaches and then point out their limitations and possible combinations.
FDM
FDM starts from solving one or a set of partial differential equations with initial-boundary conditions that describe the given structure’s vibrational mechanism. Then it discretizes any existing temporal and spatial derivatives by Taylor expansion. This approach is straightforward, general, and works with most complex shapes, however tends to neglect higher-order terms. It is possible to improve its accuracy by using smaller discretization, although at the same time it would introduce heavy computations. It is often an offline method, not suitable to be implemented in real-time synthesis. The solution contains time-evolution of all the points on the object in question.
FTM 
FTM shares the same formulation as FDM but solves the equations differently. It eliminates the temporal and spatial derivatives by carrying out two transformations consecutively - Laplace transformation and SLT (Sturm-Liouville transformation). Both transformations turn the entire equation to be expressed in terms of another domain parallel to time-space, from (t,x) to (s,mu). In the alternate domain, derivatives on t and x are transformed to simple-to-solve algebraic equations in terms of s and mu. Afterwards, the solution maybe written in the form of a transfer function multiplying the activation function (derived from whatever force is exerted on the object). This transfer function may be inverted back to time-space domain and a solution would be obtained. The transfer function has its poles and zeros, from which we derive analytical solutions for each frequency partials and their decay rates. This approach is frequency-based in that the final solution is a summation of sinusoidal waves of different modes, with their own decay exponential terms. It accurately simulates the partials resulting from the sounding object however reaches its limitation when it comes to larger modes. It is more computational-friendly than FDM, however limits itself into simpler geometries - most of the time rectangular and circular shapes.
DWG
DWG analyzes a recorded sound and simulate the exact sound with bidirectional delay lines(for simulating traveling waves in both directions), digital filters, and some nonlinear elements. The method is based on Karplus-Strong algorithm and the filter coefficients+impedence of traveling waves are interpolated from the sound. This method is the most efficient but cannot describe a parametrized model. All changes in physical parameters need to be recorded again and be re-interpolated.
MS
MS considers objects as coupled systems of substructures and characterizes each substructure with their own mode/damping coefficient data. It then synthesizes sounds by summing all weighted modes. The modal data is usually obtained by measurements of the object itself rather than deriving from an analytical solution like FTM, and thus MS cannot react to parameter change in the physical model. Furthermore since no analytical solution is derived, MS requires measurements on discretized spatial points and the accuracy here is compromised.
So what do we wanna use
Based on the summary from Trautmann and Rabenstein’s book I extracted:
frequency-based method are generally better than time-based methods due to the frequency-based mechanisms in the human auditory system
for more complicated systems simulations of spatial parameter variations is much easier in the FDM than FTM since eigenvalues can only be calculated numerically in FTM.
FDM is the most general and the most complex synthesizing method. It can handle arbitrary shapes.
FTM is limited to simple spatial shapes like rectangular or circular membranes
DWG is even more limited than FTM or MS. It can only simulate systems accurately having low dispersion due to the use of low-order dispersions.
human ear seems to be more sensitive to the number of simulated partials than to inaccuracies in the partial frequencies and decay times
How my approach is slightly different from FTM
My approach is technically a FTM approach however with slight modifications. FTM first formulates the physical model, perform Laplace and SLT transform, get transfer function, and then derive the impulse response by inverting the transfer function back to time-space domain. My approach follows the same formulation, however only perform the Laplace transform. At this point I would assume the solution to be of sinusoidal form and calculate explicitly what the spatial derivatives are. Due to properties of sinusoidal form, even high order derivatives wouldn’t escape their original forms. After that, I derive the transfer function and would only perform inverse-laplace transform to obtain the impulse response, instead of performing inverse-laplace transform and inverse-SLT transform.
Whether this approach yields utterly different results, why would people go through the trouble of performing SLT spatial transformation, and whether it’s safe to assume the solution be of sinusoidal form is still under investigation. 
What can be done 
FTM+DWG
From FTM we can derive accurate modes and their decay rate coefficients, however it costs computational power to synthesize the actual sound (summation of multitudes of mode, calculation of exponentials, sine operations etc) 
On the other hand from DWG we design filters based on pre-recorded sounds (not flexible to morph between different physical parameters), however very computationally-efficient to synthesize the sounds. 
The book mentions a promising solution of combining the two methods - use accurate modes/decay rate information obtained from FTM to design filters and leave the sound synthesis business to DWG. Next week I will explore further on the combination of these two approaches.
Tumblr media
0 notes