Im trying to implement a filter that runs over a spectrogram frequencies for each time frame and filters out inharmonic frequencies.
What I need is, given a time frame, for each frequency k in this timeframe, to access frequencies multiple of k (the harmonics), then perform some operation over them. So for frequency k, k=1,…,F, I need to access indexes, k, 2k, 3k,…, N*k (N in total), perform some operation and set the result to the position k (original frequency bin). Same calculation for all timeframes.
In resume, it would be something like this:
spec[k, :] = operation(spec[mutiple_indexes,:])
Basically its like running a operation sliding window starting in each frequency, but for each frequency this sliding window is more space (spaced by the frequency value).
I can do this iteratively, but Im wondering if there is a vectorized way of doing this.
I was thinking about torch.unfold, but it can only work on sequential patches, not of increasing stride.