NathanRoyer / pitch_shift

pitch-shifting using the phase vocoder technique
5 stars 2 forks source link

It seems that the "true" low frequencies will be lost if a target bin receives contributions from multiple source bins #1

Open stephanemagnenat opened 2 years ago

stephanemagnenat commented 2 years ago

In line 166 the frequency is overwritten, while in line 165 the amplitude is added. If I understand this code correctly, this means that if multiple source bins are written to the same target bin, due to the pitch being lowered, then only the highest "true" frequency is written.

I am aware that the source code in a famous article about this method does this as well, but this feels wrong to me. I believe it is probably better to do some form of averaging, for example a weighted average of the incoming frequencies using their corresponding amplitudes. This will consume more processing power, but it should be possible to do something not too heavy, for example using an arena allocator with a capacity equal to the number of processed bins.

I submitted a similar issue to the pvoc/pvoc-plugins crates (nwoeanhinnogaehr/pvoc-plugins#1), which implements a similar algorithm.