function [ myRecording, txt ] = signal_rec( Fs, time, bits, device )
stereo=2;               % 2 -> CH1, CH2 rögzítés stereo módban
recObj = audiorecorder(Fs, bits, stereo, device);
disp('Start Recording.');
recordblocking(recObj, time);
disp('End of Recording.');

myRecording = getaudiodata(recObj, 'double');

CH1=myRecording(:,1);
CH2=myRecording(:,2);

fr=freq(Fs, CH1, CH2);
t=0:(1/Fs):(time-(1/Fs));
txt=fazis_script(t, CH1, CH2, fr);

% Vizualizáció
NFFT = 2^nextpow2(Fs);        
numUniq = ceil((NFFT+1)/2);   
f = (0:numUniq-1)'*Fs/NFFT;  



plotT=(4*(1/fr));

figure(1);
hAx(1) = subplot(211);
hLine(1) = line('XData',t, 'YData',nan(size(t)), 'Color','b', 'Parent',hAx(1));
xlabel('Time (s)'), ylabel('CH1 Amplitude')
xlim([0 plotT])
hAx(2) = subplot(212);
hLine(2) = line('XData',t, 'YData',nan(size(t)), 'Color','r', 'Parent',hAx(2));
xlabel('Time (s)'), ylabel('CH2 Amplitude')
xlim([0 plotT])
set(hAx, 'Box','on', 'XGrid','on', 'YGrid','on')

set(hLine(1), 'YData',CH1)
set(hLine(2), 'YData',CH2)
drawnow

figure(2);
hAx(1) = subplot(211);
hLine(1) = line('XData',f, 'YData',nan(size(f)), 'Color','b', 'Parent',hAx(1));
xlabel('Frequency (Hz)'), ylabel('CH1 Magnitude (dB)')
xlim([0 (fr+100)])
hAx(2) = subplot(212);
hLine(2) = line('XData',f, 'YData',nan(size(f)), 'Color','r', 'Parent',hAx(2));
xlabel('Frequency (Hz)'), ylabel('CH2 Magnitude (dB)')
xlim([0 (fr+100)])
set(hAx, 'Box','on', 'XGrid','on', 'YGrid','on')

fftMag2 = 20*log10( abs(fft(CH2,NFFT)) );
fftMag1 = 20*log10( abs(fft(CH1,NFFT)) );
set(hLine(1), 'YData',fftMag1(1:numUniq))
set(hLine(2), 'YData',fftMag2(1:numUniq))
drawnow
end

