0

in Matlab I am able to clip/trim pairs of audio signals (same frequency) using finddelay as follows, so that they are aligned and have the same length:

d12 = finddelay(s1,s2);
if(d12 < 1)
    start1  = -d12+1;
    start2  = 1;
    end1    = length(s1);
    end2    = min(length(s1(-d12+1:end)), length(s2));
else
    start1  = 1;
    start2  = d12+1;
    end1    = min(length(s2(d12+1:end)), length(s1));
    end2    = length(s2);
end

clipped_s1 = s1(start1:end1);
clipped_s2 = s2(start2:end2);

I would like to do the same with 3 signals or more, so far I was trying to take start/end bounds for pairs of signals, i.e. d12, d23, d31, and then taking the max for the start index and the min for the end index of the corresponding indices. However, it does not give me equal bounds for s1, s2, s3, I am fundamentally misunderstanding something. Anyone has any advice?

1 Answers1

0

So first I made a mistake, it seems, for 2 signals it should be

d12 = finddelay(t1,t2);
if(d12 < 1)
    start1  = -d12+1;
    start2  = 1;
    len1    = min(length(t1) - start1, length(t2) - start2);
    len2    = min(length(t1) - start1, length(t2) - start2);
    end1    = start1 + len1;
    end2    = start2 + len2;
    %note the suffling of +/- 1
else
    start1  = 1;
    start2  = d12+1;
    len1    = min(length(t1) - start1, length(t2) - start2);
    len2    = min(length(t1) - start1, length(t2) - start2);
    end1    = start1 + len1;
    end2    = start2 + len2;
    %note the suffling of +/- 1
end

Then, to clip 3 signals, first clip s1 with s2, then s2 with s3, then maybe s3 with s1 and so on. alignment of 3 signals