Getting Started

A minimal full example that should work:

We first need to import some modules

  1. import sys
  2. # Tell python where to find moreesc (if non-standard path)
  3. sys.path.append('/your/path/to/the/folder/containing/the/moreesc/folder')
  4. # Importing moreesc
  5. import moreesc as mo
  6. mp = mo.Profiles
  7. mac = mo.AcousticResonator
  8. mv = mo.Valve
  9. ms = mo.Simulation
  10. import numpy as np

Then we build the acoustic resonator and the reed objects

  1. # Bore and reed defition
  2. D = mv.ReedDynamics(wr=2*np.pi*1500., qr=0.4, kr=8e8)
  3. 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

  1. # Control parameters
  2. tsim = 1.
  3. S0 = mp.Constant(3e-6)
  4. Pm = mp.SmoothStep([.001, .003, tsim-.2, tsim-.15], 1e3, 1e2)
  5. # 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

  1. # Creating the simulation object
  2. sim = ms.TimeDomainSimulation(D, Ze, pm=Pm, h0=S0,
  3.     fs=44100, piecewise_constant=False)
  4. # changing integrator and solving
  5. sim.set_integrator('vode', nsteps=20000)
  6. sim.integrate(t=tsim)

When calculations were achieved, we can trace the results and save the simulation (in order to continue later).

  1. sim.trace(trace_all=True)
  2. sim.save('test.h5')

Recording the synthetic sound and viewing the signals with:

  1. sim.save_wav('test.wav', where='in')

For more specific help about the features, look for class and functions documentation, for example:

  1. help(sim)