close all;clear all;clc
numTest = 50;               % Number of test samples
rt = linspace(0.2,0.8,numTest); % Random initializing the RT
for iter = 1:numTest        %     
x = 4.5 + rand();           % Random initializing the room dimension
y = 3.5 + rand();
z = 5.5 + rand();    
%File for generating data based on Room parameters
c = 340;                    % Sound velocity (m/s)
fs = 16000;                 % Sampling Frequency (Hz)
r = [2 1.5 2];              % Receiver position [x y z] (m)
s = [2 3.5 2];              % Source position [x y z] (m)
L = [x y z];                %Room dimensions [x y z] (m)
beta  = rt(iter);         % Reverberation time (s)
n = 2500;                   % Number of samples
l = 1;
%Generating the RIR
h = rir_generator(c, fs, r, s, L, beta, n);
h = transpose(h);
index = int8(1 + 120*rand());
if index < 10
    filename = sprintf('data/arctic_a000%d.wav',index);
elseif index < 100
    filename = sprintf('data/arctic_a00%d.wav',index);
else 
    filename = sprintf('data/arctic_a0%d.wav',index);
end
[speech,fs] = audioread(filename);      % Reading the anechoic speech
l = length(speech);
speech = speech(100:48100);
%Calculating the reverberant speech
reverberant_speech = fconv(speech,h);
%subplot(3,1,3);plot(reverberant_speech);
testData(:,iter) = reverberant_speech;
% Saving the speech file to .wav file
audiowrite(sprintf('genData/test_%d_rt_%f.wav',iter,beta),reverberant_speech,fs);
fprintf('Processed %d\n',iter);
end
save testData.mat testData rt