/ interactive_tutorials / hardening_softening
Sign in
interactive_tutorials / hardening_softening
hardening_softening / app / index.html
160 lines · 10.1 KBBlameHistoryRaw
1<!doctype html>
2<html lang="en">
3<head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>Hardening and Softening</title>
7 <link rel="stylesheet" href="vendor/katex-0.16.9/katex.min.css">
8 <script src="vendor/katex-0.16.9/katex.min.js"></script>
9 <link rel="stylesheet" href="style.css">
10</head>
11<body>
12 <nav class="pager">
13 <button id="nav-prev" aria-label="Previous slide"></button>
14 <button id="nav-pos" class="nav-toc" aria-haspopup="true" aria-expanded="false" title="Slides (T)"></button>
15 <div id="toc" class="toc" hidden>
16 <ol id="toc-list"></ol>
17 </div>
18 <button id="nav-next" aria-label="Next slide"></button>
19 </nav>
20 <main>
21 <div id="deck">
22 <section id="landing" data-hint="Title" class="page active">
23 <h1>Hardening and Softening Dynamical Systems</h1>
24 <button class="start" data-goto="harmonic">Click to get started</button>
25 <p class="crafted"><a id="crafted-link" target="_blank" rel="noopener" hidden>&#9998; Crafted by a human</a></p>
26 </section>
28 <section id="harmonic" data-hint="Harmonic" class="page split oscillator-page">
29 <h2>Harmonic Oscillator</h2>
31 <div class="text">
32 <ul class="defs">
33 <li><span data-tex="x"></span> &mdash; displacement from equilibrium</li>
34 <li><span data-tex="k"></span> &mdash; stiffness</li>
35 <li><span data-tex="m"></span> &mdash; mass of block</li>
36 <li><span data-tex="f_0 = \sqrt{k / m}\,/\,(2\pi)"></span> &mdash; natural frequency (Hz)</li>
37 </ul>
38 <div data-tex="\ddot{x} + (2\pi f_0)^2\, x = 0"></div>
39 </div>
41 <div class="demo" data-oscillator></div>
42 </section>
44 <section id="duffing" data-hint="Duffing" class="page split oscillator-page">
45 <h2>Duffing Oscillator (Conservative)</h2>
47 <div class="text">
48 <ul class="defs">
49 <li><span data-tex="x"></span> &mdash; displacement from equilibrium</li>
50 <li><span data-tex="k"></span> &mdash; stiffness</li>
51 <li><span data-tex="m"></span> &mdash; mass of block</li>
52 <li><span data-tex="f_0 = \pm\sqrt{|k| / m}\,/\,(2\pi)"></span> &mdash; natural frequency (Hz), with the sign of <span data-tex="k"></span></li>
53 <li><span data-tex="\alpha = \beta / m"></span> &mdash; cubic stiffness term</li>
54 </ul>
55 <div data-tex="\ddot{x} + \frac{k}{m}\, x + \alpha\, x^3 = 0"></div>
56 </div>
58 <div class="demo" data-oscillator></div>
59 </section>
61 <section id="damped" data-hint="Damped" class="page split oscillator-page">
62 <h2>Duffing Oscillator (Damped)</h2>
64 <div class="text">
65 <ul class="defs">
66 <li><span data-tex="x"></span> &mdash; displacement from equilibrium</li>
67 <li><span data-tex="k"></span> &mdash; stiffness</li>
68 <li><span data-tex="m"></span> &mdash; mass of block</li>
69 <li><span data-tex="f_0 = \pm\sqrt{|k| / m}\,/\,(2\pi)"></span> &mdash; natural frequency (Hz), with the sign of <span data-tex="k"></span></li>
70 <li><span data-tex="\alpha = \beta / m"></span> &mdash; cubic stiffness term</li>
71 <li><span data-tex="\delta = c / m"></span> &mdash; damping coefficient</li>
72 </ul>
73 <div data-tex="\ddot{x} + \delta\, \dot{x} + \frac{k}{m}\, x + \alpha\, x^3 = 0"></div>
74 </div>
76 <div class="demo" data-oscillator></div>
77 </section>
79 <section id="driven" data-hint="Driven" class="page split oscillator-page">
80 <h2>Duffing Oscillator (Driven)</h2>
82 <div class="text">
83 <ul class="defs">
84 <li><span data-tex="x"></span> &mdash; displacement from equilibrium</li>
85 <li><span data-tex="k"></span> &mdash; stiffness</li>
86 <li><span data-tex="m"></span> &mdash; mass of block</li>
87 <li><span data-tex="f_0 = \pm\sqrt{|k| / m}\,/\,(2\pi)"></span> &mdash; natural frequency (Hz), with the sign of <span data-tex="k"></span></li>
88 <li><span data-tex="\alpha = \beta / m"></span> &mdash; cubic stiffness term</li>
89 <li><span data-tex="\delta = c / m"></span> &mdash; damping coefficient</li>
90 <li><span data-tex="F = F_0 / m"></span> &mdash; forcing amplitude per unit mass</li>
91 <li><span data-tex="\Omega"></span> &mdash; driving frequency</li>
92 </ul>
93 <div data-tex="\ddot{x} + \delta\, \dot{x} + \frac{k}{m}\, x + \alpha\, x^3 = F \cos(\Omega t)"></div>
94 <div class="presets" data-presets></div>
95 </div>
97 <div class="demo" data-oscillator></div>
98 </section>
101 <!-- Lab: experimental slides for exploring, outside the recipe (see lab.md). -->
102 <section id="orbits" data-hint="Lab" class="page split oscillator-page">
103 <h2>Lab &ndash; orbits played by instruments</h2>
105 <div class="text" data-phase-controls></div>
107 <div class="demo" data-phase></div>
108 </section>
110 <section id="how" data-hint="How" class="page doc">
111 <h2>How the instruments are driven</h2>
113 <div class="text">
114 <div class="equations">
115 <div>
116 <h3>From motion to sound</h3>
117 <p>The oscillator is integrated sample by sample at the audio rate (48&nbsp;kHz). Its displacement, divided by the largest displacement of the orbit, gives the sound</p>
118 <div data-tex="u(t) = x(t) / x_{\mathrm{ref}},"></div>
119 <p>which peaks near 1. With <em>Raw</em>, we hear <span data-tex="u"></span> itself.</p>
121 <h3>The instrument is a linear filter</h3>
122 <p>An instrument is a fixed, linear, time-invariant filter with impulse response <span data-tex="h"></span>, mixed with the sound itself by the dry / wet setting <span data-tex="w"></span>:</p>
123 <div data-tex="y = (1-w)\, u + w\, (h * u), \qquad Y(f) = \big[(1-w) + w\, H(f)\big]\, U(f)."></div>
124 <p>Each filter is a sum of resonances. A resonance at <span data-tex="f_k"></span> with decay time <span data-tex="\tau_k"></span> contributes</p>
125 <div data-tex="h_k(t) = \frac{2 g_k}{\tau_k}\, e^{-t/\tau_k} \sin(2\pi f_k t),"></div>
126 <p>a peak of height <span data-tex="g_k"></span> at <span data-tex="f_k"></span>, about <span data-tex="1/(\pi \tau_k)"></span> wide. Each <span data-tex="H"></span> is scaled so that its largest value is 1, and is applied by convolution.</p>
128 <h3>What a linear filter can and cannot do</h3>
129 <p>A linear filter only reweights the frequencies already in <span data-tex="u"></span>; it cannot create new ones. A steady tone at frequency <span data-tex="f"></span> therefore stays a tone at the same pitch, made louder or quieter by <span data-tex="|H(f)|"></span>. The character of an instrument (its ringing and decay) appears only when the sound changes: at onsets, during pitch glides, and in chaotic motion.</p>
130 <p>The <em>Wooden body</em>, with broad resonances, colors any pitch. The <em>Metal plate</em> has many narrow resonances at no particular pitches, so it rings most with changing and chaotic sound. The tuned ones (<em>Marimba</em>, <em>Harp</em>, <em>Bell</em>) are tuned to the oscillator's natural frequency <span data-tex="|f_0|"></span> (220&nbsp;Hz when <span data-tex="f_0 = 0"></span>); their peaks are narrow (0.2&nbsp;Hz for a harp string), so a steady tone sounds through them only when it lands on a note, as at the hardening default (370&nbsp;Hz, the major sixth above 220&nbsp;Hz).</p>
132 <h3>Loudness and limiting</h3>
133 <p>These are the only non-linear steps. Loudness normalization tracks the mean square of <span data-tex="y"></span> over about 0.2&nbsp;s and moves the gain smoothly toward an RMS level of 0.3, boosting by at most 26&nbsp;dB. A limiter then rounds off any peaks above 0.8, leaving the sound untouched below that, so at normal levels it adds no distortion.</p>
135 <h3>Removing the driving frequency</h3>
136 <p>For a driven system, the drive's own frequency <span data-tex="\Omega/2\pi"></span> can be removed before the instrument by a notch filter about <span data-tex="\Omega/(2\pi \cdot 30)"></span> wide. This is also linear. What remains is the oscillator's own response away from <span data-tex="\Omega"></span>: subharmonics, the harmonics made by the nonlinearity, and the broad spectrum of chaos.</p>
137 </div>
139 <div>
140 <h3>The instruments</h3>
141 <ul class="doc-list">
142 <li><em>Wooden body</em>: 10 broad resonances from 100 to 2500&nbsp;Hz (<span data-tex="\tau"></span> from 80 to 15&nbsp;ms).</li>
143 <li><em>Metal plate</em>: 96 inharmonic resonances spread from 100 to 4000&nbsp;Hz (<span data-tex="\tau"></span> from 0.3 to 1.2&nbsp;s), not tuned.</li>
144 <li><em>Marimba</em>: bars on the chosen scale from <span data-tex="|f_0|"></span> over two octaves, each with partials at 1, 3.93 and 9.2 times its pitch (<span data-tex="\tau"></span> = 0.6, 0.25 and 0.1&nbsp;s).</li>
145 <li><em>Harp</em>: strings on the chosen scale from <span data-tex="|f_0|/2"></span> over three octaves, each with its first six harmonics (<span data-tex="\tau"></span> = 1.5&nbsp;s for the fundamental).</li>
146 <li><em>Bell</em>: 11 church-bell partials of <span data-tex="|f_0|"></span> (0.5, 1, 1.2, 1.5, 2, &hellip; times it).</li>
147 </ul>
148 <p>The marimba and harp use the scale chosen on the previous slide (equal-tempered; major pentatonic by default, with 10 bars and 15 strings): major or minor pentatonic, major, natural or harmonic minor, blues, whole tone, or chromatic.</p>
149 <p class="caption">Their responses <span data-tex="|H(f)|"></span> in dB (to &minus;40&nbsp;dB), the tuned ones at <span data-tex="|f_0| = 220"></span>&nbsp;Hz on the major pentatonic scale:</p>
150 <canvas class="responses"></canvas>
151 </div>
152 </div>
153 </div>
154 </section>
155 </div>
156 </main>
157 <script src="crafted-link.js"></script>
158 <script type="module" src="main.js"></script>
159</body>
160</html>
↑↓ move↵openescclose