libresample: 0.1.3 -> 0.1.4-unstable-2024-08-23

The Debian CMake build system rewrite patch was broken and generated
an unusable `.pc` file, so I rewrote it again in Meson. This was
accepted upstream, but is still awaiting a final release.

The licence also changed to BSD-2-Clause OR LGPL-2.1-or-later in 2013.

Emily 095ef5ef 7ca429f2

+160 -21
+108
pkgs/by-name/li/libresample/fix-test.patch
··· 1 + From fb8e3c74d582038a358936d827f53c4c0c43d4e6 Mon Sep 17 00:00:00 2001 2 + From: Matt Harvey <mattharvey@google.com> 3 + Date: Mon, 27 Nov 2023 16:28:53 -0800 4 + Subject: [PATCH] Fix testresample.c output span; add exit code 5 + 6 + Prior to this chance, the "Resample with different factors" test only 7 + passed for 60 of the 63 factors, with the 3 failing ones being the 8 + largest. 9 + 10 + 1. Since only 63 distinct factors were being considered, 100 random 11 + samples was overkill. 12 + 2. To support noticing failure in continuous build systems, it's nice if 13 + the test exit()s with nonzero when there are failures. 14 + 3. The root cause was a formula error when determining which indices in 15 + the resampled output ought be compared. Details are explained in a 16 + comment. 17 + --- 18 + tests/testresample.c | 32 ++++++++++++++++++++++++-------- 19 + 1 file changed, 24 insertions(+), 8 deletions(-) 20 + 21 + diff --git a/tests/testresample.c b/tests/testresample.c 22 + index aa83a46..640df5a 100644 23 + --- a/tests/testresample.c 24 + +++ b/tests/testresample.c 25 + @@ -19,6 +19,8 @@ 26 + 27 + #define MIN(A, B) (A) < (B)? (A) : (B) 28 + 29 + +int global_error; 30 + + 31 + void runtest(int srclen, double freq, double factor, 32 + int srcblocksize, int dstblocksize) 33 + { 34 + @@ -65,10 +67,12 @@ void runtest(int srclen, double freq, double factor, 35 + 36 + if (o < 0) { 37 + printf("Error: resample_process returned an error: %d\n", o); 38 + + global_error = 1; 39 + } 40 + 41 + if (out <= 0) { 42 + printf("Error: resample_process returned %d samples\n", out); 43 + + global_error = 1; 44 + free(src); 45 + free(dst); 46 + return; 47 + @@ -79,15 +83,16 @@ void runtest(int srclen, double freq, double factor, 48 + printf(" Expected ~%d, got %d samples out\n", 49 + expectedlen, out); 50 + } 51 + - 52 + + 53 + sum = 0.0; 54 + sumsq = 0.0; 55 + errcount = 0.0; 56 + 57 + - /* Don't compute statistics on all output values; the last few 58 + - are guaranteed to be off because it's based on far less 59 + - interpolation. */ 60 + - statlen = out - fwidth; 61 + + /* Don't compute statistics on all output values; the last small fraction 62 + + are guaranteed to be off since they are interpolated based on far fewer 63 + + values. When upsampling, the length of the range where this concern 64 + + applies is in direct proportion to the upsampling factor. */ 65 + + statlen = out - ((int)round(fwidth * factor)); 66 + 67 + for(i=0; i<statlen; i++) { 68 + double diff = sin((i/freq)/factor) - dst[i]; 69 + @@ -117,6 +122,7 @@ void runtest(int srclen, double freq, double factor, 70 + printf(" i=%d: expected %.3f, got %.3f\n", 71 + i, sin((i/freq)/factor), dst[i]); 72 + printf(" At least %d samples had significant error.\n", errcount); 73 + + global_error = 1; 74 + } 75 + err = sum / statlen; 76 + rmserr = sqrt(sumsq / statlen); 77 + @@ -130,6 +136,8 @@ int main(int argc, char **argv) 78 + int i, srclen, dstlen, ifreq; 79 + double factor; 80 + 81 + + global_error = 0; 82 + + 83 + printf("\n*** Vary source block size*** \n\n"); 84 + srclen = 10000; 85 + ifreq = 100; 86 + @@ -172,11 +180,19 @@ int main(int argc, char **argv) 87 + printf("\n*** Resample with different factors ***\n\n"); 88 + srclen = 10000; 89 + ifreq = 100; 90 + - for(i=0; i<100; i++) { 91 + - factor = ((rand() % 64) + 1) / 4.0; 92 + + for (i = 1; i < 64; i++) { 93 + + factor = i / 4.0; 94 + + dstlen = (int)(srclen * factor + 10); 95 + + runtest(srclen, (double)ifreq, factor, srclen, dstlen); 96 + + } 97 + + 98 + + printf("\n*** Resample with large factors ***\n\n"); 99 + + srclen = 200; 100 + + ifreq = 100; 101 + + for (factor = 25.0; factor < 1000.0; factor *= 1.7) { 102 + dstlen = (int)(srclen * factor + 10); 103 + runtest(srclen, (double)ifreq, factor, srclen, dstlen); 104 + } 105 + 106 + - return 0; 107 + + return global_error; 108 + }
+52 -21
pkgs/by-name/li/libresample/package.nix
··· 1 1 { 2 2 lib, 3 3 stdenv, 4 - fetchurl, 4 + fetchFromGitHub, 5 5 cmake, 6 + meson, 7 + ninja, 8 + pkg-config, 9 + libsndfile, 10 + libsamplerate, 6 11 }: 7 12 8 - let 9 - patch = fetchurl { 10 - url = "mirror://debian/pool/main/libr/libresample/libresample_0.1.3-3.diff.gz"; 11 - sha256 = "063w8rqxw87fc89gas47vk0ll7xl8cy7d8g70gm1l62bqkkajklx"; 12 - }; 13 - in 14 - stdenv.mkDerivation rec { 13 + stdenv.mkDerivation (finalAttrs: { 15 14 pname = "libresample"; 16 - version = "0.1.3"; 17 - src = fetchurl { 18 - url = "mirror://debian/pool/main/libr/libresample/libresample_${version}.orig.tar.gz"; 19 - sha256 = "05a8mmh1bw5afqx0kfdqzmph4x2npcs4idx0p0v6q95lwf22l8i0"; 15 + version = "0.1.4-unstable-2024-08-23"; 16 + 17 + outputs = [ 18 + "bin" 19 + "dev" 20 + "out" 21 + ]; 22 + 23 + src = fetchFromGitHub { 24 + owner = "minorninth"; 25 + repo = "libresample"; 26 + rev = "7cb7f9c3f72d4e6774d964dc324af827192df7c3"; 27 + hash = "sha256-8gyGZVblqeHYXKFM79AcfX455+l3Tsoq3xQse5nrKAo="; 20 28 }; 21 - patches = [ patch ]; 22 - preConfigure = '' 23 - cat debian/patches/1001_shlib-cmake.patch | patch -p1 24 - ''; 25 - nativeBuildInputs = [ cmake ]; 29 + 30 + patches = [ 31 + # Fix testresample.c output span; add exit code 32 + # https://github.com/minorninth/libresample/pull/7 33 + ./fix-test.patch 34 + ]; 35 + 36 + nativeBuildInputs = [ 37 + meson 38 + ninja 39 + pkg-config 40 + ]; 41 + 42 + buildInputs = 43 + [ 44 + # For `resample-sndfile` 45 + libsndfile 46 + ] 47 + ++ lib.optionals (!libsamplerate.meta.broken) [ 48 + # For `compareresample` 49 + libsamplerate 50 + ]; 51 + 52 + mesonFlags = [ (lib.mesonEnable "compareresample" (!libsamplerate.meta.broken)) ]; 53 + 54 + doCheck = true; 26 55 27 56 meta = { 28 57 description = "Real-time library for sampling rate conversion library"; 29 - license = lib.licenses.lgpl2Plus; 30 - homepage = "https://ccrma.stanford.edu/~jos/resample/Free_Resampling_Software.html"; 58 + homepage = "https://github.com/minorninth/libresample"; 59 + license = lib.licenses.bsd2; # OR LGPL-2.1-or-later 60 + sourceProvenance = [ lib.sourceTypes.fromSource ]; 61 + platforms = lib.platforms.all; 31 62 maintainers = [ 32 63 lib.maintainers.sander 33 64 lib.maintainers.emily 34 65 ]; 35 - platforms = lib.platforms.unix; 66 + mainProgram = "resample-sndfile"; 36 67 }; 37 - } 68 + })