don't repeat loop until audio file finishes playing in matlab

You can use the audioread function in MATLAB to read the audio file and get the duration of the audio. Once you get the duration, you can use the pause function to pause the execution of the code until the audio is finished playing.

Here's an example:

main.m
% read the audio file
[y, Fs] = audioread('audio_file.wav');

% get the duration of the audio
duration = length(y) / Fs;

% play the audio
sound(y, Fs);

% wait for the audio to finish playing
pause(duration);

% do something else
disp('Finished playing the audio.');
268 chars
15 lines

This will play the audio file and then wait for it to finish playing before continuing with the rest of the code.

related categories

gistlibby LogSnag