Code Monkey home page Code Monkey logo

Comments (4)

bolau avatar bolau commented on June 20, 2024 1

Thanks a lot, this looks much better :)

from resampy.

bmcfee avatar bmcfee commented on June 20, 2024

I think this is probably expected behavior given how short your input signals are, but I will look into it. (Your code example does reproduce the reported behavior on my environment.)

To get high quality reconstruction, the default filter (kaiser_best) uses a very long window to approximate a sinc filter. When you get to the end of the signal, the filter gets adaptively shortened to avoid running off the end of the input buffer, which results in the attenuation behavior that you reported above. You can see this by switching from kaiser_best to kaiser_fast, in which case the results look like:
image
image
(note that the edge effects occupy a much smaller portion of the signal). If you want even more control over this, you can call resampy(... filter='sinc_window', num_zeros=16); the num_zeros parameter controls the effective precision of the resampling filter, with larger values producing longer filters and better fidelity.

For typical audio signals, these edge effects should be negligible. ~100 samples at 22050 Hz would not be audible. Still, it's a bit strange that the beginning of the resampled signal does not exhibit these artifacts, since the filter is time-symmetric, so I'll look into it.

from resampy.

bmcfee avatar bmcfee commented on June 20, 2024

Update: this does indeed seem to be a bug, due to this line subtracting off the left-hand array bound when calculating the right-hand array bound. Removing that subtraction brings the boundary effects down to where I would expect them:

image

image

At this point though, I'm wondering if it makes more sense to calculate a symmetric array bound for time t so that each output sample always has an equal contributions from the left- and right- wings of the filter. I'll experiment with this and report back. Otherwise, I've flagged this issue for fixing in 0.2.1, which I hope to push in the next few days.

Thanks @bolau for reporting this!

from resampy.

bmcfee avatar bmcfee commented on June 20, 2024

Fix is merged, I'll push the bugfix release later today and it should appear on conda-forge shortly thereafter.

The fix as implemented is, I think, the correct thing to do if we assume the input signal is zero outside of the observations. More generally, I could imagine it being useful to support other edge modes, which might be useful depending on the assumptions you're willing to make about your signals. I've created a new issue #64 for that. I probably won't have time to implement that in the immediate future, but I'm happy to help any newcomers that want to work on it.

from resampy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.