You don’t have two ears by accident. [Stoppi] has a great post about this, along with a video you can see below. (The text is in German, but that’s what translation is for.) The point to having two ears is that you receive audio information from slightly different angles and distances in each ear and your amazing brain can deduce a lot of spatial information from that data.
For the Arduino demonstration, cheap microphone boards take the place of your ears. A servo motor points to the direction of sound. This would be a good gimmick for a Halloween prop or a noise-sensitive security camera.
Math-wise, if you know the speed of sound, the distance between the sensors, and a few other pieces of data, you wind up with a fairly simple trigonometry problem. In non-math terms, it is easy to get a feel for why this works. If the sound hits both microphones at once, it must be coming from straight ahead. If it hits the left microphone first, it must be closer to that microphone and vice versa. If the sound were right in line with both microphones but closer to the left, the time delay would be exactly due to the speed of sound over the distance between the sensors. If the time is less than that, the sound must be somewhere in between.
The microphone modules have both analog outputs and digital outputs. The digital output triggers if the sound level exceeds a limit set by a potentiometer. By using these modules, the circuit is trivial. Just an Arudino, the two modules, and the servo motor.
Now imagine that you wanted all this spatial detail to come through your headphones. Recording binaural audio is a thing. You can 3D print a virtual head if you are interested. We’ve seen projects for this several times.