Resampling audio file to first 10 sec of each minute

3 views (last 30 days)
Brendon Samuels
Brendon Samuels on 16 Jul 2019
Answered: David K. on 16 Jul 2019
I am writing a script to analyze a series of long audio recordings. Each file is about 10 minutes in duration, and I have many of these files as they are segments of hour-long recordings. The analysis I am trying to run is at the subsecond level: quantifying the frequency of a regular AM pulse (the heartbeat of a bird) and looking at how this frequency changes over time.
To run this analysis on the entire files is impractical and unnecessary. Instead, I am trying to figure out how to sample only the first 10 seconds from each minute in the recording. This will be somewhat lossy, but we don't expect the rate of the heartbeat to change much within a single minute. I'm not sure if this will require further segmenting each 10 min .wav file into a series of single 1 min .wav files, but would prefer to avoid this step if possible.
My question is: how do I tell the program to only analyze the first 10 seconds of each minute in an audio recording?
Many thanks for your help.

Answers (1)

David K.
David K. on 16 Jul 2019
There are many ways to do this depending on what exactly it is you want to do and how you want to do it. If you have already imported the files into matlab an easy way to split the data up is with knowledge of the sampling frequency. If you don't know that you can find it by total number of samples divided by exact time of the recording in seconds. Then 10 seconds of the song is 10*fs and if you wanted to loop through the file you could index the variables like this
for n = 0:9
song(n*60*fs : n*60*fs+10*fs)
If instead you are looking to read in less from an external file, .csv for example, then you may want to look at fseek to skip the parts you do not wish to bring in.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by