forked from pyodide/pyodide
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
151 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package: | ||
name: soxr | ||
version: 0.5.0.post1 | ||
top-level: | ||
- soxr | ||
source: | ||
url: https://files.pythonhosted.org/packages/02/c0/4429bf9b3be10e749149e286aa5c53775399ec62891c6b970456c6dca325/soxr-0.5.0.post1.tar.gz | ||
sha256: 7092b9f3e8a416044e1fa138c8172520757179763b85dc53aa9504f4813cff73 | ||
patches: | ||
# Can be removed once the PR chirlu/soxr#13 (dead upstream) or dofuuz/soxr#3 (python soxr fork) is merged and released | ||
- patches/0001-Fix-function-signatures.patch | ||
requirements: | ||
run: | ||
- numpy | ||
about: | ||
home: https://github.com/dofuuz/python-soxr | ||
PyPI: https://pypi.org/project/soxr | ||
summary: High quality, one-dimensional sample-rate conversion library | ||
license: LGPLv2+ | ||
test: | ||
imports: | ||
- soxr | ||
extra: | ||
recipe-maintainers: | ||
- swnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
From 983ea3d49b2834e044ca5b492cfb80181e49666f Mon Sep 17 00:00:00 2001 | ||
From: swnf <[email protected]> | ||
Date: Sun, 3 Nov 2024 10:36:47 +0100 | ||
Subject: [PATCH] Fix function signature mismatches | ||
|
||
|
||
diff --git a/libsoxr/src/fft4g32.c b/libsoxr/src/fft4g32.c | ||
index 7a31ba4..31aebca 100644 | ||
--- a/libsoxr/src/fft4g32.c | ||
+++ b/libsoxr/src/fft4g32.c | ||
@@ -9,11 +9,12 @@ | ||
|
||
#if WITH_CR32 | ||
#include "rdft_t.h" | ||
-static void * null(void) {return 0;} | ||
-static void forward (int length, void * setup, double * H) {lsx_safe_rdft_f(length, 1, H); (void)setup;} | ||
-static void backward(int length, void * setup, double * H) {lsx_safe_rdft_f(length, -1, H); (void)setup;} | ||
+static void * null(int length) {return 0; (void)length;} | ||
+static void nothing(void * setup) {(void)setup;} | ||
+static void forward(int length, void * setup, void * H, void * scratch) {lsx_safe_rdft_f(length, 1, (double * ) H); (void)setup; (void)scratch;} | ||
+static void backward(int length, void * setup, void * H, void * scratch) {lsx_safe_rdft_f(length, -1, (double * ) H); (void)setup; (void)scratch;} | ||
static int multiplier(void) {return 2;} | ||
-static void nothing(void) {} | ||
+static void nothing2(int length, void * setup, void * H, void * scratch) {(void)length; (void)setup; (void)H; (void)scratch;} | ||
static int flags(void) {return 0;} | ||
|
||
fn_t _soxr_rdft32_cb[] = { | ||
@@ -27,7 +28,7 @@ fn_t _soxr_rdft32_cb[] = { | ||
(fn_t)_soxr_ordered_convolve_f, | ||
(fn_t)_soxr_ordered_partial_convolve_f, | ||
(fn_t)multiplier, | ||
- (fn_t)nothing, | ||
+ (fn_t)nothing2, | ||
(fn_t)malloc, | ||
(fn_t)calloc, | ||
(fn_t)free, | ||
diff --git a/libsoxr/src/fft4g32s.c b/libsoxr/src/fft4g32s.c | ||
index 8ce9726..f00c97c 100644 | ||
--- a/libsoxr/src/fft4g32s.c | ||
+++ b/libsoxr/src/fft4g32s.c | ||
@@ -5,11 +5,12 @@ | ||
#include "util32s.h" | ||
#include "rdft_t.h" | ||
|
||
-static void * null(void) {return 0;} | ||
-static void nothing(void) {} | ||
-static void forward (int length, void * setup, float * H) {lsx_safe_rdft_f(length, 1, H); (void)setup;} | ||
-static void backward(int length, void * setup, float * H) {lsx_safe_rdft_f(length, -1, H); (void)setup;} | ||
+static void * null(int length) {return 0; (void)length;} | ||
+static void nothing(void * setup) {(void)setup;} | ||
+static void forward (int length, void * setup, void * H, void * scratch) {lsx_safe_rdft_f(length, 1, (float*)H); (void)setup; (void)scratch;} | ||
+static void backward(int length, void * setup, void * H, void * scratch) {lsx_safe_rdft_f(length, -1, (float*)H); (void)setup; (void)scratch;} | ||
static int multiplier(void) {return 2;} | ||
+static void nothing2(int length, void * setup, void * H, void * scratch) {(void)length; (void)setup; (void)H; (void)scratch;} | ||
static int flags(void) {return RDFT_IS_SIMD;} | ||
|
||
fn_t _soxr_rdft32s_cb[] = { | ||
@@ -23,7 +24,7 @@ fn_t _soxr_rdft32s_cb[] = { | ||
(fn_t)ORDERED_CONVOLVE_SIMD, | ||
(fn_t)ORDERED_PARTIAL_CONVOLVE_SIMD, | ||
(fn_t)multiplier, | ||
- (fn_t)nothing, | ||
+ (fn_t)nothing2, | ||
(fn_t)SIMD_ALIGNED_MALLOC, | ||
(fn_t)SIMD_ALIGNED_CALLOC, | ||
(fn_t)SIMD_ALIGNED_FREE, | ||
diff --git a/libsoxr/src/fft4g64.c b/libsoxr/src/fft4g64.c | ||
index 0018516..5798fd7 100644 | ||
--- a/libsoxr/src/fft4g64.c | ||
+++ b/libsoxr/src/fft4g64.c | ||
@@ -7,11 +7,12 @@ | ||
#include "soxr-config.h" | ||
|
||
#if WITH_CR64 | ||
-static void * null(void) {return 0;} | ||
-static void nothing(void) {} | ||
-static void forward (int length, void * setup, double * H) {lsx_safe_rdft(length, 1, H); (void)setup;} | ||
-static void backward(int length, void * setup, double * H) {lsx_safe_rdft(length, -1, H); (void)setup;} | ||
+static void * null(int length) {return 0; (void)length;} | ||
+static void nothing(void * setup) {(void)setup;} | ||
+static void forward (int length, void * setup, void * H, void * scratch) {lsx_safe_rdft(length, 1, (double*)H); (void)setup; (void)scratch;} | ||
+static void backward(int length, void * setup, void * H, void * scratch) {lsx_safe_rdft(length, -1, (double*)H); (void)setup; (void)scratch;} | ||
static int multiplier(void) {return 2;} | ||
+static void nothing2(int length, void * setup, void * H, void * scratch) {(void)length; (void)setup; (void)H; (void)scratch;} | ||
static int flags(void) {return 0;} | ||
|
||
typedef void (* fn_t)(void); | ||
@@ -26,7 +27,7 @@ fn_t _soxr_rdft64_cb[] = { | ||
(fn_t)_soxr_ordered_convolve, | ||
(fn_t)_soxr_ordered_partial_convolve, | ||
(fn_t)multiplier, | ||
- (fn_t)nothing, | ||
+ (fn_t)nothing2, | ||
(fn_t)malloc, | ||
(fn_t)calloc, | ||
(fn_t)free, | ||
-- | ||
2.43.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pytest | ||
from pytest_pyodide import run_in_pyodide | ||
|
||
|
||
@pytest.mark.parametrize("input_sr, output_sr", [(44100, 22050), (22050, 44100)]) | ||
@run_in_pyodide(packages=["soxr", "numpy"]) | ||
def test_resample(selenium, input_sr, output_sr): | ||
import numpy as np | ||
import soxr | ||
|
||
# Signal length in seconds | ||
length = 5.0 | ||
# Frequency in Hz | ||
frequency = 42 | ||
|
||
input_sample_positions = np.arange(0, length, 1 / input_sr) | ||
output_sample_positions = np.arange(0, length, 1 / output_sr) | ||
|
||
input_signal = np.sin(2 * np.pi * frequency * input_sample_positions) | ||
predicted_output_signal = np.sin(2 * np.pi * frequency * output_sample_positions) | ||
|
||
output_signal = soxr.resample(input_signal, input_sr, output_sr) | ||
|
||
np.testing.assert_allclose(predicted_output_signal, output_signal, atol=0.0015) |