I would like to ask you for help to understand shifting frequency bins in audio pitch shifter. I have two issues that I can’t undersrand:
At first how to shift frequency bins when pitch factor is not rounded? For example let’s imagine some not typical but easier to explain case:
I have complex numbers array
f with freq bins, where each member of array corresponds to one Hertz. So:
f correspond to DC
f correspond to 1Hz,
f corresponds to 2Hz,
f corresponds to 3Hz
and so on.
And I have only one value at freq bin with index 1:
f.real = 1; f.imag = 0;
And all the rest members in
f array are zero (both real and imag). So it means that my signal in time dmain is just single 1Hz sinusoid with no phase shift and with amplitude equal 1, and can be expressed by: $1 \cdot sin(1\cdot x)$
(Of course apmlitude depends on fft size, but the point is frequency so for simplify let's assume amlitude is 1 in that case).
And now let's assume I want to make pitch shifting with factor 1.75 to achieve one 1.75 Hz sinusoid expressed by: $1 \cdot sin(1.75 \cdot x)$
So after such pitch shift there are:
f.real = 0.25; f.imag = 0; f.real = 0.75; f.imag = 0;
But in that case it looks like I have two sinusoids, first 1Hz and amplitude 0.25, and second 2Hz and amplitude 0.75. And it could be expressed by:
$0.25 \cdot sin(1 \cdot x) + 0.75 \cdot sin(2 \cdot x)$
So I've plot it on Desmos, to compare with desired $1 \cdot sin (1.75 \cdot x) And definitely they are not even similar.
So it looks like I do something wrong? But then how should it be solved?
Second question corresponds to the first one. Let's say I want to pitch shift with factor exact 2, so I should achieve the signal with one octave higher than original. While it works for one sinusoid, I get very ugly results for normal audio signals where all freq bins in array are filled with some value. So after shift all bins by factor 2 then I have every two bins empty, let mi illustrate it:
And it seems (and it sounds) like it’s wrong way to shifting freq bins. But then how to do that properly?
For any help great thanks in advance.