/ simulated_instruments / maraca
Sign in
simulated_instruments / maraca
Pitch support by geometric scaling in the exported driver
MIDI pitch scales every structural length by 2^-((pitch - ref)/12), so the modal spectrum shifts by the semitone ratio exactly (bending modes go as thickness / length^2; the woodblock's cavity scales consistently). The exciter stays fixed. The default geometry sits at the reference note with a two-octave playable range around it.
Jeremy Magland <jmagland@flatironinstitute.org> committed commit be4a90d24ad0 parent 3680208 Browse files
3 changed files+29−8
export-src/maraca/export.jsonmodified+16−3View file
@@ -1,10 +1,23 @@
11 {
22 "id": "maraca",
33 "name": "Maraca",
4- "description": "One maraca stroke per MIDI event; unpitched, velocity onto shake speed.",
4+ "description": "One maraca stroke per MIDI event; pitch scales the gourd around MIDI 60 (48..72), velocity onto shake speed.",
55 "source": "simulated_instruments/maraca",
66 "knobs": [
7- { "key": "grain_count", "label": "grain count", "min": 40, "max": 600, "default": 320, "step": 1 },
8- { "key": "burst_width_ms", "label": "burst width (ms)", "min": 5, "max": 120, "default": 45 }
7+ {
8+ "key": "grain_count",
9+ "label": "grain count",
10+ "min": 40,
11+ "max": 600,
12+ "default": 320,
13+ "step": 1
14+ },
15+ {
16+ "key": "burst_width_ms",
17+ "label": "burst width (ms)",
18+ "min": 5,
19+ "max": 120,
20+ "default": 45
21+ }
922 ]
1023 }
export-src/maraca/render_note.mmodified+11−3View file
@@ -1,7 +1,12 @@
11 function y = render_note(note)
2-% Unpitched: MIDI pitch is ignored, velocity drives the stroke speed.
3-% Fixed: a single stroke, a fixed seed, normalize off so velocity
4-% survives in pascals.
2+% MIDI pitch scales the gourd: shell radius and thickness by
3+% s = 2^-((pitch - 60)/12), shifting the shell modes and the cavity
4+% resonance by the semitone ratio while the seed beads stay the same
5+% size, so higher notes are smaller, brighter shakers. Pitch 60 is the
6+% default gourd, playable 48..72; the sound is noise-based, so the note
7+% number sets register rather than a tuned fundamental. Velocity drives
8+% the stroke speed. Fixed: a single stroke, a fixed seed, normalize off
9+% so velocity survives in pascals.
510 P = maraca_defaults();
611 P.sample_rate = note.sample_rate;
712 P.stroke_count = 1;
@@ -11,6 +16,9 @@ P.normalize = 0;
1116 if note.preview ~= 0
1217 P.oversample = 1;
1318 end
19+s = 2 ^ (-(max(48, min(72, note.pitch)) - 60) / 12);
20+P.shell_radius_m = P.shell_radius_m * s;
21+P.shell_thickness_m = P.shell_thickness_m * s;
1422 P.shake_velocity = 0.2 + (6 - 0.2) * note.velocity;
1523 P.grain_count = round(note.params.grain_count);
1624 P.burst_width_ms = note.params.burst_width_ms;
exports/maraca.jsonmodified+2−2View file
@@ -2,7 +2,7 @@
22 "format": "numbl-instrument-v1",
33 "id": "maraca",
44 "name": "Maraca",
5- "description": "One maraca stroke per MIDI event; unpitched, velocity onto shake speed.",
5+ "description": "One maraca stroke per MIDI event; pitch scales the gourd around MIDI 60 (48..72), velocity onto shake speed.",
66 "source": "simulated_instruments/maraca",
77 "knobs": [
88 {
@@ -24,7 +24,7 @@
2424 "files": [
2525 {
2626 "name": "render_note.m",
27- "content": "function y = render_note(note)\n% Unpitched: MIDI pitch is ignored, velocity drives the stroke speed.\n% Fixed: a single stroke, a fixed seed, normalize off so velocity\n% survives in pascals.\nP = maraca_defaults();\nP.sample_rate = note.sample_rate;\nP.stroke_count = 1;\nP.seed = 1;\nP.pre_delay_ms = 0;\nP.normalize = 0;\nif note.preview ~= 0\n P.oversample = 1;\nend\nP.shake_velocity = 0.2 + (6 - 0.2) * note.velocity;\nP.grain_count = round(note.params.grain_count);\nP.burst_width_ms = note.params.burst_width_ms;\ny = maraca_render(P);\nend\n"
27+ "content": "function y = render_note(note)\n% MIDI pitch scales the gourd: shell radius and thickness by\n% s = 2^-((pitch - 60)/12), shifting the shell modes and the cavity\n% resonance by the semitone ratio while the seed beads stay the same\n% size, so higher notes are smaller, brighter shakers. Pitch 60 is the\n% default gourd, playable 48..72; the sound is noise-based, so the note\n% number sets register rather than a tuned fundamental. Velocity drives\n% the stroke speed. Fixed: a single stroke, a fixed seed, normalize off\n% so velocity survives in pascals.\nP = maraca_defaults();\nP.sample_rate = note.sample_rate;\nP.stroke_count = 1;\nP.seed = 1;\nP.pre_delay_ms = 0;\nP.normalize = 0;\nif note.preview ~= 0\n P.oversample = 1;\nend\ns = 2 ^ (-(max(48, min(72, note.pitch)) - 60) / 12);\nP.shell_radius_m = P.shell_radius_m * s;\nP.shell_thickness_m = P.shell_thickness_m * s;\nP.shake_velocity = 0.2 + (6 - 0.2) * note.velocity;\nP.grain_count = round(note.params.grain_count);\nP.burst_width_ms = note.params.burst_width_ms;\ny = maraca_render(P);\nend\n"
2828 },
2929 {
3030 "name": "maraca_basis.m",
↑↓ move↵openescclose