MATLAB: How to calculate the time duration of a .wav format voice signal?

audio signal processingMATLABsignal

voice signal is in .wav format and fs=44100 Hz.using 'sound' i played the signal and it would be of nearly 2 seconds. In my project, i want to discard the first 500ms and retain the next first second. how to trim the signal using matlab code . Thanks in advance..

Best Answer

This is a fairly straightforward calculation:
fs = 44100; % Sampling Rate (samples/sec)
tlen = 500E-3; % Time (sec)
length_to_cut = tlen * fs % Length = samples/sec * sec
length_to_cut =
22050
So to discard the first 500 milliseconds, discard the first 22050 samples (1:22050).