/ proof-of-concept / plate-dynamics-lab-2
Sign in
proof-of-concept / plate-dynamics-lab-2
plate-dynamics-lab-2 / packages / core / src / m / plate_rr_strike.m
45 lines · 1.8 KBBlameHistoryRaw
1function result = plate_rr_strike(params, M)
2% PLATE_RR_STRIKE Strike the Rayleigh-Ritz modes and render the result.
3%
4% result = plate_rr_strike(params, M) takes the modes of plate_rr_modes,
5% evaluates the basis at the strike point and the probe (the hit
6% participation of each mode is its mass-normalized shape there), sets the
7% modal damping (plate_damping), applies the prescribed Hertz pulse
8% (plate_rr_contact) and synthesizes the sound, the series and the frames
9% (plate_synthesize). Only this function needs to run again when the
10% hammer, the strike point, the microphone or the render settings change.
12t_start = tic;
13if ~strcmp(M.method, 'rr')
14 error('plate_rr_strike: the modes were computed by another method (%s)', M.method);
15end
16P = plate_setup(params);
17pl = params.plate;
18if abs(params.strike.x) > pl.width / 2 || abs(params.strike.y) > pl.height / 2
19 error('plate_rr_strike: the strike point is outside the plate');
20end
21if abs(params.probe.x) > pl.width / 2 || abs(params.probe.y) > pl.height / 2
22 error('plate_rr_strike: the probe is outside the plate');
23end
25hit = plate_rr_basis(params.strike.x, params.strike.y, M.order, pl.width, pl.height);
26phi_hit = (M.vecs' * hit)';
27[zeta, Q] = plate_damping(M.freqs, M.support_part, params, P);
29fs = params.render.fs;
30na = round(params.render.duration * fs);
31t = (0:na - 1) / fs;
32C = plate_rr_contact(params, P, M.freqs, zeta, phi_hit, t);
34[bp, bxx, byy, bxy] = plate_rr_basis(params.probe.x, params.probe.y, M.order, pl.width, pl.height);
35D.zeta = zeta;
36D.Q = Q;
37D.phi_hit = phi_hit;
38D.phi_probe = (M.vecs' * bp)';
39D.kxx_probe = (M.vecs' * bxx)';
40D.kyy_probe = (M.vecs' * byy)';
41D.kxy_probe = (M.vecs' * bxy)';
43result = plate_synthesize(params, P, M, C, D);
44result.info.strike_wall_s = toc(t_start);
45end
↑↓ move↵openescclose