Calculating sound to silence ratio

Hi,

I’d like to keep some statistics of my sleeping habits and to see how loud I am (snoring, moving etc.) each night. I think a quick and easy way to get a number would be to somehow divide the time during which I’m making sounds by the time I am silent. I’ve been doing this manually but it’s become quite tiresome since the files are generally 7 to 8 hours long. The spectogram view is a nice way to “see” sounds, so somehow exporting the image and processing it might work as well.

Any suggestions on how to achieve this?
Thanks.

Linux version: Arch Linux x86_64 | 5.12.6-arch1-1
Audacity version: 2.4.1
Distribution release, installed via https://archlinux.org/packages/community/x86_64/audacity/

It always amazes me, the things people use Audacity for.
From analyzing bat sounds, to car tachometers to sleeping patterns.

Just goes to show how versatile Audacity can be.

As to your question, how about using the built in “Sound Finder” under the “Analyze” options.

I simulated some sounds using some white noise, a tone, a drum sound and some DTMF tones.
(In your case it would be …errr…snoring).

It looks like this:


Now, select the whole track and run the “Find Sounds” plugin, my settings were:
(You may have to change yours, depending on the level of your recording).

Screen Shot 2021-05-25 at 1.09.19 PM.png
You should now have another label track underneath your recording track, like so:


Now, export the label track.
It will be a tab delimited text file.
Change the extension from .txt to .csv and open it in Microsoft Excel or OpenOffice.
(If it asks you what delimiter to use, select spaces and tabs).

You should now see something like this:

Screen Shot 2021-05-25 at 1.12.19 PM.png

With some formulae, it should not be too hard to work out the stats you need.
Ratio of silence to noises (you know how long the recording is), period with most noises, most quiet period/s, etc.

Since you are more interested in the duration and amount of noises, rather than the noises themselves,
use a low sample rate when you record as it will make for smaller file sizes.

Hope it helps.
I’m sure others will add to this thread with other ideas.

So you wouldn’t be the first one to consider using Audacity to diagnose Sleep Apnea. Google says there are 1.4 million hits for the search “using audacity to study sleep apnea”. Sleep Apnea is much much more common than you might think.

A possible project for you Paul2: Create a Nyquist plug-in to calculate how much of a track is included in region labels as a % of the track length.


Hint:

(setf labels (second (first (aud-get-info "Labels"))))
(format nil "Number of labels: ~a" (length labels))

If you fancy trying this and need any help, start a new topic in the Nyquist Plug-ins forum. If you get it working, the plug-in can be posted here.

OK it’s a deal.

I didn’t even know that it was possible in Nyquist to do that.
It will certainly be good practice and can have a variety of uses.

New thread started here: