How to obtain the exact onset of a sound?

4 views (last 30 days)
Hello!
I am presenting a sound using the function 'soundsc'. I want to send a marker exactly when the sound starts. I was using 'GetSecs' just after the 'soundsc' function to get the onset of the stimuli. Would that be accurate enough? If not, how could I now the exact onset of my sound?
Thank you in advance!

Accepted Answer

Image Analyst
Image Analyst on 19 Dec 2020
Why can't you just read the sound and find when the magnitude exceeds a threshold that you think is required for it to be audible. Like if your sound amplitude ranges from -1 to 1, and you think the value needs to be more than 0.05 to be audible, just do
[y, fs] = audioread(filename);
startingIndex = find(abs(y) > 0.05, 1, 'first');

More Answers (0)

Community Treasure Hunt

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

Start Hunting!