Live data from Hacker News

Fire alarm audio detection, using FFTs and Go

github.com

21–30 of 51 posts

Re: Fire alarm audio detection, using FFTs and Go

#21
post #8

you dont need a FFT you can use a Goertzel band pass filter

I was thinking the same.

From Wikipedia:

"The Goertzel algorithm is a technique in digital signal processing (DSP) for efficient evaluation of the individual terms of the discrete Fourier transform (DFT). It is useful in certain practical applications, such as recognition of dual-tone multi-frequency signaling (DTMF) tones produced by the push buttons of the keypad of a traditional analog telephone. The algorithm was first described by Gerald Goertzel in 1958." [0]

It's also a nice project for an ESP32 with a MEMS microphone.

[0] https://en.wikipedia.org/wiki/Goertzel_algorithm

Re: Fire alarm audio detection, using FFTs and Go

#22

Earlier quoted context omitted.

I'm also curious about the power draw of continuously executing FFTs on a rpi. Seems like the kind of task where one could easily burn 10 watts, if the wrong FFT Implementation is chosen. You'd absolutely want to do this in DSP hardware.

yeah using a DSP for this definitely makes more sense - but I'm lacking experience in the field. Same goes for using a discrete band-pass filter. This project is more of an attempt at "how can I build something in 2 hours that works reliably" ! For reference, it eats ~25% of the available CPU resources on my rpi zero 2w - which draws a maximum of 350mA, so this implementation definitely draws less than 1 watt.

Nice to see that it consumes barely any power. Looks like a fun and useful project!

Re: Fire alarm audio detection, using FFTs and Go

#23
post #21
post #8

you dont need a FFT you can use a Goertzel band pass filter

I was thinking the same. From Wikipedia: "The Goertzel algorithm is a technique in digital signal processing (DSP) for efficient evaluation of the individual terms of the discrete Fourier transform (DFT). It is useful in certain practical applications, such as recognition of dual-tone multi-frequency signaling (DTMF) tones produced by the push buttons of the keypad of a traditional analog telephone. The algorithm was…

Thanks for this, I'll toy with implementing that instead of a full FFT

Re: Fire alarm audio detection, using FFTs and Go

#24

Earlier quoted context omitted.

I'm also curious about the power draw of continuously executing FFTs on a rpi. Seems like the kind of task where one could easily burn 10 watts, if the wrong FFT Implementation is chosen. You'd absolutely want to do this in DSP hardware.

yeah using a DSP for this definitely makes more sense - but I'm lacking experience in the field. Same goes for using a discrete band-pass filter. This project is more of an attempt at "how can I build something in 2 hours that works reliably" ! For reference, it eats ~25% of the available CPU resources on my rpi zero 2w - which draws a maximum of 350mA, so this implementation definitely draws less than 1 watt.

yes and it's very cool! if you're interested in learning, i'd look into the filtering approach.

maybe could try pyfda and the filtering functions in scipy.signal to start playing around.

or if you have access to matlab it has some really excellent filter design tools.

regarding the hardware/dsp: many cpus include simd instructions these days, which basically are an interface to a hidden digital signal coprocessor. :)

Re: Fire alarm audio detection, using FFTs and Go

#26

Earlier quoted context omitted.

I'm also curious about the power draw of continuously executing FFTs on a rpi. Seems like the kind of task where one could easily burn 10 watts, if the wrong FFT Implementation is chosen. You'd absolutely want to do this in DSP hardware.

yeah using a DSP for this definitely makes more sense - but I'm lacking experience in the field. Same goes for using a discrete band-pass filter. This project is more of an attempt at "how can I build something in 2 hours that works reliably" ! For reference, it eats ~25% of the available CPU resources on my rpi zero 2w - which draws a maximum of 350mA, so this implementation definitely draws less than 1 watt.

1W of continuous power consumption is not great. To put it into perspective: that’s 1x24x365Wh, almost 9kWh per year. A kettle (1.8-2kW) can run for 4-5 hours for that amount of energy. If getting a kettle to boiling takes 5 minutes, that’s almost 50-60 kettles. That’s two month of boiling one kettle a day.

Re: Fire alarm audio detection, using FFTs and Go

#27
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

Re: Fire alarm audio detection, using FFTs and Go

#28

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

I didn't click the link yet, but one could easily DIY with a microcontroller at each alarm, picking up the alarm signal in some fashion or another.

Re: Fire alarm audio detection, using FFTs and Go

#29

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

It looks like a windowing function. Used to turn continuous data into segments of data for FFT processing. https://en.m.wikipedia.org/wiki/Window_function

Re: Fire alarm audio detection, using FFTs and Go

#30
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/

Post reply on HN