PedalNetRT icon indicating copy to clipboard operation
PedalNetRT copied to clipboard

Bug when calculating pre-emphasis filter for plotting

Open ivanpondal opened this issue 4 years ago • 4 comments

Hello!

When plotting, the following function is not calculating correctly the pre-emphasis filter: https://github.com/GuitarML/PedalNetRT/blob/238aca13db1aac87cbfd8df06a8d5960c9641f13/plot_wav.py#L24

The correct implementation is being used in the model: https://github.com/GuitarML/PedalNetRT/blob/238aca13db1aac87cbfd8df06a8d5960c9641f13/model.py#L106

At high level this is given a signal x, in order to calculate x[t] you do: x[t] = x[t] - 0.95*x[t - 1]

btw, great project! :+1:

ivanpondal avatar Dec 06 '20 19:12 ivanpondal

@ivanpondal Thanks for catching that, I will check it out, and I'll also check that in the GuitarLSTM repo because I might be making the same mistake there.

GuitarML avatar Dec 08 '20 12:12 GuitarML

@ivanpondal Sorry for the delay in responding to this, but if you compare the two implementations, aren't they doing the same thing? The one in plot code is using numpy arrays and the one in the model is using pytorch tensors.

GuitarML avatar Feb 03 '21 12:02 GuitarML

Hey! The problem is it's not using the previous element for the substraction. The pytorch implementation does: x[:, :, 1:] - coeff * x[:, :, :-1] That list slicing produces the desired x[t] = x[t] - 0.95*x[t - 1] while the numpy implementation does the substraction over the same list element.

ivanpondal avatar Feb 03 '21 14:02 ivanpondal

Got it now, good catch!

GuitarML avatar Feb 03 '21 19:02 GuitarML