/ proof-of-concept / cymbalsim
Sign in
proof-of-concept / cymbalsim
Hammered crash: an option to scatter the dents at random
randomDents = 1 places the marks at random with uniform density over the bow, from a seeded congruential generator in the script, so that a seed always gives the same cymbal; the default stays the spiral.
Jeremy Magland <jmagland@flatironinstitute.org> committed commit 149833c43ed7 parent 0b50660 Browse files
1 changed file+24−10
src/presets.tsmodified+24−10View file
@@ -190,16 +190,20 @@ end
190190 `;
191191
192192 const crashHammered16 = `% The 16 inch crash with bell, hammered: 160 shallow dents of 0.4 mm on
193-% the bow, laid out on a sunflower spiral so that no two align. A hammered
194-% cymbal is no longer axisymmetric, so its degenerate mode pairs split and
195-% its modes mix, which is part of what makes a cymbal sound like one. The
196-% dents here are what a script can express, a change of the rest shape;
197-% the residual stresses of real hammering are not modeled.
193+% the bow, laid out on a sunflower spiral so that no two align, or, with
194+% randomDents set to 1, scattered at random over the bow (dentSeed picks the
195+% pattern, and the same seed gives the same cymbal). A hammered cymbal is
196+% no longer axisymmetric, so its degenerate mode pairs split and its modes
197+% mix, which is part of what makes a cymbal sound like one. The dents here
198+% are what a script can express, a change of the rest shape; the residual
199+% stresses of real hammering are not modeled.
198200 inch = 0.0254; mm = 1e-3;
199201 D = 16*inch; R = D/2;
200202 bellR = 55*mm; bellH = 8*mm; bowH = 10*mm;
201203 tCenter = 1.2*mm; tEdge = 0.7*mm;
202204 nDents = 160; dentR = 12*mm; dentDepth = 0.4*mm;
205+randomDents = 0; % 0: the spiral; 1: random places, overlapping as hammer marks do
206+dentSeed = 1; % any positive integer; changes the random pattern
203207
204208 design.name = '16 inch hammered crash';
205209 design.material.E = 110e9;
@@ -213,7 +217,7 @@ design.bounds.width = D;
213217 design.bounds.height = D;
214218 design.inside = @(x, y, r, theta) r <= R;
215219 design.thickness = @(x, y, r, theta) tCenter + (tEdge - tCenter) * ramp(bellR, R, r);
216-design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH) + dents(x, y, bellR + dentR, R - dentR, nDents, dentR, dentDepth);
220+design.profile = @(x, y, r, theta) bowH * (1 - (r/R).^2) + dome(r, bellR, bellH) + dents(x, y, bellR + dentR, R - dentR, nDents, dentR, dentDepth, randomDents, dentSeed);
217221
218222 function v = ramp(a, b, x)
219223 v = min(max((x - a) ./ (b - a), 0), 1);
@@ -225,15 +229,25 @@ function v = dome(d, radius, height)
225229 v = 0.5 * height * (1 + cos(pi * d / radius)) .* (d < radius);
226230 end
227231
228-function v = dents(x, y, r0, r1, n, rd, depth)
232+function v = dents(x, y, r0, r1, n, rd, depth, random, seed)
229233 % n hammer marks between the radii r0 and r1: Gaussian dents of 1/e radius
230234 % rd, placed on a sunflower spiral (equal area per mark, golden-angle
231-% spacing) so that the pattern has no symmetry.
235+% spacing) so that the pattern has no symmetry, or at random with uniform
236+% density over the annulus, from a small congruential generator so that a
237+% seed always gives the same pattern.
232238 v = 0 * x;
233239 ga = pi * (3 - sqrt(5));
240+s = seed;
234241 for k = 1:n
235- rk = sqrt(r0^2 + (r1^2 - r0^2) * (k - 0.5) / n);
236- tk = k * ga;
242+ if random
243+ s = mod(s * 1664525 + 1013904223, 4294967296); u = s / 4294967296;
244+ s = mod(s * 1664525 + 1013904223, 4294967296); w = s / 4294967296;
245+ rk = sqrt(r0^2 + (r1^2 - r0^2) * u);
246+ tk = 2 * pi * w;
247+ else
248+ rk = sqrt(r0^2 + (r1^2 - r0^2) * (k - 0.5) / n);
249+ tk = k * ga;
250+ end
237251 dx = x - rk * cos(tk); dy = y - rk * sin(tk);
238252 v = v - depth * exp(-(dx.^2 + dy.^2) / rd^2);
239253 end
↑↓ move↵openescclose