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

93 Ansichten (letzte 30 Tage)
Wade
Wade am 25 Okt. 2025 um 10:14
Kommentiert: Star Strider am 30 Okt. 2025 um 14:11
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 Kommentare
dpb
dpb am 25 Okt. 2025 um 15:42
Which toolboxes do you have available to use?
Walter Roberson
Walter Roberson am 25 Okt. 2025 um 18:32
I recommend using the third-party Psychtoolbox for this kind of work.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Star Strider
Star Strider am 25 Okt. 2025 um 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 Kommentare
Wade
Wade am 30 Okt. 2025 um 12:53
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 am 30 Okt. 2025 um 14:11
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.
.

Melden Sie sich an, um zu kommentieren.


Walter Roberson
Walter Roberson am 26 Okt. 2025 um 19:28
  1 Kommentar
Wade
Wade am 29 Okt. 2025 um 9:47
Hi Walter,
Thanks for the answer. Could you please show me how to use one of these functions please?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Measurements and Spatial Audio finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by