Match audio duration when joining multiple tracks

前端 未结 1 1004
暗喜
暗喜 2021-01-27 10:34

I have a program that combines audio tracks together, the current system I have is that I can write two audio tracks and make them play simultaneously. The problem I am having i

相关标签:
1条回答
  • 2021-01-27 10:56

    First of all don't use function name "length" as to define new variable, You will not be able to use it as function in the next statement. Second, when you play multiple tracks you want to be able to do some kind of sync in the beginning, so i added for you this option.

    The solution is this:

    s1=[ 0.5, 0.2, 0.2, 0.1 ];
    s2=[ 0.1, 0.4 ];
    
    s1_pad_delay=8; s1_pad_after=5;
    s2_pad_delay=4; s2_pad_after=3;
    
    s1_len=s1_pad_delay+length(s1)+s1_pad_after;
    s2_len=s2_pad_delay+length(s2)+s2_pad_after;
    mix_len=max(s1_len,s2_len);
    
    s1_padded=[ zeros(1,s1_pad_delay), s1, zeros(1,mix_len-length(s1)-s1_pad_delay) ];
    s2_padded=[ zeros(1,s2_pad_delay), s2, zeros(1,mix_len-length(s2)-s2_pad_delay) ];
    
    mix=s1_padded+s2_padded
    
    0 讨论(0)
提交回复
热议问题