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

34 visualizzazioni (ultimi 30 giorni)
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!

Risposte (2)

Star Strider
Star Strider il 25 Ott 2025 alle 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.
  2 Commenti
Wade
Wade circa 23 ore fa
Modificato: Wade circa 23 ore fa
Hi there,
Thank you so much for your answer. If I made it right of your words, I should find the peak of the beep sound and the response voice, and then extract the length between the two peaks. I have no question on the former as the beep sounds are identical and have the same frequency, envelope etc. But I wonder if it can apply to the response voice signal, which may vary hugely and have different peaks. For example, if a participant offered an answer first and then immediately corrected that answer with louder voice and higher frequency, the peak should fall on the latter part of the voice segment. But in that instance what I want to obtain is the distance between the beep peak and the first part of the voice segment, because it was his first utterance that could manifest his reaction time. How should I solve this? Much appreciation!
Star Strider
Star Strider circa 20 ore fa
My pleasure!
I would not use the peak values, however you need to use the 'peak' option in your envelope call. If you want to know when the voice response begins, set a threshold and then determine the time the voice response envelope (I use the upper envelope here) first crosses that threshold.
Try something like this --
Fs = 44100; % Sampling Frequency (z)
L = 5;
t = linspace(0, Fs*L, Fs*L+1).'/Fs;
ts = seconds(t); % Time Vector ('duration' Here)
s = randn(size(t)) .* exp(-(t-2.2).^2*10); % Voice Response Signal
[et,eb] = envelope(s, 1000, 'peak'); % Use 'peak' Option
thrshld = 0.25; % Detection Threshold Value
tidx = find(diff(sign(et - thrshld))); % Approximate Indices of Threshold Crossing
idxrng = tidx(1)+[-1 0 1]; % Index Range For Interpolation
t_exact = interp1(et(idxrng), ts(idxrng), thrshld); % 'Exact" Value Of Upper Envelope Crossing Threshold Value
fprintf('\nResponse envelope crosses detection threshold level at %.3f seconds\n', seconds(t_exact))
Response envelope crosses detection threshold level at 1.690 seconds
figure
plot(ts, s, DisplayName='Response Signal')
hold on
plot(ts, [et eb], LineWidth=2, DisplayName="Envelope")
hold off
grid
xlabel("Time (s)")
ylabel("Amplitude")
yline(thrshld, '--k', "Detection Threshold", DisplayName='Detection Threshold')
xline(t_exact, '-.r', "Response Onset Time", DisplayName="Response Onset Time")
text(t_exact, 1.5, sprintf('%.3f s \\rightarrow',seconds(t_exact)), Horiz='right')
legend(Location='best')
.

Accedi per commentare.


Walter Roberson
Walter Roberson circa 13 ore fa

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by