After finishing the last article, I meandered for a while trying to find a new topic. I eventually strongly considered writing about lasers – their function relies on a few interesting physical phenomena that were worth visualizing.
I wanted to understand and explain these concepts from the ground up, by first showing how mirrors used in lasers end up reflecting light and reversing phase of the electromagnetic wave. Unfortunately, I was not able to find a good justification for this behavior, especially with 3 different materials (air, glass, silver) being involved in the process – it seems that I wasn't the only one. It's very demoralizing when I can't find the answers for even the most fundamental questions like these, so I abandoned the idea of lasers completely and had to start my search for a new idea from scratch.
Thankfully, the MIT lectures about vibrations and waves I was watching in preparation for lasers inspired me to switch from electromagnetic waves to pressure waves, and that's how I ended up writing about sound.
I originally really wanted to visualize pressure wave propagation using particle simulations, but, despite numerous attempts, I couldn't recreate any observable pressure waves. I suspect that I'd have to simulate truly enormous numbers of particles to witness any typical large-scale behavior.
It's still a little unintuitive to me that the air just works, and the huge number of collisions between the discrete particles ends up creating, on average, a more or less continuous medium that we can reason about.
Starting with air particles was easy, but after that it was, once again, quite difficult to find an appropriate progression of the topics. One approach would be to introduce sine waves at first and build up other waveforms from there, but I wanted to have a more tangible experience of individual pops becoming discernible notes as their frequency increases. This provided a springboard for more complicated shapes.
Since the beginning I knew I wanted to present some aspects of the Fourier transform. I initially wanted to show that we don't necessarily have to resolve to using sines as the basis of decomposition and that one could decompose a signal e.g. into a sum of triangular functions. Unfortunately, my assumption was actually incorrect – it turned out that triangular functions are actually not orthogonal, and one can't use a sum of "harmonic" triangles to represent an arbitrary function!
One of the biggest surprises was learning about the difference in behavior of air next to a sphere or a piston that is vibrating at low and high frequencies – this then also happens in real speakers. Many introductory sources don't talk about it, and only textbooks dedicated to acoustics describe this unusual relation.
Despite showing it in the article, this behavior still feels a little unintuitive to me. One can easily observe that difference experimentally using a single driven harmonic oscillator, or even a series of them, but I'd like to see a larger scale simulation with "masses and springs" that reaches the same outcomes. I couldn't reliably reproduce that in my simple tests.
Simulation of the guitar string was a last minute addition, but I'm very glad I put it in. It was relatively simple to implement, but it added the much needed tangible connection between vibration and emitted sound.
My original plan for the final section also included a description of sound diffraction, but it turned out that this process is significantly harder to simulate. The Huygens principle is actually more complicated than it's usually presented. It requires a 90 degree phase change for the secondary waves, which makes it more questionable for rapidly varying waves. Some analytical solutions of diffraction through open holes that I found in the literature didn't match the incoming wave at the boundary. Since I couldn't correctly simulate it, I ended avoiding the topic of diffraction completely.
Designing user interface for this article was a bit challenging. The sliders work for simple one dimensional parameters, but they're not a great fit for free form sound creation. The little synthesizer keyboard turned out to be a great solution here as it closely matches real life objects. It's also easy to operate with a computer keyboard or with fingers on a touchscreen. I decided to only use three keys for ease of use on mobile devices, as it's quite inconvenient to fit more than three fingers on a small smartphone screen.
The keyboards use a more realistic aesthetic than the other parts of the demonstrations. I did some quick experiments with a simpler design, but I didn't really like the way it looked:

While the heavier shadows and highlights clash a little with simple forms and shapes of the simulations themselves, I think the design still works reasonably well and that the stylistic difference helps to establish the keyboards as separate entities.
For the most part, I'm pleased with the selection of colors, especially the orangish-red and softer-blue of the pressure waves, which are so commonly drawn using way too jarring pure red and blue colors.
Overall, I'm glad to be done with this topic. I started working on it exactly three months ago – I was growing a little tired of it and the process hasn't been as rewarding as with the other articles. On the flip side, it will probably be a while before another idea will warrant the use of sound on my website, so I'm happy that I ventured into this thus far unexplored region of multimedia.
Tommaso Poletti
2022-11-03 10:29:51 +0000 UTCRahul Banerjee
2022-10-21 08:24:15 +0000 UTCAdrien Rey-Jarthon
2022-10-20 13:13:03 +0000 UTC