# Converting Audio of Paced breathing to plot

This is for a research project on meditation. A music-type person composed for me an audio for paced breathing, which consists of some undulating tones. I would like to convert it to a smooth function for data analysis, where I will compare the function to some laboratory measurements, like heart rate. Here is a link to the audio file: Here is my code.

audio = Audio[File["BPM 8.wav"]];
selectData = MovingAverage[selectData, 20020];
ListLinePlot[selectData, PlotRange -> All, AspectRatio -> 1/10]


Here is the result

If I increase the moving average window, it loses its features. If I decrease the window, the result obviously gets noisier. I can't seem to a get a smooth function that has the features of this very regular tone.

• hmm...what features do you want to extract? volume? pitch? If you take an average of a sound wave, you'll have a lot of cancellation in each of the pitch components (imagine the average of a sine wave over a long time). If you want to represent the volume, maybe take the root mean square over a certain window, or the maximum value over a certain window? But first you've got to decide on the abstract features you want before implementing them! :) Commented Dec 2, 2022 at 2:56
• I don't really care what feature I extract. I just want to correlate the audio with some laboratory measurements (HRV, if you've heard of that) in meditators. But anyway, after I posted the above question, I realized that I really need to take the absolute value of the data file. Your idea of the root mean squared is probably even better. So thanks for that! Commented Dec 2, 2022 at 22:34

I'd suggest looking at the Audio* functionality for maximum efficiency. I'd do something like:

a = Audio["/Users/carlogico/Downloads/BPM 8.wav"];

AudioPlot[a]
Spectrogram[a]

AudioLocalMeasurements[a, "RMSAmplitude",
PartitionGranularity -> {Quantity[0.2, "Seconds"],
Quantity[0.1, "Seconds"]}] // ListLinePlot


Some pages to look at:

• This looks like the answer I'm looking for. I will try to implement your suggestion in coming days, and if it works I'll remember to attribute the answer to you. thanks. Commented Dec 7, 2022 at 16:56