1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| fs=48000; f1 = 17e3; f2 = 18e3; chirp_len=960; mode='s7/';
fileFolder = fullfile(['receive/', mode]); dirOutput = dir(fullfile(fileFolder,'*.pcm')); fileNames = {dirOutput.name}; file_name = fileNames{end} file=['receive/' , mode, file_name]; data= importdata(file);
data=data(15000:end-50000); stft(data, fs, "FFTLength", 1024)
time = length(data); t = 0:1/fs:(time-1)/fs;
data=highpass(data, 15000, fs);
A = movmean(abs(data), 20); thresh = (max(A) - min(A))/7 + min(A); inds = find(A > thresh); valid_data = data(inds(1):inds(end)); if(length(valid_data)<32*chirp_len) valid_data=padarray(valid_data,32*chirp_len-length(valid_data), "pre"); else valid_data=valid_data(1:32*chirp_len); end
res=[]; for i= 1:chirp_len:length(valid_data) temp=valid_data(i:i+chirp_len-1); [argv, argmin]=max(abs(fft(temp, fs))); if(abs(argmin-f1)<abs(argmin-f2)) res= [res 0]; else res=[res 1]; end end
res; str_res= sprintf('%1d', res) deci_res=bin2dec(str_res) IPVector= deci_res; test=strcat(num2str(bitand(bitshift(IPVector,-24), 255)),'.',num2str(bitand(bitshift(IPVector,-16), 255)) ,'.',num2str(bitand(bitshift(IPVector,-8), 255)) ,'.',num2str(bitand(bitshift(IPVector,0), 255)) )
|