Skip to content
Snippets Groups Projects
Commit 84692a42 authored by Eric Kooistra's avatar Eric Kooistra
Browse files

Added normalize output and quantize.

parent 6a897f7e
No related branches found
No related tags found
No related merge requests found
...@@ -23,13 +23,19 @@ ...@@ -23,13 +23,19 @@
% Purpose : FFT per block of data % Purpose : FFT per block of data
% Description : % Description :
function [data] = pfft(ctrl, data) function [out_data] = pfft(ctrl, in_data)
% Data processing % Data processing
dat = fft(data, ctrl.fft_size); out_data = fft(in_data, ctrl.fft_size);
if ctrl.complex if ~ctrl.complex
data = dat;
else
% because we have real input, we can omit half of the fft result % because we have real input, we can omit half of the fft result
data = dat(1:ctrl.fft_size/2); out_data = out_data(1:ctrl.fft_size/2);
end
% Normalize output to [-1 1]
out_data = out_data / ctrl.gain;
% Quantization
if ctrl.data_w>0
out_data = quantize(out_data, 1, ctrl.data_w, 'half_away');
end end
...@@ -26,7 +26,15 @@ ...@@ -26,7 +26,15 @@
function [state, out_data] = pfir(ctrl, in_data) function [state, out_data] = pfir(ctrl, in_data)
% Data processing % Data processing
for t = 1:ctrl.downsample_factor for t = 1:ctrl.downsample_factor
[out_data(t), ctrl.Zdelays(t,:)] = filter(ctrl.coeff(t,:), 1, in_data(t), ctrl.Zdelays(t,:)); % ctrl.nof_taps coefficients and ctrl.nof_taps-1 Zdelays [out_data(t), ctrl.Zdelays(t,:)] = filter(ctrl.coeff(t,:), 1, in_data(t), ctrl.Zdelays(t,:)); % range ctrl.nof_taps coefficients and range ctrl.nof_taps-1 Zdelays
end
% Normalize output to [-1 1]
out_data = out_data / ctrl.gain;
% Quantization
if ctrl.data_w>0
out_data = quantize(out_data, 2^ctrl.scale_w, ctrl.data_w, 'half_away');
end end
% Keep state for next call % Keep state for next call
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment