function out = generator(playRec,samplerate,freq,ampl,time,buffer,mute)
cycles = (samplerate/buffer)*time; %number of cycles to measure for 
sample_per = 1/samplerate;

for j =(0:(cycles-1)) 
    sound_out = (zeros(buffer,1));
    if (mute == false) %not muted, output sound
        phi =(2*pi*freq*((j*buffer)*(1/samplerate)));
        for i=(1:buffer)
            sound_out(i) = ampl*sin(2*pi*freq*(i*sample_per)+phi);
        end
    end %if muted, keep zeros
 
    if(j == 0) %first buffer   
        rec = playRec(sound_out);
    else
        buff=playRec(sound_out); %all next buffers
        rec = cat(1,rec,buff);
    end
end
out = rec; %whole matrix
