function y = sourceA()

T = 2;
fs = 44100;
ns = T*fs;
x = randn(1,ns);
nc = 360/5;           %number of chunks- every 5 degrees
sc = ns/nc;           %size of chunks


index = 1;
for i=1:nc
    for j=1:sc
        chunk_right(i,j) = x(index);
        index=index+1;
    end
end
chunk_left = chunk_right;

index = 1;
for i=0:5:355
    if i < 10
        L_angle = sprintf('L0e00%da.wav', i);
        R_angle = sprintf('R0e00%da.wav', i);
    elseif i < 100 
        L_angle = sprintf('L0e0%da.wav', i);
        R_angle = sprintf('R0e0%da.wav', i);
    else
        L_angle = sprintf('L0e%da.wav', i);
        R_angle = sprintf('R0e%da.wav', i);
    end
        
    hr = wavread(R_angle);
    hl = wavread(L_angle);
    r = chunk_right(index,:);
    l = chunk_left(index,:);
    
    c_right(index,:) = conv(hr,r);
    c_left(index,:) = conv(hl,l);
    
    index = index+1;
end

h = length(hl)-1;
y_right = zeros(1, (ns+h));
y_left = y_right;

index = 1;
for i=1:sc
    y_right(index) = c_right(1,i);
    y_left(index) = c_left(1,i);
    index=index+1;
end

for i=2:nc
    for j=1:sc
        if j<h
            y_right(index) = c_right(i,j) + c_right((i-1),(sc+j));
            y_left(index) = c_left(i,j) + c_left((i-1),(sc+j));
        else
            y_right(index) = c_right(i,j);
            y_left(index) = c_left(i,j); 
        end
        index=index+1;
    end
end

y = [y_left ; y_right];
y = [ y y ];
y = y.';

wavwrite(y, fs, 'sourceA.wav');

