180 comments

[ 4.0 ms ] story [ 83.1 ms ] thread
Woah this is cool. Another interesting simonw project based around sound through browsers. Lots of simple real world problems that can be tackled with this.
You can also solve this in O(logn) using a physical binary search:

1) Move half the boxes to another room.

2) Listen for a beep and determine which room the beep comes from.

3) Take the boxes in that room and split it in half again.

4) Repeat until one box is left.

> Move half the boxes to another room.

Alternatively, no.

Alternatively, you can unpack
Who's got that kind of time?
Yes, if you still didn't unpacked it when you don't need it.
I am confident that inventing a new networked sound locating system is far easier than that.
Or you could use a very heavy blanked to just cover some boxes to supress the sound enough to simulate moving boxes.
It's O(logn) but you haven't accounted for how heavy each item in the array of n is.
Lol classic “ignore the constant factor” gotcha when using Big-O.
This is a pretty good real world example to show off how O(n) can't always tell the full story.
This is true, but it probably isn't a box of books that's beeping.

I also feel like ordering the moves by lightest box first is reasonable as a real-world optimization.

Typically, the heavy boxes are at the bottom too; to some extent, the piles will already be sorted by weight.
If you randomly index them and there's enough of them then on average the partitions average out.
You can just move the lightest half of the boxes each time.
A few additional constraints:

  - the boxes are stacked
  - the heavy boxes are at the bottom of a stack, and you can't stack a heavy box on top of a light one
  - boxes aren't the same size
  - some boxes are open, so must be put on top
  - storage space and height are limited
Some boxes contain a wolf, some a sheep, and some a cabbage; the sheep and the wolf cannot be left together, nor the cabbage and the sheep.
Yes, but that's also O(log n) physical effort. This one's O(1) sitting on your butt.

(Solely for entertainment: I think "physical binary search" is more properly O(n^{1/3} log(n)), or maybe O(n^{1/2} log(n)). Since physical objects have sizes, and moving things (or moving between things) takes time proportional to distance).

Good point about the moving effort required. But if moving an object takes constant time, then it's O(n) overall -- since even though there are O(log n) steps, among all n-1 non-beeping items, either (i) all are moved exactly once (this case occurs when the beeping item is not moved during the initial halving) or (ii) half are never moved and the other half are moved exactly twice for O(2 * n/2) = O(n) work, and this term dominates the log n term.
Yeah, that interpretation is more realistic!

O(log n) is if you can split the collection in half in an O(1) step, like, *shoving* the whole pile together as a unit

O(n) if you're moving items one at a time. So, splitting the pile in half is O(n). (You did get it right: searching the whole thing is also O(n))

O(n^{3/2}) if the project is way out of control and walking distances start to matter

O(n^{4/3}) if that, but somehow it's taking place in 3-dimensions

It’s not sitting on your butt if you have to code an entire system and set up notes throughout the house and monitor them.
That requires you to stand in the room and listen for which side. So it’s nlogn times a very long time constant
You could also solve it by getting rid of the boxes of stuff you clearly don't need (if you needed it, it wouldn't still be in a box). The best way to solve a problem is to make the problem go away.
> if you needed it, it wouldn't still be in a box

I like to keep a lot of things in storage, and sometimes go through my boxes and “rediscover” things I haven’t used in a while.

Sure I have a lot of things I never use also. Some things I could sell, and some things I could give away, and some things I could throw away.

But just because a lot of things are in boxes, doesn’t mean that I might as well get rid of all of it for that reason alone.

This has got me thinking, I wonder how many garbage trucks are beeping right now.

And the piles of rubbish at the landfill are probably beeping too.

That was my proposed solution to finding something just today; it didn’t work, but one of the bags ended up containing an old contract from General Development Company. Apparently a late family member had been buying some land down there through them, but county appraisers showed that the land never changed hands until after GDC’s bankruptcy. Not even their kid had heard about this, so it really makes me wonder what the story was behind that considering they lived in the Midwest (but did have some relatives nearby in Florida).
You are moving n/2 objects log(n) times, so its O(n.log(n))
Only half of the remaining boxes need to be moved, not half of the total.
You move n/2, then n/4,...n/2^-i

n. Sum(2^-i)=n

So its o(n. Log(n))

Actually,

  sum_{i=1}^{log_2(n)} (n/2^i) = n - 1
So it's O(n).

A simple example: start at n = 2^m = 10000...

move 2^m/2, and keep adding halves:

  0100...
  0010...
  0001...
  ...
Sum:

  0111...11 = 2^m - 1 = n - 1
n-1 moves are O(n).
In terms of physical effort taken it’s O(n). Move half, then a quarter, then one eighth, etc.

The number of partitions doesn’t matter either, the most straightforward case is the beeping box always being in the original room, so regardless of strategy you move n-1 boxes to narrow it down, and by symmetry it doesn’t matter which room beeps.

You just look in the last box first, duh.
I did roughly that to find my mum's missing hearing aid the other day. The bluetooth would locate which room it was in but not much more detailed than that. It was stuck to some orange peel in a recycling bin.
Close the door of the room the boxes are in.

I'll see myself out...

Could you build this into a HUD for a cat, tuned to mouse squeeks? Asking for a friend.
It seems that the setup might be useful to record the moves of a mouse in order to place traps or locate its nest.
MKBHD demos the the FOTRIC TD2e Acoustic Imaging Camera.

https://www.youtube.com/shorts/ai1gIWacf0I

Of course, at ~$1,000 you'd probably want to rent it for this purpose, but it's interesting to know such a thing exists.

Great thing for tool checkout/rental at a makerspace!
Oh, was gonna post a comment about this, I actually bought just last week their USBc version (Fotric Sonic 3), on eBay, for around $700. Works quite well, it has 64 mic array, I think it would be tough to replicate it to this level.

Lmk if anyone has any questions about it! It’s android-only, but I’ve gotten an agent to write a Mac version of it though haven’t tested yet.

eBay link to what I bought: https://www.ebay.com/itm/960060893216

For an intermittent beep, could you point it at a room and then leave it recording video for an hour, then come back later and scrub through that video looking for the source of the noise?
Does it work for infrequent sounds? The sound might for example come in the middle of the night for two seconds, loud enough to wake one up, then go away. If I leave it on, can it do continuous recording and max or threshold-based capture?
That should work. You could always have Claude Code run the server itself and explain to it the rough parameters of the sound (two seconds, late at night) - then let it listen for hours and occasionally tweak its own configuration to try to better capture what's happening.

In my case it identified that the likely beep was about every 62 seconds pretty quickly - then I confirmed that one of the recordings was the mystery sound and it locked in from there.

Yes it can, works like a thermal camera. No recording (apart from stills), but you can watch the video image and, depending on overlay options, new sounds will be localized on the screen. Use mine to track down air leaks in a compressed air system, thing is magic.
It seems what happened with thermal cameras many years ago might be happening with acoustic ones now. They used to cost a lot more than that.
You know what might have been easier... Going through the boxes!
No, no. Instead of taking the time to unpack the boxes, it's better to spend time to play with AI, and leave the boxes unpacked forever.
WHAT WAS MAKING THE BEEP!!?!?!
wonderful! Thanks for sharing. I thought about doing this to track the sounds moving around in my stomach... it is interesting how well the mic on your smartphone works at picking up stomach sounds
Simon's LLM's beeping finder app vs https://annoyingpcb.com/

Who would win?? :-)

I lack the courage to plant such a PCB prank device... it really feels like you could drive people completely crazy haha

I wonder if it would work to find an annoyatron?
I had a beep that drove me crazy and the very long search turned up a surplus CO monitor that I didn’t recall buying and had gotten tucked into the laundry room for some reason.

Same brand as my smoke detectors.

Make sounds that can be detected directionally, assholes.

I didn't mention this in the article, but this isn't the first time my family has been driven almost spare by a mysterious, hard-to-track beep.

Our dog goes outside and hides in the lavender bush if a smoke alarm starts making a "I need a battery" noise.

So I went into this project with the attitude that I would like to solve this class of problem forever.

Pff that sound is horrible, and sorta hard to locate (because of the pitch?). Anyway. None of my neighbours seem to care and in summer I used to hear an orchestra of beeps every 5 seconds. It was maddening, I was contemplating of buying 1000 batteries, print a manual and shoving it in peoples mailboxes, although somehow I think it wouldnt have made a difference. I moved out eventually (not because of the beeps)
It’s because it doesn’t have enough overtones, or a notable attack. You might have noticed that some trucks these days make a weird noise when they back up instead of a beep. They’re using white noise because it’s easier to locate; it has many overtones that allow your brain to pick the sound out of the background more easily, and thus more easily correlate the signals from both ears. You get a much more accurate location just from hearing that sound than you ever could with a pure tone.
Interesting! I also feel the pulse is just to short… starting to question yourself if you actually heard something or that you are imagining it. Here the cars and trucks play musicals tunes or a crappy voice recording hahah
That makes sense; we were searching for a family member’s blood sugar monitor just today and it barely seemed to come from any single direction. Ultimately it wasn’t the sound itself but the loudness of it that let us find it, because a blanket got shoved over it mid-search that we could deduce from there.
Consider a pure sine wave, it's harder (in theory anyway) to match the signals from the left and right ears, and identify the time delay between the two signals: each cycle of the wave is just like the others, so there's no distinct signature to match and say "the sound reached the left ear 0.5 ms before it reached the right ear". This is especially the case for higher frequencies where there can be something like aliasing.

Animal species sometimes use this in different sounds they make. An alarm call has that kind of "smooth tone" characteristic, so a predator can't locate the source of the sound but it still works to raise the alarm. Meanwhile more social sounds are more "chirpy" and sharp, so they can locate each other.

I think some people are immune to beeps. My wife drives a Suzuki Crossbee and the fucking thing beeps every 10s for some alert or another. It drives me insane but she doesn’t notice it at all.

Examples

- beep: curve coming up ahead in X metres

- beep: curve coming up

- beep beep beep (too close to lane divider)

- beep: the speed limit is X

- beep: you’re speeding (no, I’m transitioning from a 60kmh to 40kmh section)

- beep: gps directions

- beep: gps directions again in case you missed it

- beep: yes again, turn left here you idiot!

A friend of mine drove a... something-or-other that dinged every time you exceeded the speed limit by 10 or 15mph/kmh. He gave it a dingectomy after meeting his goal of driving home from work without the dinging ever stopping.
This is very humanizing. I like that.

Nicely done!

> Claude doesn’t have native audio input (yet), but it can run JavaScript and Python code that can analyze audio captured by a microphone.

LLMs can also do that with non-mic audio, btw. I had GLM (or was it qwen?) answer the question of "Why does the spotify version of the Metal Gear Rising" soundtrack sound so bad" - to great results.

Compared with the CD rips on archive.org, the noise floor was 27dB (!!!) higher, and, the whole thing was 10dB more compressed.

I cannot vouch for these specific numbers, but subtracting the good version from the bad one gave me a horrible delta wav file with lots to listen to, so there was definitely a _lot_ of difference.

It got the job done is what I want to say.

Wait, can you share the results?
Maybe I should try this.

I bought an album from Apple Music, it was “in flames - reroute to remain” an album I’m very fond of when growing up.

Turns out that the digital version just sounded like trash, it sounded very compressed, so I had to find a CD to rip.

Could be interesting to know how they butchered it.

That’s terrible. As an Apple Music subscriber, I’m now wondering if I’m not experiencing music as it should be. For new recordings that I’m not previously familiar with, I’ve attributed the bad sound quality to the source not being mixed and/or mastered correctly. Until now, I hadn’t considered that Apple might also be processing the audio files.

When you say “very compressed” are referring to the dynamic range or a low bit-rate? If it’s dynamic range, that would be somewhat ironic. The loudness wars resulted in remastered CDs from the 90s and 2000s having a reduced dynamic range compared to the original album release. Back in the good old days, many What.CD users valued rips from vinyl over CD re-issues for this reason.

> I didn't mention this in the article, but this isn't the first time my family has been driven almost spare by a mysterious, hard-to-track beep.

https://xkcd.com/3100/

Next step isto make an iphone app and robotic arm that throws it and catches it and uses the spinning motion of the phone to triangulate.

Then its solved.

The fun part about apartment living is the weird noise can be coming from a neighboring apartment you do not have access to or control to fix.
The worst one of those I've had is an intermittently vibrating phone resting on the hard floor of the apartment above me
> Our dog goes outside and hides in the lavender bush if a smoke alarm starts making a "I need a battery" noise.

Our three dogs are absolutely terrified of the Nest smoke alarm after I almost burned down my kitchen trying to make some copycat crunchwraps a few years ago. =P They're so afraid of the smoke alarm that the monthly "sound check" thing Nest performs makes them quiver and quake. We used to be able to delay the sound check through the Nest app, so we could have a chance to bring the dogs outside before it goes off, but Nest seems to have removed that functionality.

Great post. Many levels of interesting information. Any sense of how much this cost?
I spend $200/month on an Anthropic subscription which this all fit into easily, and I don't have a good estimate for the first part (in Claude Code Cloud with Opus 5.5), but the subsequent Fable 5.2 session on my laptop would have cost $31.04 at API prices (517.9k ctx / 331.4k out), according to `uvx agentsview serve`.
This article is about a weekend project and not a serious product, so what I'm saying below is not criticizing the author's approach — I'm making a point about something tangential.

The post touches on my biggest pet peeves about how many software engineers currently use AI at work: they ask it to "write out a problems.md file describing the problem we want to solve" then lob the output over the fence for the rest of the engineering org to review, often times without even disclosing they used AI to generate it (it's, of course, obvious).

AI can not do the reasoning for us; thinking that because it is great at writing code that works, the same applies to documents whose primary purpose is to demonstrate critical thinking, explore trade-offs, and reason through a problem is absurd.

In fact (or IMO?), this "problems.md" document is entirely unnecessary. In many cases, simply describing the issue and providing the relevant context is enough for AI to come up with a working solution.

AI can not do critical thinking (yet), so don't ask it to (and stop sending your fellow software engineers AI-slop RFCs).

Yeah, I wouldn't do this for code that I was expecting anyone else to review.

This is actually the first time I've told an agent to write out a "problems.md" document - it was an experiment to see if stating the problem provided decent results, as opposed to working directly on a spec.

It did seem to work well though. I was outsourcing as much judgement as possible to the model, and the model did a good job at making decisions that got me to my required end result.

In this case, the AI could do the reasoning for me. Opus 5.5 and Fable 5.2 are really good!

> In fact (or IMO?), this "problems.md" document is entirely unnecessary. In many cases, simply describing the issue and providing the relevant context is enough for AI to come up with a working solution.

I don't mean to respond to your 'professional work' scenario, but I find it quite useful to first let it draft a PLAN.md, even when "in many cases" it would one-shot some implementation without it. I mostly prompt it with a problem statement, "write a PLAN.md", "ask me any questions in prose and numbered", "don't start implementation until my say-so". The back-and-forth questions are often pretty significant to the final result, and I can (skim) review the plan and make other adjustments.

When you ask most models to write that plan, you see an extended thinking trace similar to implementation itself, but now all the decisions are made up front. If you one-shot it an implementation, those decisions are sprinkled all over the implementation phase, while half of it has been written and some architectural choices have already been locked in. I then frequently adjust that plan to end up (IMO) with a much better implementation, or much better suited to my situation, with less shortcuts.

I'm only here with a friendly tip for the designers of beeping devices: make sure to gradually ramp high-pitched beeps up and down, so that there's no sharp edge that an adversary could time.
You can time the envelope of the ramp, though
Not with any kind of precision if the slope is gentle and you're using random commodity devices with different frequency response, automatic gain control, etc.
Thanks, Vetinaris clockmaker.
You joke, but birds' alarm calls are usually fairly spectrally simple for exactly this reason: simple monotone sounds (or those with a very gradual frequency slide) with soft edges are hard for predators to locate while still communicating meaning to other prey animals.

On the other hand, warning calls are often spectrally complex. Think of a cat's hiss: it's nearly white noise, one of the easiest sounds to locate. By telling another animal exactly where you are, you project your confidence that you're able to win a fight.

Why didn't you time the interval between the beeps? Then when the next beep was coming up, just listen to a particular part of the room or set of boxes until you found it.
This is the problem with technology. Some people just want to use it, so it's quite hard to tell whether this is really a quality of life improvement, or if it's just exciting for some weirdo (any programmer counts as weirdo here).

I've personally had to track down a beep before and used a similar technique as you suggest: time the beeps then be in right place to perform a kind of binary search to home in on it. I found a smoke alarm in the roof space above my flat, nailed to the top of the rafters that had been there since the building was built 20 years prior. It was annoying but I'm sure it took way less time and effort than "getting AI to do it".

This is also why it's been difficult for me to decide on portfolio projects to build. I just don't have anything I really need to build. I made a compound interest calculator as my first React app, but could have made an excel sheet or python script.
I use a frustration threshold. A lot of times, I’ve got a working solution, but it’s not “right”, so when that become frustrating enough, I build something.

A few examples

dotnet does not work on OpenBSD, so to run jellyfin (supported by the infuse app on the apple tv), I have to run Linux. I wonder if I can replicate the API somehow

calibre is quite nice, but I don’t use much of its capabilities. I could try to make a simpler system for my use cases.

And so on.

Yup! This is fun and cool, but the OBVIOUS solution is "just unpack." You need to do that anyway, and life is giving you motivation.
I mean, yeah, that was the joke.

I spelled it out a bit more on Bluesky etc:

> There is a mysterious intermittent beep coming from somewhere in your room of unopened boxes. Do you:

> 1. Open the boxes methodically one by one until you find it

> 2. Vibe code software that lets you set up two laptops, two iPads and a phone in various points around the room to triangulate it

https://bsky.app/profile/simonwillison.net/post/3mzvuqd4ndk2...

whynotboth.jpg

... your awesome vibecoded project has now told you what to unpack first.

Not related to the beep but if you still have natural gas (guessing based on the old carbon monoxide detector) you likely also want to get a simple plugin alarm that also detects natural gas in its natural un burned state.

Carbon monoxide is only produced when it's burned and builds up. And is obviously very dangerous. But a small gas leak building up over time or an oven pilot out and left on is not great for you either.

Make sure you place it relatively near the ceiling as it pools up there apparently. Saved my life during Covid lockdowns

There was a post on HN recently about a suspended string robot, and how it could manage different loads (picking up dirty laundry) depending on on where it was in the room.

https://neufangled.com/payload

Simon’s microphone configuration is very similar except instead of payload kg it would be affecting detection accuracy.

I wonder why the accuracy was an OOM outside the expected result (40cm vs 7mm)? Also using claps for calibration of unknown devices feels like a different approach to measuring distances between devices with a tape and solving the polygon. How many devices would be needed to self calibrate — 1x beep and Nx listening — instead of relying on smudgy claps? Or maybe every sound is smudged in a room filled with boxes?

What I'd like to know is: did it make you feel good? Did you get a sense of satisfaction at having solved a problem? Do you feel more stronger and more capable than you were before?

What I've been finding is just setting AI loose like this doesn't give me any of that. I've decided not to think, so I don't feel any struggle. No struggle means no relief, no feeling of accomplishment. I also don't learn anything because AI read the paper for me. Learning is what I live for.

It makes me feel great!

There is no world in which I would have spent the days (more likely weeks) necessary to learn enough about audio analysis in both JavaScript and Python and the WebAudio APIs necessary to build this thing, just to help me identify an annoying beep.

Thanks to coding agents, I got to build a wildly ambitious system that still taught me a bunch of interesting things about audio analysis and network web application design, all in about an hour and a half of clock time.

The alternative wasn't learning those things at increased detail, it was not learning anything about them at all.

And I added more tools to my tool belt for the future. I now know that it's possible to measure distances to sounds using cheap devices over a network, and I've got code in a GitHub repository that shows exactly how to do that.

The trick where the server could inject additional JS modules into the clients without needing to refresh the page (and hence lose the microphone permission) was neat, too.

Well, I envy you, I guess.

I don't believe you learnt anything to any appreciable depth in 1.5 hours. I guess you learnt what's possible, but not much more. I get it, learning is learning and you got 1.5 hours' worth. Fair enough.

The bit I struggle with, though, is celebrating things being easy. I'm not excited by easy things. I like hard things. It's a bit like reading an account of how easy it was doing the Alpe d'Huez in a car. I'm more excited by people cycling up it because I know how difficult that is, or building the car. But driving it? Meh.

I do wonder if I'm descended from the people who built Stonehenge. I get restless if things are too easy. I need something hard, like erecting huge stones. But damn it's been nice being able to get that kind of satisfaction just sitting at a desk.

Surely it matters that you can choose the things you want to be hard. Practicing guitar is hard, but I choose to do it, because I want to be better at that specific thing and the journey is the point. But not everything we do is like that. I don't want paying my bills to be hard.
Those things you don't want to be hard are chores. Software wasn't a chore for me; I enjoyed it. I play guitar too, I'm really glad I have another hobby that isn't programming actually. I guess it would be like if I could get programmed like Neo in The Matrix, I say "I know guitar" and suddenly I'm Jimmy Page. I wouldn't bother. Anyone could do it so it would be pointless to play. That's how I feel about programming now.
Yeah fair enough. I thought I had successfully avoided the management track my entire career, and here I am, a session manager.
Yup, this is the same "learning" as passively watching a 3blue1brown video and thinking you've mastered Fourier transforms or something.
No, it's more active than that.

It's closer to sitting in a lecture and actively asking questions, then discussing the material with others in the room (but still skipping the homework).

I would recommend updating your mindset.

Going through life angry that things that once were hard and are now easy go directly against why we are doing the hard things.

To your example. Building Stonehenge was HARD back in 3000BC. Now, a guy and some hydraulic tools could do it as a weekend project.

LLMs have made "hard" (but previously solved) problems "easy". And it opens up a large window of new hard problems.