/ simulated_instruments / maraca
Sign in
simulated_instruments / maraca
maraca / matlab / maraca_demo.m
26 lines · 1.1 KBCodeBlameHistory
aa03146Maraca shake simulator: MATLAB model and interactive web appmagland 1% Render a maraca shake with default parameters and print diagnostics.
2% Run with: numbl run maraca_demo.m
4P = maraca_defaults();
5tic;
6[y, basis, dinfo] = maraca_render(P);
7elapsed = toc;
9fprintf('modes kept : %d\n', basis.n);
10fprintf('mode l : ');
11fprintf('%d ', basis.l);
12fprintf('\nmode freq : ');
13fprintf('%.0f ', basis.f);
14fprintf('Hz\n');
15fprintf('breathing : %.0f Hz (dry %.0f Hz, cavity shift %+.1f Hz)\n', ...
16 dinfo.breathingHz, dinfo.breathingDryHz, dinfo.breathingHz - dinfo.breathingDryHz);
17fprintf('grains : %d, %.2f bounces each per stroke\n', P.grain_count, P.bounces_per_grain);
18fprintf('impacts : %d (mean v %.2f m/s, max %.2f; mean contact %.0f us)\n', ...
19 dinfo.impactCount, dinfo.meanV, dinfo.maxV, dinfo.meanTauUs);
20fprintf('peak press.: %.3f Pa (%.1f dB SPL) at %.0f cm\n', ...
21 dinfo.peakPa, dinfo.peakSplDb, dinfo.listenerDistM * 100);
22fprintf('length : %.2f s @ %d Hz\n', length(y) / P.sample_rate, P.sample_rate);
23fprintf('render time: %.2f s\n', elapsed);
24if dinfo.listenerInside
25 fprintf('WARNING : listener is inside/at the shell surface\n');
26end
↑↓ move↵openescclose