How can you tell whether there's a signal (when your signal looks a lot like noise)? This is my snoring detector again.
I've gotten pretty good at detecting a signal when there's anything there -- can track from a wall-peeling snore down to breathing you can't even hear in the recording.  The problem is, I can't tell when the signal has dropped below detectable level and the app is just &quot;hearing things&quot;.  And, unfortunately, snoring/breathing is often irregular enough that a simple autocorrelation or similar interval timing scheme is unlikely to help much.  (And it's actually likely that in some cases the noise is more regular than the breathing.)
So, are there any tricks I'm missing for figuring out when there is no signal?  It kind of seems that I'm up against a hard place here, given the &quot;signal&quot; is so noise-like to begin with.
(And maybe this is related to another problem I'm having:  Strangely, I can't accurately (or even approximately) measure the signal level even when fairly loud.  Since I need to use rolling averages and ratios to detect the signal anyway, the level information kind of gets lost.  I'm looking for some tricks to reconstitute it.)
Basic technique
(For Yoda)
The audio signal is sampled (generally at 8000Hz, for various reasons), then FFTed in 1024 blocks.  (In my experiments Hamming filters and overlapping blocks seem to have little effect, though those may be revisited later.)
The FFT is divided into &quot;bands&quot; (currently 5, slightly skewed in size to place more detail on the low end) and the &quot;spectral difference&quot; and level of each band is summed.  Long-term averages of the peak-limited values are used as &quot;thresholds&quot;, and further bias adjustments are used to maintain a roughly 20% &quot;over threshold&quot; rate.
Each &quot;over threshold&quot; value is given a weight of 1 (under threshold is given a weight of 0), but then that weight is adjusted by the apparent &quot;variability&quot; (at roughly 2Hz) in the band, to give more weight to bands that carry more apparent signal.
The weights of the bands are summed and then the summed weights of subsequent blocks are summed over about a second to produce a running &quot;score&quot;.  This is again compared to a running average threshold (plus several heuristics) to detect snore onset/offset.
Update
It suddenly occurred to me that if my algorithm effectively maintains a constant-level signal (per my signal level problem), the way to effectively gauge SNR is by measuring the noise when there's no signal.
Conveniently, snores are intermittent, with lots of &quot;dead air&quot; in-between.  And I'm already detecting the snore envelopes.  So anything outside of the envelope (between the end of one snore and the start of the next) is presumably noise!  This I can (with some modest degree of accuracy/repeatability) measure.  (It took three tries to come up with a halfway decent algorithm, of course -- reality never matches the theory.)
So I don't have the full answer yet, but I've made progress.
(While the above technique gives me a fairly good proxy for SNR, I'm still having trouble estimating actual signal level.  My &quot;relative level&quot; indications can be off the scale for a barely audible breath and so-so for a window rattler.  I need some sort of proxy for absolute level.)
So far you seemed to identify snoring through the presence of a strong periodic pattern in the audio. If you tell me that there might be other sources with the same property, it's time to move on and focus on a property of the signal more specific of snoring ; and I would suggest to look more precisely into the timbre of the recorded sound itself. Given that a human listener can tall apart snoring from breathing, you might resort to traditional audio signal classification approach. Compute features like MFCCs and Fluctuation patterns on your audio data, and train a bayesian classifier (or more sophisticated) to discriminate snoring from breathing.

It might be time also to review the literature on the topic... For example I found this: http://web.itu.edu.tr/kamasak/pubs/pdf/pm7_8_007.pdf