blocks audio signal into overlapping blocks > > @param x: audio signal (dimension length x 1) > @param iBlockLength: target block size > @param iHopLength: target hopsize > @param f_s: sample rate > > @retval x_b (dimension iNumOfBlocks x iBlockLength) > @retval t time stamps for blocks ======================================================================
0001 %blocks audio signal into overlapping blocks 0002 %> 0003 %> @param x: audio signal (dimension length x 1) 0004 %> @param iBlockLength: target block size 0005 %> @param iHopLength: target hopsize 0006 %> @param f_s: sample rate 0007 %> 0008 %> @retval x_b (dimension iNumOfBlocks x iBlockLength) 0009 %> @retval t time stamps for blocks 0010 % ====================================================================== 0011 function [x_b, t] = ToolBlockAudio(x, iBlockLength, iHopLength, f_s) 0012 0013 iNumBlocks = ceil(size(x, 1)/iHopLength ); 0014 0015 % time stamp vector 0016 t = (0:(iNumBlocks-1)) * iHopLength / f_s + iBlockLength/(2*f_s); 0017 0018 % pad with zeros just to make sure it runs for weird inputs, too 0019 xPadded = [x; zeros(iBlockLength+iHopLength, 1)]; 0020 0021 x_b = zeros(iNumBlocks, iBlockLength); 0022 0023 for n = 1:iNumBlocks 0024 x_b(n, :) = xPadded((n-1)*iHopLength+1:(n-1)*iHopLength+iBlockLength); 0025 end 0026 end