/ simulated_instruments / recorder
Sign in
simulated_instruments / recorder
recorder / matlab / recorder_demo.m
28 lines · 1.1 KBBlameHistoryRaw
1% Render a recorder note with default parameters and print diagnostics.
2% Set P.note_count = 3 for a three-note figure; P.note1..note3 pick the
3% fingerings (1 = C5 ... 10 = D6, 11..14 = pinched E6, F6, G6, A6).
4% Run with: numbl run recorder_demo.m
6P = recorder_defaults();
7tic;
8[y, basis, dinfo] = recorder_render(P);
9elapsed = toc;
11fprintf('bore modes : %d resonances, first at %.1f Hz (Q %.0f)\n', basis.n, basis.f(1), basis.Q(1));
12fprintf('notes : %d\n', dinfo.noteCount);
13for i = 1:dinfo.noteCount
14 fprintf(' note %d : fingering %d, played %.1f Hz (target %.1f, %+.1f cents)\n', ...
15 i, dinfo.noteIdx(i), dinfo.fPlay(i), 523.25 * 2^((dz_semi(dinfo.noteIdx(i))) / 12), dinfo.cents(i));
16end
17fprintf('peak press.: %.4f Pa (%.1f dB SPL) at %.0f cm\n', ...
18 dinfo.peakPa, dinfo.peakSplDb, dinfo.listenerDistM * 100);
19fprintf('length : %.2f s @ %d Hz\n', length(y) / P.sample_rate, P.sample_rate);
20fprintf('render time: %.2f s\n', elapsed);
21if dinfo.listenerInside
22 fprintf('WARNING : listener is at or inside the instrument\n');
23end
25function s = dz_semi(note)
26semis = [0 2 4 5 7 9 11 12 13 14 16 17 19 21];
27s = semis(note);
28end
↑↓ move↵openescclose