When impulse response is symmetric around sample zero phase entirely zero.
in = 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 , 0 , 0 -> This gives zero phase result
As I know if I apply a delay in time domain this should result a linear phase in frequency domain. So if I delay my previous vector by one;
in = 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 , 0 -> This should give linear phase responce
const int N = 11;
// in = 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 0 , 0
std::vector< std::complex<double> > in (N);
std::vector< std::complex<double> > out (N);
std::vector< std::complex<double> > polarOut (N);
auto middleElem = in.begin() + in.size()/2;
//std::fill( middleElem - 1, middleElem + 3, 1); //zero phase
std::fill( middleElem, middleElem + 4, 1);
fftw_plan my_plan = fftw_plan_dft_1d(N, reinterpret_cast<fftw_complex*>(&in[0]),
reinterpret_cast<fftw_complex*>(&out[0]), FFTW_FORWARD, FFTW_ESTIMATE);
fftw_execute(my_plan);
std::transform( out.begin(), out.end(), polarOut.begin(),
[]( auto& in ){
return std::complex<double>( std::abs(in), std::arg(in) );
} );
The result of the fourier transform in polar notation is :
polarOut <11 items> std::vector<std::complex<double>>
[0] (4.000000, 0.000000) std::complex<double>
[1] (3.228707, 2.570394) std::complex<double>
[2] (1.397877, -1.142397) std::complex<double>
[3] (0.372786, -1.713596) std::complex<double>
[4] (1.088156, 0.856798) std::complex<double>
[5] (0.546200, -2.855993) std::complex<double>
[6] (0.546200, 2.855993) std::complex<double>
[7] (1.088156, -0.856798) std::complex<double>
[8] (0.372786, 1.713596) std::complex<double>
[9] (1.397877, 1.142397) std::complex<double>
[10] (3.228707, -2.570394) std::complex<double>
What am I missing here? Why phase responce is not linearly increasing?