from Hacker News

Fire alarm audio detection, using FFTs and Go

by pdubouilh on 4/7/24, 12:08 PM with 48 comments

  • by severino on 4/7/24, 10:24 PM

    I took a look at the source, as I was curious about how does one perform a FFT of a signal, but stumbled upon this. Could somebody explain to me what this calculation does? (in is the audio signal, if I'm not wrong)

      window := make([]float64, len(in))
      for i, x := range in {
          window[i] = float64(x) * (0.54 - 0.46*math.Cos(2*math.Pi*float64(i)/float64(len(in)-1)))
     
    Thanks
  • by bearbin on 4/7/24, 10:59 PM

    There's a physical product that implements the same idea [1]. I'm not sure how it actually works (presumably there's a patent somewhere, is there an alternative solution?) but it's quite a magic feeling to hear the fire alarm go off and the doors independently close by themselves. If you're in a building that uses these, you can test yourself by playing a recorded fire alarm sound - they work on quite a few different ones (and it really doesn't have to be that loud!). They also have a surprisingly long battery life, ~10 years I think so the detection mustn't take much power at all.

    [1]: https://www.fireco.uk/products/sound-activated/dorgard/

  • by asdefghyk on 4/7/24, 9:12 PM

    Is there sample audio of the fire alarm, when it is activated? Is this alarms to US standards ? It seems so, It seems different countries have some different requirements for this audio sound? ...... There is also commercial fire alarms and residential smoke alarms. which in my country have different signals ( if my recollection is corrct )
  • by yesimahuman on 4/7/24, 6:55 PM

    Funny, I was just thinking about building something like this since I bought a z-wave smoke alarm listener and it does not work with my first alert system and it really annoys me. It can't be that hard, right? Even something that just detects extremely loud sounds would be useful despite false positives
  • by xchip on 4/7/24, 7:57 PM

    you dont need a FFT you can use a Goertzel band pass filter
  • by animex on 4/7/24, 8:02 PM

    My Wyze cam does this with the included functionality. I get a text/notification when it detects the alarm. However, it does get fooled by certain sounds from the TV.
  • by asdefghyk on 4/7/24, 9:59 PM

    It is also quite useful to know exactly which alarm triggered. It would seem it is not feasible to have a DIY system to implement this
  • by a-dub on 4/7/24, 7:53 PM

    bandpass filtering in the time domain seems like it may be more efficient for this use case to me. if i'm reading the code correctly, it seems it's computing a 512 point window and fft on every non-overlapping window.

    i guess it depends on what vector/matrix instructions are being used in the underlying implementations.

  • by beefnugs on 4/7/24, 7:16 PM

    Just solder a wire in there somewhere. Even if you knew absolutely nothing about electronics, 50 trial and error solder points sounds like less work.