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

84 visualizaciones (últimos 30 días)
Wade
Wade el 25 de Oct. de 2025 a las 10:14
Comentada: Star Strider hace alrededor de 5 horas
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!
  2 comentarios
dpb
dpb el 25 de Oct. de 2025 a las 15:42
Which toolboxes do you have available to use?
Walter Roberson
Walter Roberson el 25 de Oct. de 2025 a las 18:32
I recommend using the third-party Psychtoolbox for this kind of work.

Iniciar sesión para comentar.

Respuestas (2)

Star Strider
Star Strider el 25 de Oct. de 2025 a las 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.
  13 comentarios
Wade
Wade hace alrededor de 6 horas
Since you've separated the audio into three different signal fragments according to their frequency, I wonder if there is a way to play each of them so that I can doublecheck which is which.
Star Strider
Star Strider hace alrededor de 5 horas
You would have to run my code to separate the signals, do the filtering, and then listen to each one separately.
This only works with Google Chrome with MATLAB Online (I will not use Google Chrome), so I ran it on my desktop instead.
This works --
wavfile = websave('sample-1.zip','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1842543/sample-1.zip')
UZ = unzip(wavfile)
[s,Fs] = audioread(UZ{1});
L = size(s,1)
t = linspace(0, L-1, L).'/Fs;
s500 = bandpass(s(:,1), [250 750], Fs, ImpulseResponse='iir');
s2000 = bandpass(s(:,1), [1900 2100], Fs, ImpulseResponse='iir');
s2500 = bandpass(s(:,1), [2600 2700], Fs, ImpulseResponse='iir');
% sound(s500, Fs) % Voice
% sound(s2000, Fs) % Squeak
% sound(s2500, Fs) % Squeak
That should work as written. (I just tested it.) I commented -out the sound calls. When you run that, un-ciomment them one at a time to listen to that particular vector.
The two that I labelled 'Squeak' sound similar to me, although they are obviously different in the pspectrum 'spectrogram' plot (they are not much different in frequency). I do not recognize much in the 'Voice' vector.
I also experimented with several different ways of finding the envelope (using a lowpass filter) and of finding the beginning of the signal (finding the peak and then finding the last lowest value of the preceeding 10E+3 index range). None of those worked satisfactorally because of the noise in the signal.
These data are extremely difficult to work with, largely because I rarely work with speech signals, only with signals from various sorts of biomedical instrumentation.
.

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 26 de Oct. de 2025 a las 19:28
  1 comentario
Wade
Wade hace alrededor de 10 horas
Hi Walter,
Thanks for the answer. Could you please show me how to use one of these functions please?

Iniciar sesión para comentar.

Categorías

Más información sobre Measurements and Spatial Audio en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by