How can I extract the time length (in miliseconds) between two audio signals?

41 views (last 30 days)
I have a psychology experiment paradigm which asks participants to give a verbal response immediately after they hear a beep sound. Participants may or may not respond to the beep, and their response could be quick or slow. I need to extract the time length between the end of the beep sound and the start of their verbal response. Such time length should be measured in miliseconds as the total time allowed for each response was 3 seconds (3000 ms). There are hundreds of trials so I would like to find a way to do the extraction automatically. How should I achieve this? Carload thanks to any suggestions!

Answers (2)

Star Strider
Star Strider on 25 Oct 2025 at 18:06
Considering the nature of this problem, probably the best option is to estimate the signal envelops with the Signal Processing Toolbox envelope function (use the 'peak' option with an appropriate window), decide on a threshold, and measure the time the envelope crosses the threshold.
It may be necessary to use a filter to eliminate noise. If you are using the lowpass function (or any of its friends) for this, use the ImpulseResponse='iir' name-value pair for best results.
This approach as worked for me in the past.
It will probably be necessary to experiment to get the result you want.
  4 Comments
Wade
Wade about 2 hours ago
Thanks a lot for the reply! I can roughly make sense of your codes. But I have 3 questions:
  1. How should I determine the threshold?
  2. 1.690s is the result in a window that starts from 0s as the beep onset, but if another beep falls on a non-zero position on the X-axis, will the codes return a time index or the actual duration length?
  3. Do I need to do some pre-preprocessing to remove noise? If yes how should I do that?
As a complete layman of audio signal processing, please forgive me if any of these questions looks stupid to you :)
Star Strider
Star Strider about 1 hour ago
My pleasure!
  1. I defined the threshold empirically here. There is usually some noise, even in a filtered signal, so the threshold needs to be greater than that value. Beyond that, the lowest value that gives the best results (the fastest time) would be best. I doubt that there is a mathematical way to determine the best threshold.
  2. I do not fully understand your experiment. My code measures the time to voice response onset from the beginning of a specific record. It has no idea where the beeps are, so it simply returns the time to the voice response. (This is a simple example, and it could be made as comprehensive as necessary to give you the result you want.) If the beeps are recorded in the same record as the voice response, and all the beeps have the same frequency characteristics (ideally a single frequency), it would be relatively straightforward to separate them from the voice response and compute the times of the beeps and the time of the voice response separately. I would need representative data to explore this.
  3. I do not have a sample of your signal, so I cannot determine the noise characteristics. I usually use a Fourier transform of a signal to design the filter cutoffs, and determine the sort of filter I want (usually lowpass or bandpass).
I do not consider any questions to be 'stupid'! I will do my best to answer any that you have.
.

Sign in to comment.


Walter Roberson
Walter Roberson about 3 hours ago

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!