Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ulab.numpy: implement sinc for creating audio filters #617

Merged
merged 3 commits into from
May 16, 2023

Commits on May 15, 2023

  1. ulab.numpy: implement sinc for creating audio filters

    This is useful for generating FIR filters using code snippets generated at
    https://fiiir.com/ (at least those with a rectangular window type; other
    window types need additional functions but we can revisit it later if needed)
    
    I think this will come in handy for folks who are using the advanced
    features of our audio synthesizer module, synthio.
    
    e.g., the following block now gives highly similar results on ulab
    or numpy:
    
    ```py
    try:
        import numpy as np
    except:
        from ulab import numpy as np
    
    # Example code, computes the coefficients of a low-pass windowed-sinc filter.
    
    # Configuration.
    fS = 48000  # Sampling rate.
    fL = 4000  # Cutoff frequency.
    N = 23  # Filter length, must be odd.
    
    # Compute sinc filter.
    h = np.sinc(2 * fL / fS * (np.arange(N) - (N - 1) / 2))
    
    # Normalize to get unity gain.
    h /= np.sum(h)
    
    # Applying the filter to a signal s can be as simple as writing
    # s = np.convolve(s, h)
    jepler committed May 15, 2023
    Configuration menu
    Copy the full SHA
    1150554 View commit details
    Browse the repository at this point in the history

Commits on May 16, 2023

  1. fix docstring of sinc

    jepler committed May 16, 2023
    Configuration menu
    Copy the full SHA
    6000743 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f3e6e1c View commit details
    Browse the repository at this point in the history