Skip to main content

No project description provided

Project description

Kazane: simple sinc interpolation for 1D signal in PyTorch

build Upload Python Package PyPI version

Kazane utilize FFT based convolution to provide fast sinc interpolation for 1D signal when your sample rate only needs to change by an integer amounts; If you need to change by a fraction amounts, checkout julius.

Installation

pip install kazane

or

pip install git+https://github.com/yoyololicon/kazane

for latest version.

Usage

import kazane
import torch

signal = torch.randn(8, 2, 44100)

# downsample by an amount of 3
decimater = kazane.Decimate(3)
resampled_signal = decimater(signal)

# upsample by an amount of 2
upsampler = kazane.Upsample(2)
resampled_signal = upsampler(signal)

# you can also control number of zeros, roll-off frequency of the sinc interpolation kernel
decimater = kazane.Decimate(3, num_zeros=24, roll_off=0.9)

# use other types of window function for the sinc kernel
upsampler = kazane.Upsample(2, window_func=torch.blackman_window)

Benchmarks on CUDA

Using the benchmark scripts at bench, you can see that FFT can gives some speed improvements when the sample rate changes with some common integer numbers.

[---------- Down sample ----------]
               |  julius  |  kazane
2 threads: ------------------------
      rate: 2  |   52.2   |   52.4 
      rate: 3  |   66.5   |   36.1 
      rate: 5  |   94.8   |   30.0 
      rate: 7  |  121.7   |   42.3 

Times are in milliseconds (ms).

[----------- Up sample -----------]
               |  julius  |  kazane
2 threads: ------------------------
      rate: 2  |   48.8   |   39.0 
      rate: 3  |   68.1   |   51.6 
      rate: 5  |  112.5   |   78.9 
      rate: 7  |  159.4   |  108.0 

Times are in milliseconds (ms).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kazane-1.0.4.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

kazane-1.0.4-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file kazane-1.0.4.tar.gz.

File metadata

  • Download URL: kazane-1.0.4.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for kazane-1.0.4.tar.gz
Algorithm Hash digest
SHA256 8e6ca18b8ce5f7ad00dd0f4dd8281f6ac6347e6356607093e79b6778f87d8b7a
MD5 540d677b9ff3f987a5b4a5c486f65b34
BLAKE2b-256 7b87f254fbb5d225b5bee70d7c957bd26bc4edc3753810e74ffd739e5445e909

See more details on using hashes here.

File details

Details for the file kazane-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: kazane-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 8.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.17

File hashes

Hashes for kazane-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 efef842e95fee87255574891970344662708e9d9f3a9720d1c06e376ecc9bce5
MD5 5240d08c373943e9f18d0a169362112e
BLAKE2b-256 00b76924c4a40bc74f643dc74d274344b737adceb574bcd6ec46819ce4567f80

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page