You can use the dir
function to get a list of audio files in a specific directory, then loop through each file and use audioinfo
function to get the audio length in seconds.
Here's an example code snippet:
main.m467 chars15 lines
In the example above, we first specify the directory containing audio files using dir_path
variable. We then use dir
function to get a list of audio files in that directory using the pattern *.wav
. You can change this pattern to match the audio format you are using.
We then loop through each audio file in the directory using a for
loop. For each file, we use audioinfo
function to get the audio information and store the audio length in seconds in an array called audio_length_sec
.
Note that this code assumes all audio files in the directory have the same format and parameters. If this is not the case, you may need to check the audio information for each file to make sure they match.
gistlibby LogSnag