3688ceacymsim: Python port of cymbalsim with a modal linear model and a PyTorch von Karman modelJeremy Magland 1"""The linear model on a 16 inch crash: modes, decay times, a strike, a WAV file and a few plots."""
3import matplotlib.pyplot as plt
5import cymsim
6from cymsim import plot
8plate = cymsim.presets.crash_16().evaluate(spacing=0.008)
9print(plate.summary())
11modes = cymsim.compute_modes(plate, fmax=16000)
12print(f"{modes.count} modes in {modes.seconds:.1f} s")
13print(modes.table(12))
15strike = cymsim.Strike(x=0.9, y=0.5, velocity=3.0)
16listener = cymsim.Listener(distance=0.5, angle=30)
17sound = cymsim.synthesize(modes, strike, listener, duration=4.0, movie=True)
18print(sound, f"peak force {sound.info['peak_force']:.0f} N, contact {sound.info['contact_time'] * 1e3:.2f} ms")
19sound.to_wav("crash_linear.wav")
21fig, axes = plt.subplots(2, 2, figsize=(12, 9))
22plot.plate(plate, ax=axes[0, 0], strike=strike, listener=listener)
23plot.mode(modes, 5, ax=axes[0, 1])
24plot.spectrogram(sound, ax=axes[1, 0], modes=modes, fmax=16000)
25plot.decay_times(modes, ax=axes[1, 1])
26fig.tight_layout()
27fig.savefig("crash_linear.png", dpi=120)
28print("wrote crash_linear.wav and crash_linear.png")