Getting Started
A minimal full example that should work:We first need to import some modules
- import sys
- # Tell python where to find moreesc (if non-standard path)
- sys.path.append('/your/path/to/the/folder/containing/the/moreesc/folder')
- # Importing moreesc
- import moreesc as mo
- mp = mo.Profiles
- mac = mo.AcousticResonator
- mv = mo.Valve
- ms = mo.Simulation
- import numpy as np
Then we build the acoustic resonator and the reed objects
- # Bore and reed defition
- D = mv.ReedDynamics(wr=2*np.pi*1500., qr=0.4, kr=8e8)
- Ze = mac.Cylinder(L=.5, r=7e-3, radiates=False, nbmodes=10)
Time-varying mouth pressure (with silence, attack, sustain and decay) and constant lip stress on the reed are defined with the Profil class
- # Control parameters
- tsim = 1.
- S0 = mp.Constant(3e-6)
- Pm = mp.SmoothStep([.001, .003, tsim-.2, tsim-.15], 1e3, 1e2)
- # 2ms attack starting at 1ms, almost .8s sustain, 50ms decay
Finally, the TimeDomainSimulation instance is created, and it can compute the auto-oscillations of the combination of the resonator and of the reed for such control parameters
- # Creating the simulation object
- sim = ms.TimeDomainSimulation(D, Ze, pm=Pm, h0=S0,
- fs=44100, piecewise_constant=False)
- # changing integrator and solving
- sim.set_integrator('vode', nsteps=20000)
- sim.integrate(t=tsim)
When calculations were achieved, we can trace the results and save the simulation (in order to continue later).
- sim.trace(trace_all=True)
- sim.save('test.h5')
Recording the synthetic sound and viewing the signals with:
- sim.save_wav('test.wav', where='in')
For more specific help about the features, look for class and functions documentation, for example:
- help(sim)