Skip to main content
  1. Blog/

Detecting the Popping of Microwave Popcorn

·790 words·4 mins

I was watching an older Technology Connections video called “What’s the deal with the popcorn button?” and went down a small rabbit hole. I learned that microwave ovens sometimes have moisture sensors, and some even use lookup tables together with the moisture to guess what kind of food you’ve put inside and stop according to that. What caught my attention was that some microwaves also include a microphone. That made me wonder: if there’s a microphone inside and I have access to it, how would I detect the sound of popcorn popping?

The experiment
#

Each popcorn pop is a small, sharp sound, a transient. The background, on the other hand, is mostly a steady hum from the microwave’s fan and transformer. So if you record the audio, you can think of the problem as separating two components: a steady background and a sequence of short bursts. I have a store bought popcorn that we use at home. From previous trial and errors, It takes about 2 minutes to go through the bag without burning any kernels. At the end of the 2 minutes, the pops continue for a few seconds more.

So I recorded audio on a android phone, converted it wave file in audacity. I Initially wanted to do the analysis in audacity itself, but decided to do it inside python using librosa library for more flexibility. Here is the signal:

Recorded signal

I filtered out the low-frequency hum, built a noise profile from the first 40 seconds (when nothing much happens), and then subtracted it from the rest of the recording. What remained were spikes of energy that correspond to individual pops. By setting a threshold slightly above the background level, the script can pick out the timing of each pop. From this one recording, using a 1-frame smoothing window, I detected around 188 events. But it’s pretty clear that some pops overlap, the bag sometimes bursts two or three kernels at once.

Onset strength with threshold and pops
#

Onset strength with detected pops
Onset strength with detected pops

What it shows:

  • Onset strength envelope over time (a measure of how sudden the audio changes are)
  • Horizontal dashed line is the adaptive threshold computed from the baseline. Peaks above the threshold are counted as events
  • Peak height is a proxy for loudness or overlapping pops.
  • Red dots are peaks above threshold, interpreted as pops.
  • The peak close to 2 minutes might be when the bag opened up ?
  • First 40 odd seconds, everything inside the bag is getting hot, the dense high peaks afterwards mean rapid popping; sparse low peaks mean the cycle is finishing

Waveform with detected pops
#

Waveform with detected pops
Waveform with detected pops

What it shows:

  • Time domain waveform of the denoised, band-passed recording
  • Red crosses at times where the detector found transient events that look like pops
  • Each marker is one detected event after debouncing and ignoring early seconds
Estimating the number of kernels in the bag
#

If each pop represented a single kernel, that would be far too few. A 100 g bag of microwave popcorn typically has a composition something like this: 79.5% popcorn, 2.5% salt and rest is oil, air and the bag. That means about 79.5 g of popcorn itself in the 100 grams. With individual kernel masses ranging from 0.112 g to 0.172 g, the estimated kernel count looks something like this:

  • Lower bound (heaviest kernels): 462 kernels
  • Upper bound (lightest kernels): 710 kernels
  • Uniform-mean estimate: 560 kernels

Other sources from the internet suggest that typical microwave popcorn bags contain around 400-600 kernels, and one specific count found 437. About 5% of kernels are not known to explode, that is about 20-25. So if my detection algorithm saw 188 “pops,” that probably means there were many double or triple pops and something like 200 more pops probably hiding inside the double or more pops. The numbers are close enough that our simple kernel-mass model makes sense, one detected event doesn’t necessarily equal one kernel.

How a microwave might do it
#

A microphone-based system inside a microwave could work in almost the same way. It would listen for sharp changes in sound level and track the rate of popping over time. When the rate begins to slow down say, when the time between pops exceeds a certain threshold, the controller could infer that the popcorn is mostly done and shut off the magnetron.

Technology Connections explains that “the popcorn people put a purportedly proper popcorn preparation primer on every package of popcorn, which usually involves listening for a gap of two seconds between pops to signal it’s done.”

It’s a nice example of simple acoustic sensing and signal processing. Here is the complete video if you are interested: What’s the deal with the popcorn button?