c5866daReimplement the algorithm in MATLAB syntax, run it with numblJeremy Magland 1% Validate against woodblock.py reference diagnostics (its defaults use
2% mallet_stiffness = 3.0e8) and the listener targets in woodblock.md §7.
3% Run with: numbl run woodblock_validate.m
5P = woodblock_defaults();
6P.mallet_stiffness = 3.0e8;
8[y, basis, dinfo] = woodblock_render(P);
9fprintf('reference config:\n');
10fprintf(' contact %.3f ms (target 0.301), peak %.0f N (target 794)\n', ...
11 dinfo.contactMs, dinfo.peakForceN);
12fprintf(' peak %.3f Pa (target 6.132), %.1f dB SPL (target 109.7)\n', ...
13 dinfo.peakPa, dinfo.peakSplDb);
14fprintf(' max real eigenvalue: %.1f (must be < 0)\n', dinfo.maxRealLam);
16targets = [0.15 0.25 0.30 109.7
17 0.00 0.00 0.40 100.9
18 0.00 0.40 0.00 90.9
19 0.00 0.05 0.02 125.4];
20for i = 1:size(targets, 1)
21 Q = P;
22 Q.listener_x_m = targets(i, 1);
23 Q.listener_y_m = targets(i, 2);
24 Q.listener_z_m = targets(i, 3);
25 [~, ~, di] = woodblock_render(Q);
26 err = abs(di.peakSplDb - targets(i, 4));
27 if err < 0.3
28 verdict = 'ok';
29 else
30 verdict = 'MISMATCH';
31 end
32 fprintf('listener (%.2f, %.2f, %.2f): %.1f dB SPL (target %.1f) %s\n', ...
33 targets(i, 1), targets(i, 2), targets(i, 3), di.peakSplDb, targets(i, 4), verdict);
34end