跳到主内容
@wquguru
精选70Hacker News Best(web_list)产品发布/更新

eigendrum:用特征值分解模拟任意形状鼓声的在线鼓机

eigendrum:基于特征值分解的鼓机

原文
发到 X

how it works

工作原理

A drumhead clamped at its rim can only vibrate in certain shapes, at certain frequencies. Those shapes and frequencies are the solutions of

边缘被夹紧的鼓面只能以特定形状和特定频率振动。这些形状和频率是以下方程的解:

−∇²u = λu inside the shape, u = 0 on the edge

−∇²u = λu 在形状内部,u = 0 在边缘上

Each solution u is a mode, a standing wave, and each λ gives a frequency proportional to √λ. This is an eigenvalue problem, and for almost every shape it has no formula. So Eigendrum solves it numerically: it covers your shape with a mesh of triangles, builds the finite element stiffness and mass matrices, and finds the smallest eigenvalues of Kφ = λMφ.

每个解 u 是一种模态,即驻波,每个 λ 给出与 √λ 成正比的频率。这是一个特征值问题,对于几乎任何形状都没有公式解。因此 Eigendrum 用数值方法求解:它用三角形网格覆盖你的形状,构建有限元刚度矩阵和质量矩阵,并找出 Kφ = λMφ 的最小特征值。

why you can trust the numbers

为什么你可以信任这些数字

A few shapes have spectra that can be written down exactly, and the solver is tested against them on every change. A circle's frequencies are the zeros of Bessel functions; a rectangle's are π²(m²/a² + n²/b²). The solver reproduces both to better than a tenth of a percent, and because a conforming finite element method minimises energy over a restricted space, its answers are guaranteed slight overestimates, never under. The measured error is in “the numbers”.

少数形状的频谱可以精确写出,求解器在每次更改时都会针对它们进行测试。圆的频率是贝塞尔函数的零点;矩形的频率是 π²(m²/a² + n²/b²)。求解器对两者的重现精度都优于千分之一,并且由于协调有限元方法在受限空间内最小化能量,其答案保证是轻微高估,绝不会低估。测量误差在“数字”中体现。

where you strike it matters

敲击位置很重要

Striking a spot drives each mode in proportion to how much that mode moves there. Hit a line where a mode stands still and you cannot excite it at all. That was not programmed in; it falls out of projecting the mallet onto the modes.

敲击一个点会按该模态在该点的位移比例驱动每个模态。如果敲击在模态静止的线上,你根本无法激发它。这不是编程设定的;它来自将鼓槌投影到模态上的结果。

So a strike is never one mode: it is every mode at once, in a mixture set by where your mallet landed. The rules along the mode list are that mixture, and the modes marked with a square were the ones your mallet could not reach. Pressing a row instead plays that single mode alone - something no mallet can do, and the only way to hear what one frequency of a shape actually sounds like.

因此,一次敲击从来不是单一模态:它同时是所有模态,混合比例由鼓槌落点决定。模态列表上的规则就是这种混合,标记为方块的模态是你的鼓槌无法触及的。按下某一行则单独播放该模态——这是任何鼓槌都无法做到的,也是听到形状单一频率实际声音的唯一方式。

drums from equations

从方程生成鼓

Besides tracing an outline you can write one. r(t) gives the radius as t sweeps one full turn, so 1 + 0.3cos(5t) is a five-lobed flower; a parametric x(t), y(t) pair reaches the closed curves polar cannot, like a nephroid or an egg. This is not a shortcut for drawing. It reaches shapes no hand traces accurately - eleven even lobes, a superellipse partway between a circle and a square - and it makes a shape something you vary: change one number and hear what moved.

除了描摹轮廓,你还可以编写一个。r(t) 给出半径,t 扫过一整圈,所以 1 + 0.3cos(5t) 是一个五瓣花;参数化的 x(t), y(t) 对可以到达极坐标无法描述的闭合曲线,如肾形线或蛋形。这不是绘图的捷径。它能达到手绘无法精确描绘的形状——十一个偶数叶瓣、介于圆和正方形之间的超椭圆——并且它使形状成为可变的:改变一个数字,听听什么发生了变化。

A written shape travels as its own text. The link for a formula holds the formula, so it is something you can read and retype rather than a few hundred characters of encoded outline, and editing it in the address bar works. Anything too thin to mesh honestly is refused rather than answered, because a sliver would still return numbers and they would be wrong.

一个书写的形状以其自身的文本形式传播。公式的链接包含公式本身,因此它是你可以阅读和重新输入的内容,而不是几百个字符的编码轮廓,在地址栏中编辑它也能生效。任何过于单薄而无法诚实融合的内容都会被拒绝而非回答,因为一小片仍然会返回数字,而这些数字将是错误的。

can one hear the shape of a drum?

能听出鼓的形状吗?

Mark Kac asked exactly that in 1966. In 1992 Carolyn Gordon, David Webb and Scott Wolpert answered no, by building two different shapes with identical spectra. Both are in the form list as Kac drum I and II. Each is made from the same seven triangles, rearranged. They enclose the same area and the same perimeter, and every frequency matches. Switch between them and listen: the outlines are plainly different and the sound is not.

马克·卡克在1966年恰好提出了这个问题。1992年,卡罗琳·戈登、大卫·韦伯和斯科特·沃尔珀特通过构建两个具有相同频谱的不同形状回答了“不能”。两者都在形状列表中,分别称为卡克鼓I和II。每个都由相同的七个三角形重新排列而成。它们包围相同的面积和相同的周长,每个频率都匹配。在它们之间切换并聆听:轮廓明显不同,声音却并非如此。

what's physics, and what's just a slider

什么是物理,什么只是滑块

The frequency ratios, the mode shapes, and the pitch of the fundamental are all baked into the outline - you can't touch them. What you can move is the wave speed (tension and density): the pitch slider names the note a circle of this area would sound, and your actual shape lands above or below that on its own. Since every shape gets scaled to the same area first, that offset is genuinely about the shape - roughly six semitones of spread across the built-in presets, with the circle always lowest thanks to Faber-Krahn's inequality. Fade time is a real slider too, since that's material and air, not something the maths pins down.

频率比、模态形状和基音的音高都内置于轮廓中——你无法触碰它们。你可以移动的是波速(张力和密度):音高滑块命名了一个具有此面积的圆会发出的音符,而你的实际形状会自行落在其上方或下方。由于每个形状首先被缩放到相同的面积,这种偏移确实与形状有关——内置预设中大约有六个半音的跨度,圆总是最低的,这得益于法伯-克拉恩不等式。衰减时间也是一个真正的滑块,因为那是材料和空气的问题,不是数学所固定的。

The mallet works the same way. Its width is a slider; its contact time is fixed at a few milliseconds, because no real beater is instant, and one that was would slam every mode equally hard. Both change how much of a mode a strike can reach - neither one can shift where a mode actually sits. Damping is Rayleigh damping, so loss rises with the square of frequency: the high overtones die away first, which is why a drum darkens as it rings.

鼓槌的工作方式相同。它的宽度是一个滑块;其接触时间固定为几毫秒,因为没有真正的鼓槌是瞬时的,如果是瞬时的,它会同样用力地撞击每个模态。两者都改变了一次击打能触及模态的程度——但都不能移动模态实际所在的位置。阻尼是瑞利阻尼,因此损耗随频率的平方增加:高次泛音首先消失,这就是为什么鼓在回响时会变暗。

where it lives, and how to reach me

它在哪里,以及如何联系我

Eigendrum is hosted at eigendrum.com. That is the address to link to and to cite; the older baselashraf81.github.io/eigendrum is a mirror that now redirects there.

Eigendrum托管在eigendrum.com。这是要链接和引用的地址;较旧的baselashraf81.github.io/eigendrum是一个镜像,现在重定向到那里。

For advertising or partnership enquiries, write to [email protected]. For anything wrong with the maths or the interface, an issue on the repository is better, because then the fix is public.

对于广告或合作咨询,请写信至[email protected]。对于数学或界面上的任何错误,在仓库上提出问题更好,因为那样修复将是公开的。

colophon

版权页

No build step and no application backend: the mesh, the solve and the audio all run on your own machine. The deployed site uses Google Analytics for aggregate site analytics and a Cloudflare D1 counter for the public visit total; it carries no advertising network and no consent banner. Support toward the domain and hosting is voluntary, via the link above. The shape you draw lives in the address bar after the #, which browsers never send to a server, and analytics is configured not to record it. Details in the privacy notice. Set in Jost* by indestructible type*. After Kac, Can One Hear the Shape of a Drum? (1966); Gordon, Webb and Wolpert (1992); and Driscoll, Eigenmodes of Isospectral Drums (1997), whose coordinates the two Kac drums use.

无需构建步骤,也无需应用后端:网格、求解和音频都在您自己的机器上运行。部署的网站使用Google Analytics进行聚合站点分析,并使用Cloudflare D1计数器统计公开访问总数;它不携带广告网络,也没有同意横幅。对域名和托管的支持是自愿的,通过上面的链接进行。您绘制的形状存在于地址栏中#之后,浏览器不会将其发送到服务器,并且分析配置为不记录它。详情见隐私声明。字体使用indestructible type*的Jost*。继Kac的《能听出鼓的形状吗?》(1966);Gordon、Webb和Wolpert (1992);以及Driscoll的《等谱鼓的本征模》(1997)之后,两个Kac鼓使用了其坐标。

Source, including the solver and the tests that check it against the closed-form spectra: github.com/BaselAshraf81/eigendrum

源代码,包括求解器以及针对闭式谱进行测试的测试用例:github.com/BaselAshraf81/eigendrum

Free to use, with no account and nothing to install. If you would like to put something towards it, or would rather it were not ad-supported: ko-fi.com/baselashraf

免费使用,无需账户,无需安装任何东西。如果您愿意支持,或者希望它不依赖广告:ko-fi.com/baselashraf

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

另一事件,读法相近