# How quickly could a cyborg determine that a bullet has been fired from the sound alone?

L.Dutch made a worthwhile observation in an answer to a different question:

Moreover for close range shots there is almost no time to react and move the limb: for a shot fired at 20 m, with a speed of 200 m/s, you have only 0.1 s to have the limb in place to protect you (if you see the gun pointed at you) or even less if you have to react to the sound of the shot being fired (which reaches you at about 300 m/s).

Suppose our intrepid cyborg is not visually aware of the shot being fired. (Basically, it's "looking in another direction", whatever "looking" means for it.) Its first indication of the possible danger is when the leading edge of the shock wave from the bullet being fired reaches it at the speed of sound, approximately 300 m/s. If the shot is aimed at the cyborg and the bullet is either subsonic or supersonic, the shock wave is closely followed by the bullet itself, which is of course a problem; however, if the bullet is going in some other direction, then the cyborg will be able to detect the fact that a shot has been fired and remain operational.

For an alternative scenario, since lots of people have argued that the speed of the bullet is too low, you may freely choose to consider the following scenario instead: A person stands next to our intrepid cyborg, with both facing the same direction. The person fires the weapon along their mutual line of sight, such that the trajectory of the bullet takes it away from both of them. The cyborg does not visually observe the shot being fired.

Here, we aren't interested in actually dodging the bullet or really doing much of anything with the information, but rather only the processing that goes into determining the fact that a shot has been fired at all with a reasonable false positive rate (no claiming "shots fired!" when someone slams a door shut). To put this in software acceptance criteria terms, the cyborg only needs to set a single bit in a fixed memory location somewhere once a shot fired condition is detected; the time to do this particular write to memory can safely be approximated as instantaneous.

How long would the cyborg at a minimum need to, based on auditory cues alone and with a reasonable false positive rate, determine that a shot has been fired in its vicinity?

You may assume that the cyborg is able to fully process all audio input in real time, with no lag.

I have a feeling that Nyquist and Shannon are working against us here, but I don't know to what extent.

• most firearms i know of have muzzle velocities between 380m/s and 760 m/s. At those speeds, the first thing the cyborg notices is the impact of the bullet. The sound arrives later. Commented Apr 11, 2017 at 7:21
• @Burki my first thought: bullet arrives before sound. But the bullet may miss, or be aimed at something else, or be stopped by armour, in which case locating where it was shot from would be extremely valuable. BTW I have read about extant military hardware which can triangulate the origin of mortar or artillery fire. Locating the source of bullets may already have been solved, or if not, it is not a very big stretch. Commented Apr 11, 2017 at 10:14
• Relevant: shotspotter.com an acoustic gunshot detection and location system already in use by 80 law enforcement agencies in the US. Commented Apr 11, 2017 at 10:18
• @nigel222 if the bullet misses, it's velocity is irrelevant, and only the speed of sound and the distance matter. Since the referenced question was about dodging a bullet, and the velocity is given, i find it safe to assume the bullet is aimed at the cyborg in question. Yet it is only an assumption. Commented Apr 11, 2017 at 11:10
• Note that 200 m/s is a very, very slow bullet. Commented Apr 11, 2017 at 14:35

Disclosure: we (Sound Intelligence) sell this exact product.

The problem is not detecting a loud noise. That's actually quite easy. But the vast majority of loud noises aren't gunshots. Is your android going to duck every time a door is closed?

Another answer quoted 120 dB. That's at the standard measurement distance of 1 meter. Guess what? At that distance, you're dead anyway. We can safely ignore it.

So we're dealing with a gunshot 'sound that's not only attenuated by distance, but also we have reflections from the ground and walls. This will smear out the peak and make it a bit longer. It's still a pretty unique signature, especially if you are in a stationary environment. You can see how the sound decays, and compare it to the normal environment.

Other noises may be not as loud as a gunshot, but by being closer they end up at the same dB level at the microphone. Looking at the whole signature including reflections and decay, recognition becomes a lot easier.

So the practical answer is that we may need the full sound including several hundred milliseconds after the initial peak to distinguish it from perfectly normal sounds.

How much margin does that give us? Well, the bullet is traveling at about Mach 0.9, so the sounds leads by about 10%. Let's assume a shot fired from 100 meters away. That means the bullet arrives exactly 100 ms after the sounds - just enough to have a somewhat reliable detection, but not to react.

• "... just enough to have a somewhat reliable detection, but not to react" said no cyborg salesman ever. Commented Apr 12, 2017 at 15:45
• "The bullet is traveling at about Mach 0.9" Where did you get that from? The hypothetical 200m/s bullet in the question was traveling slower than mach 0.9, but such a bullet is not realistic anyway. For one, the bullet's speed is not constant, and two, if I recall correctly a bullet is likely to be going faster than mach 1 even once it reaches its target. Commented Apr 12, 2017 at 18:16
• @Aaron: Assumptions to see if it can work. Yes, bullets are usually supersonic until they hit, but there is in fact subsonic ammunition. That's still going to be high subsonic. Note that 200 m/s is Mach 0.7 or so. Commented Apr 13, 2017 at 7:10
• @L0j1k: it may still react fast enough for the second bullet, especially if the shooter is a human. That’s even useful if the robot itself is the target—you just need two robots… Commented Apr 13, 2017 at 11:49
• @L0j1k: The biggest problem being of course that it fails on supersonic bullets. Fixable in-universe by explaining that since androids armies have this feature so they can avenge their fallen comrades, which leads to the use of less noisy subsonic ammo and silencers. Of course that makes the sound detection a bit harder, but hey - we're assuming real AI. Even puny AI's from early 21st century can detect gunshots. (Yes, we do train AI's for that today, although they're hybrids between self-trained and expert-trained. ) Commented Apr 13, 2017 at 13:58

I think signal convolution between the sound and a prerecorded shot sound should suffice to determinate that is actually a shot (a trained human can easily separate shot from other sounds), and we admit that this computation is instantaneous. Thus, only the sound travel time must be taken into consideration.

The speed of sound at sea level and in ISA conditions (25°C, 1013.25 hPa, ...) is 340.29 m / s, thus the time to reach the cyborg "ear" is $$t = \frac{distance}{speed} = \frac{20}{340.29} = 0.058 s = 58ms$$

The main problem is that sentence

The shock wave, of course, is closely followed by the actual bullet itself.
is actually false. This is the problem when something has passed the sound barrier, the sound is behind the object. Thus, if your cyborg is shot, the bullet would reach them before any sound does. (In fact the shockwave created just on the tip of the bullet is ahead of the bullet and if you want to hear it you have to listen to the bullet tip... and you don't want to put your ear there).

• The bullet in this example is travelling at 200 m/s. I don't know how you reach the conclusion that an object travelling at 200 m/s is moving faster than the speed of sound, whether that's 300 m/s or 340 m/s or 340.29 m/s.
– user
Commented Apr 11, 2017 at 7:21
• @MichaelKjörling The shockwave word led me to think that something was passing the sound barrier. But now I realize you meant deflagration probably. The calculation stays the same, the sound would be a lot more suppressed, but still audible at 20m (especially by a cyborg). Commented Apr 11, 2017 at 7:27
• "I think signal convolution between the sound and a prerecorded shot sound suffice" - clearly you haven't actually tried this. It's got an astonishing low accuracy. As in, if you set the margins low enough t get a decent detection rate, you'll also detect pretty much every door closing. Commented Apr 11, 2017 at 12:08
• @MichaelKjörling if you are going science-based, you should first do a reality-check question about the bullet speed. Just doing a fiat on the bullet speed will waste all effort on being realistic on the sound detection. Commented Apr 11, 2017 at 12:29
• @MichaelKjörling The bullet in a different question, which was cited as inspiration for this question, was travelling at 200m/s. Since 200m/s is an unrealistic estimate, we might as well ignore it unless question states otherwise. We should assume the bullet is supersonic. Commented Apr 12, 2017 at 18:22

Let's assume the shot is fired at t=0.

The sound travel at about 340 m/s, therefore we have to rule out supersonic bullets, as they will hit the cyborg before it hears the shot.

For a subsonic shot, assuming the emitted sound spectrum is comparable with this one (source)

we have a peak frequency of 1 kHz, meaning that to have a complete oscillation of the pressure wave in the listening device of the cyborg we need at least 0.5 ms.

After this millisecond the cyborg has to locate the point from where the bullet is approaching. Proper triangulation would require 3 "ears" in different locations, if instead the cyborg has only 2 it will be able only to identify the line along which the bullet is travelling.

After having found the point of fire, the cyborg has to determine if the bullet is really approaching to hit, or if it was fired to another target.

• I hope the cyborg does not need a complete oscillation of a vibration to hear it. It would be a regression since a human can hear a little under or overpressure. Commented Apr 11, 2017 at 6:57
• @EngelOfChipolata I am afraid that just the pressure ramp up in the first quarter of a cycle would not be enough to generate a sound perception. Maybe half a cycle...
– L.Dutch
Commented Apr 11, 2017 at 7:27
• I don't think so, 120dB is huge, at 1kHz, most of people can hear about 20 dB SPL. So I think the cyborg can detect even less than the quarter of a period. Commented Apr 11, 2017 at 7:33
• I am not talking about the pressure level (measure by the dB), but abouth the pressure variation. If you don't have half a period (pressure increase and pressure decrease) how can you discriminate the 1 kHz sound from any other pressure change with lower frequency?
– L.Dutch
Commented Apr 11, 2017 at 7:45
• You're doing harmonic analysis here on a signal that's about as non-harmonic as it gets. This is entirely meaningless. Then again, you're quoting a chemical engineering journal ?! Commented Apr 11, 2017 at 12:14

To react to a sound compatible with a gunshot and assuming that it really is a shot and you're the target you can probably reckon on the dramatic increase in sound pressure being enough, but we could call it half a period of a 1 kHz wave, or 0.5 ms plus the distance divided by the speed of sound (propagation time) after the shot. The question is, is that enough to do anything, given that the bullet isn't far behind. Using metres and seconds from now on.

For a distance x and bullet speed v (assumed constant) we have a time t=0.0005 + x/340 - x/vin which to detect the sound and move out of the way.

If you imagine dropping all the way to the ground to dodge a bullet, with a cyborg that can essentially fold itself up instantaneously, you can consider that as a very first approximation to be falling half the cyborg's height -- lets say 1 metre -- based on the centre of mass. From the basic equations of motion we can find that it takes 1/sqrt(5) or 0.45 s to fall 1 metre. That would mean the reaction time is miniscule compared to the distance and difference in speeds and we can simplify, getting 340/v =1-(340*0.45)/x. For a 200m/s bullet that means a distance of around 220 m.

If your enemy always goes for headshots and you know you only need to duck the movement required drops to say 1/3 m and the time to around 0.25 s -- a distance of 120 m for your 200 m/s bullet

• Nice thought! But the cyborg might move sideways, too, in which case he might be able co accelerate quicker than 1g, provided his grip on the ground is good enough. Commented Apr 11, 2017 at 11:24
• @Burki or leaning on a wall with one superhuman hand -- but that's too many variables to consider here. The OP can build that in if a short range is implied by other elements of the story. Commented Apr 11, 2017 at 11:33
• "you can probably reckon on the dramatic increase in sound pressure being enough". Nope. There are far more sounds that have the same pattern. Quite a few percussion instruments have this characteristic. You'll get triggered all the time by music. Commented Apr 11, 2017 at 12:09
• @ChrisH: Annoyingly enough for us, speakers are a pretty bad way to fake gunshots. We'd like to use them to demo our product, but the problem is that a gunshot is created by creating several liters of (hot) smoke. A normal speaker can't move that much air that quickly. Now humans may say "that sounds believable to me", but human hearing is far from perfect. That's how MP3 compression can work; the computer calculates which parts are inaudible to puny humans. We can assume our android doesn't suffer from this. Commented Apr 11, 2017 at 13:00
• @ChrisH: Fireworks work pretty well, and are decently easy to source. Nailguns (as the name suggests) also sound like real guns. Commented Apr 11, 2017 at 13:16

A couple of things to add...

1. By definition, a supersonic bullet exceeds the speed of sound. If you are close enough, you will not hear it before it reaches your location, if it is fired in your direction. If it matters, most handgun ammunition is subsonic, while most rifle ammunition is supersonic.

Of course, a bullet will not remain supersonic at any distance, it will slow down over time. However, a bullet meant for long-distance shooting may not slow below supersonic for 1000 meters or so. (Technically, the bullet is the projectile, and the cartridge and charge of powder are important in how fast the bullet can be pushed, but I'm blurring those distinctions.)

2. There are two sounds associated with supersonic bullets: 1) the firing of the gun -- i.e. the powder "exploding" in the cartridge to propel the bullet down the barrel -- and 2) the shockwave from being supersonic. The shockwave follows closely behind the bullet, while the sound of the gun firing may be left farther behind. (It would not be unusual for a rifle bullet to be 2-3x the speed of sound.)

Quick Answer: Here's a really good paper on the subject. One graph in the paper indicates about 30 milliseconds for most of the audio -- muzzle blast through echoes -- to be received 9 meters from a rifle. Onto that, you'd add processing time, which I would guess would also be measured in the low milliseconds. The processing time should be fairly constant, and you could run multiple detectors -- optimized for different distances and directions of fire. The dominant times would be: a) how much of the 30 or so milliseconds your detector needs to see to make the call, and b) the distance of the gun from the cyborg -- depending on the direction of the fire.

My musings:

So it depends on the relationship of the cyborg to the bullet's path as to what it will hear. If the bullet is fired at or near the cyborg, and if the bullet it supersonic, the cyborg might first hear an impact -- though that would be hard to distinguish from other sounds -- followed by the shockwave from the bullet, followed by the "bang" of the gun, then echoes and reflections of the shockwave and the "bang".

If the bullet is subsonic, there will be no sonic crack, but if the bullet goes beyond the cyborg there may still be a fairly unique "zing" of a fast object flying by.

If the bullet is fired away from the cyborg, it will hear the "bang" first, then some of the sonic boom. And then a fair amount of reflections and echoes.

Loudness-wise, an unsurpressed rifle can be 160 dB very close by. (This is why suppressors or hearing protection are a big deal: percussive sounds like this will damage your hearing if greater than 140 dB. Remember that the dB scale is logarithmic.) Sound intensity falls off with the square of the distance, though if you're close there are probably not a lot of sounds in your city that are as loud as an unsuppressed gun, if only because of lawsuits for hearing damage.

Msalters' answer is fascinating. I imagine their product uses multiple sensors, spread out over city blocks, to triangulate the position of the shot. (Not an easy task due to reflections/echoes, etc.)

So, all that said, if you only intend for your cyborg to determine that a shot has been fired somewhere nearby, the time to detection would vary depending on whether the shot was fired towards or away from the cyborg (with supersonic bullets, at least). At an absolute minimum, if a supersonic bullet was fired at the cyborg, the shockwave would reach the cyborg in as little as 1/3 the time it would take the "bang" to propagate to the cyborg. At a maximum, the shot would be fired away from the cyborg and we'd have to wait for the "bang" at the speed of sound.

If you want to locate the shot, you would have to wait until multiple cyborgs hear the shot, and coordinate between themselves. (Or perhaps one cyborg that has a pretty long distance between its "ears", but echoes/reflections will still make it difficult.)

Actual recognition time is dominated by how much sound you need to hear to capture enough of a picture of the sound wave to try to identify it, followed by processing time. Considering you have cyborgs, I assume there is a lot of computing power, so that would add something on the order of a few milliseconds.

t of the sound of the shot (speed assumed as 300 m/s). It is the same as the shockwave.

To 'realize' the shot, there is a lag from when the sound is received by the sound sensor (or ear) to the processor (or brain), and the processing time deciphering and figuring out that the sound is indeed a gunshot. Both are ignored.

So, by assuming the distance is 20 m, then:

t1 = 20 / 300 = 0.067 s


That is the required time for the sound to reach the cyborg, if both input time and processing time is ignored.

Speaking about the question in bold, namely "how long a cyborg needs to spend to determine if the sound it receives is a gunshot" - this highly depends on whether that cyborg has microphones capable of receiving frequencies beyond human hearing range, whether it can process signals at the rate at least twice faster than maximum frequency that its microphones can register, and whether the exact spectra of all the guns are foreknown by it. The first parameter here is measurable, a short search returned that there are microphones that can register frequencies up to 500 kHz, the second is assumed to be "ideal" that is, all channels are captured somewhere without lag, and the third is assumed to be ideal without quotes, that is, as soon as the cyborg receives audio that's matched at least some high-frequency part of any gunshot sample, it says "Gunshot detected".

First, such a cyborg would be limited by DSP rate, even if there would be a ready-made FPGA to perform a FFT/FPT (there's a research that says gunshots are good candidates to run FPT together with FFT, this one ) that would do a moving FFT/FPT over enough samples to discern frequencies from 500 kHz down to another adjustable factor (named FL), FPGAs still do not return result values fast enough to say "almost instant", this kind of an FPGA would have to work on at least 1 MHz operating over no less than 256*500/FL samples of a microphone, the output delay can get big enough due to sheer path travelled by all the signals within the FPGA and all the time to shift triggers within it, etc etc, thus 1 MHz might even not be reached if FL is low enough, based on the current technology. Lowering the FL would allow for less false positives if a certain combination of high-frequency sounds would actually happen to appear without a gunshot being fired to trigger the recognizing circuit, raising it might hit a situation where in a certain gunshot pattern there will be 1 to 0 distinct high frequencies upon which to react, either invalidating the detection completely or triggering it by a single frequency peak. Also, I am not aware of gunshot patterns containing frequencies this high, but I assume they do because a gunshot is essentially a single impulse with diminishing Fourier spectre towards infinity. Assuming that 1 MHz DSP rate is actually reached, and FL set to low enough to avoid most false positives, the FPGA alone would produce a pattern matching a gunshot in 256M/FL microseconds. Say if FL is 125kHz, top frequency is 500kHz, and all the patterns contain enough data to detect a gunshot in this frequency interval, the FFT/FPT data of a heard gunshot will be ready in 1024 microseconds, or a little more than a millisecond.

(PS: this 256 is an arbitrary number that is also a subject to change, it can be changed to a power of 2, and depends on the incoming signal patterns, whether they align to FFT frequency values for a given sampling freq. I don't have any of these, especially for high-frequency region which would provide the earliest info about the gunshot which is sought here, so wherever 256 is read above, a lesser value could also fit, reducing resultant data flow downstream as well as reaction time, but increasing false positive rate. Afterwards I assume that 256 is the lowest value that, together with selected FL, provides acceptable false positive rate.)

Second, the signal has to be processed to match stored patterns. This can also be done with FPGAs, although they first have to operate over the same amount of data, and they have to do that fast enough so the data won't change while processing is performed. This requires a buffer of some kind in the cyborg's circuitry between the sampler/FFT/FPT and the matchers. This adds to latency, which mostly depends on how the buffer is organized, whether it can serve all the pattern matching FPGAs per cycle with the entire set of data (which for FFT is 4 bytes per frequency bin, and with a sample size of 1024 per above paragraph takes considerable amount of time to both be collected from FFT FPGA and get loaded into a receiving circuit over whatever data bus there would be) and should there be too many of those patterns per receiver, whether the matching circuit that wiuld prodice a detection would receive a sample fast enough. But, since the incoming data flow is constant at a rate of 1 matching sample per microsecond, and the lowest amount of matchers that a sample would be fed into is one, the resultant delay can be no more than 2+1*number of samples, in mincroseconds, where 2 contains 1 as the time to transfer data to the buffer, and another 1 for the matcher FPGA to produce a yes signal. The signal can actually share an analogue bus line (a wire) to send a logical 1 via diode to a single collector like a processor pin dedicated to an interrupt.

So, assuming current tech and some data about unavailable cyborg architecture and gunshot patterns with high frequency range, the minimum delay at which a cyborg could detect a known gunshot sound is no greater than 1026+samples, in microseconds, starting from the moment the gunshot's front sound wave reaches the cyborg's microphone(s). This value can be reduced by selecting less samples in FFT+FPT block, lowering the intermittent data size, optimizing data bus to make more matches per sampling cycle or probably advancing to better technology in making cyborgs.

The thing highly differs if a cyborg is required to detect an unknown gunshot, like one from a freshly made weapon, the solution would likely involve a trained neural network translated into a FPGA, if there could be an FPGA to contain the NN, and reaction times would most likely severely increase.

• What do all the abbreviations you use stand for? Commented Jul 14, 2022 at 9:23
• @Joachim FFT = Fast Fourier transformation, FPT = Fourier Phase transformation, DSP = Digital signal processing, FPGA = a chip that's designed to do a very special thing, most of these are configurable, NN = neural network, a software made to discern certain aspects in a signal, and FL means lowest frequency which we desire to detect in order to make the earliest possible detection. Commented Jul 14, 2022 at 9:27

Not only medium conditions but also type of firearm has to be taken into consideration: different firearmes produce different output spectrum at shot.

That being said the cyborg database could be filled with all the spectrum profiles of all the firearms in the world (way) OVERsampled to get for each weapon the most common one.

That being said, to identify a shot, a match should be done on the entire (as far as samplers can sample) spectrum width and not just one freq.

Now, still agreeing that we are looking for frequencies here, hence p variations and not levels, I anyway think that slightly more than a quarter period may suffice (for sure not less), that is the point where a full period, thus freq, evaluation can be made: if you know in how much time you reach the peek, you know how much the period is, 4x. This means we are looking for the lowest freq in the sampled spectrum, because its quarter period would the longest.

Of course this would require constant air pression monitoring to know where the 0 crossing is, to identify the first peek.

All this being said, because of the many variables involved, and the MANY more not mentioned (variation of base pressure before the first ramp, noise, and so forth...) I strongly doubt this would ever be possible with an impressive degree of correctness. Thus, if sometimes the cyborg would be positively identifing a shot and being able to somewhat react, the rest of the time the poor guy would just walk like a freak trying to avoid invisible bullets XD

AND all of this, in the kingdom of approximations of course

• Heisenberg inequality: how detailed should that spectrum be? Because you need that much samples in your input. You can't get a 32000 bins spectrum out of 20000 samples. In fact, because it's a real signal, your spectrum is mirrored. You can't get 32000 real bins out of 60000 samples. Commented Apr 11, 2017 at 13:05
• Next issue: "the" spectrum of a gun doesn't exist. It depends on too many variables. To name but a dumb one: the combination of bullets and gun matters. The combination of gun and silencer matters. Commented Apr 11, 2017 at 13:06
• Well of course I'm not posing limits in samplers fequency capabilities... We should go as far as the highest frequency is asking for, oversampling at need! Commented Apr 11, 2017 at 13:06
• It's not (just) the highest frequency, it's the difference in adjacent frequencies in your spectrum. You're not going to do much with a spectrum that just contains 4 values, 10000/30000/50000/70000 Hz even though the second frequency is already much higher than humans can hear. The bins are simply too side then. Commented Apr 11, 2017 at 13:09
• You don't get to pick those frequencies, that's the Heisenberg inequality. Not even physics or computing, those limits are pure math. Commented Apr 11, 2017 at 13:12