8 ms·
Breaking a Wine Glass in Python by Detecting the Resonant Frequency
- js2 9y agoSemi-related discussion 4 months ago: https://news.ycombinator.com/item?id=15667096 https://news.ycombinator.com/item?id=15667096
- the_cat_kittles 9y agofun project! if you arent married to python, or the idea of writing a bunch of superfluous code (:P) fft'ing a sound is pretty trivial, and creating a sound at that frequency is also trivial from command line. i google for 15 seconds, looks like this library https://aubio.org/manual/latest/cli.html https://aubio.org/manual/latest/cli.html would work fine with something like aubio notes -r $(aubio pitch myfile.wav) would probably do it. i love python as much as the next person, but sometimes... ah well, cool project anyway!
- danbolt 9y agoAs much as I’d likely end up using some sort of scripting language for something like this, being able to do it via command line is always lovely.
- nurettin 9y ago"doing X in python" titles are a recurring theme in HN. I don't care much about the language, especially because of silly syntax like explicit self on methods (oh yeah, they have the "zen philosophy" of explicit vs implicit where every other thing in the language is implicit except this) and obviously broken tooling that installs an old version of pip when you create a virtual environment.
- jsjohnst 9y ago“complaining about X” when X isn’t your preferred tool of choice also sadly seems to be a recurring theme on HN comments. Where’s your post about doing something similar in your tool of choice?
- nurettin 9y agohere you go: http://blog.nurett.in/post/171958522813/python3-for-frustrated-rubyists http://blog.nurett.in/post/171958522813/python3-for-frustrat...
- abhirag 9y agoI have no intention of starting or getting into a flame war between Ruby and Python, both are great languages but I can help with the Python tooling a bit. The Python equivalent of rvm is pyenv (https://github.com/pyenv/pyenv/blob/master/README.md https://github.com/pyenv/pyenv/blob/master/README.md) and to install dependencies and handle virtual environments after that you can use pipenv (https://github.com/pypa/pipenv https://github.com/pypa/pipenv). Both of them together will get you almost similar experience to the Ruby tooling example you ended the post with. I love why the lucky stiff's writing, I love POODR (http://www.poodr.com/ http://www.poodr.com/) and the two languages have a lot in common if you just keep an open mind about it :)
- nurettin 9y agoI do appreciate the effort you've put into this response, unlike parent. Well done. Next time I have to do something in python, I will try pyenv and pipenv (and maybe write about it, too)
- jsjohnst 9y agoExactly what I expected as a response. Thank you for confirming my suspicion!
- nurettin 9y agoYou provide so much value. Definitely an MVP hackernews user.
- jsjohnst 9y agoWhy should I spend my valuable time to help you when you literally spend no time to help yourself and instead blame tools for your inability to use them? Reread your posts in this thread and your blog post and show me where there’s any sign that wouldn’t be a lost cause effort.
- ChuckMcM 9y agoResonance is an amazing thing. I was fixated on it for a while because it was something that fascinated Tesla. There was a story where he attaches a small hammer to a building which is tapping slowly and it shakes the building to its foundations. The Mythbusters have done a couple of shows on it as well (https://www.youtube.com/watch?v=IZD8ffPwXRo https://www.youtube.com/watch?v=IZD8ffPwXRo, and https://www.youtube.com/watch?v=7xODgR2FEKo https://www.youtube.com/watch?v=7xODgR2FEKo) Things I learned were that the crystal (and steel) structure are important because every bit of compliance in the system absorbs energy and turns it into heat rather than reflecting it back into the structure. Bricks work too if they are hard fired. Finding the exact resonant frequency can be difficult as it can change as the system begins to vibrate. Sometimes the harmonics are better than the fundamental frequency. If I were doing this today I'd probably clips a strain gauge to the material and use a feedback loop to localize to the peak energy absorption frequency.
- madengr 9y agoA laser would work well too, that way you don’t damp the resonance.
- mirimir 9y agoThis cut does a good job for buildings: https://www.youtube.com/watch?v=SFBV2UzsB3A https://www.youtube.com/watch?v=SFBV2UzsB3A
- tzs 9y agoThey used to do a demo for the introductory mechanical engineering class at Caltech where they got the 9 story Millikan Library noticeably moving by having something vibrating on the roof at the building's resonant frequency. That library has long been used for research and experiments involving resonance. The seismologists and structural engineers have had it full of instruments for 50 years and been studying how its resonances change periodically in response to weather and other natural cycles, and how they change permanently after earthquakes, and they have used shaking it to study wave propagation. Apparently all you need is something that is big, resonates, and is coupled to the ground and you can do some fun science. Some papers: "Soil-Structure System Identification of Millikan Library North–South Response during Four Earthquakes (1970–2002): What Caused the Observed Wandering of the System Frequencies?" [1] "The Millikan shaking experiments and high-frequency seismic wave propagation in Southern California" [2] "Variations in the Natural Frequencies of Millikan Library Caused by Weather and Small Earthquakes" [3] "Results of Millikan Library Forced Vibration Testing" [4] "The Observed Wander of the Natural Frequencies in a Structure" [5] [1] https://pubs.geoscienceworld.org/ssa/bssa/article-abstract/99/2A/626/342074 https://pubs.geoscienceworld.org/ssa/bssa/article-abstract/9... [2] https://www.scec.org/publication/1908 https://www.scec.org/publication/1908 [3] https://ascelibrary.org/doi/abs/10.1061/40753%28171%2990 https://ascelibrary.org/doi/abs/10.1061/40753%28171%2990 [4] https://authors.library.caltech.edu/26542/ https://authors.library.caltech.edu/26542/ [5] http://earthquake-eng.usc.edu/ECEES_STS-E10/Clinton_BSSA_2006.pdf http://earthquake-eng.usc.edu/ECEES_STS-E10/Clinton_BSSA_200...
- RickJWagner 9y agoHacker News paydirt! Good read, cool programming. :)
- Tomminn 9y agoI noticed an interesting resonance just yesterday on my guitar. You can actually tune a guitar by playing, for example, an A note on the E string repeatedly, and moving the tuning pegs on the A string until the A string starts vibrating. This is kind of hard to do using just the visuals, as you run out of hands unless you play and fret the string with the same hand. But it works really nicely if you try to find the note by ear, and then use visual resonance as confirmation that you're right. Makes tuning pretty fun.
- maxerickson 9y agoThat'll tune the one string to the other, but not necessarily bring the guitar into tune. This guy goes through a bunch of other combinations: https://www.youtube.com/watch?v=dMhrF-LvfUk https://www.youtube.com/watch?v=dMhrF-LvfUk
- Tomminn 9y agoYeah, but that's always the best you can do without an external note. And if there are no external notes around, you could argue it's all that matters;)
- dec0dedab0de 9y agoEspecially since A=440 is arbitrary to begin with.
- olympus 9y agoIt starts out arbitrary but becomes useful once everyone agrees with it, like measuring distance in meters- which has gone through several definitions, none of which make much sense in terms of being based on a natural constant and using a nice round numbers as a coefficient. If four instruments are following the standard and one is a bit flat because "A-440 Hz is arbitrary" then the whole band sounds like a mess.
- JoshTriplett 9y ago
- michaelfeathers 9y agoObligatory. https://news.ycombinator.com/item?id=11189688 https://news.ycombinator.com/item?id=11189688
- goldenkey 9y agoWas a bit dissapointed. Thought he was going to do an audio sweep and use ML on a video feed to detect the resonant frequency and break the glass as fast as possible.
- tripzilch 9y agoI agree it would have been cooler if he did an autodetection sweep (or the impulse response thing mentioned upthreads), but not disappointingly so. However I would have been disappointed if he used ML for the detection. Some basic DSP would suffice and be much more accurate without needing a days worth of training on a powerful video card.
- lifeisstillgood 9y agoWhat struck me was a different project every day for 50 days. lovely way to spend your time
- SlowRobotAhead 9y agoIDK. For me that would be training myself to put hacky poorly considered code together as fast as possible. I can already do that, but it’s not a good habit.
- mrlala 9y ago>but it’s not a good habit Being able to get things done is a good habit. There's of course a balance somewhere in the middle, but doing 50 projects in 50 days and having to work quick and write code that "works" is certainly a valuable skill.
- baobrien 9y agoCouldn't you figure out the resonant frequency automatically by hitting the glass with a few impulses from the speaker and looking at the response? That'd be a fun signal processing exercise.
- jsjohnst 9y agoI’m not a sound expert, but I’m curious how you think this would work?
- hedora 9y agoWhen the glass starts resonating, it should start prouducing sound too, so you should be able to hear two frequencies as you get close to the right frequency — I think. (Not a sound expert either)
- sannee 9y agoApplying fourier transform to impulse response results in the frequency response: https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.freqz.html https://docs.scipy.org/doc/scipy/reference/generated/scipy.s... I think this would work only if the system in question is reasonably linear though, which wine glass might not be (?)
- pletnes 9y agoTechnically speaking, you don’t need to know the frequency response in detail, or whether it’s exactly linear. If the glass «sings» at a given frequency after being whacked by a short impulse, that’s a resonant frequency.
- rotten 9y agoSo if he builds a big one can he knock down bridges?
- enriquto 9y agothat's great! but what's it to do with python ?