From 72a83d0744ccb2ed5a9051fa47a312495c236ecd Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 26 Mar 2026 10:32:28 -0400 Subject: [PATCH 01/10] Add license --- LICENSE | 28 ++++++++++++++++++++++++++++ README.md | 13 ++----------- 2 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f873106 --- /dev/null +++ b/LICENSE @@ -0,0 +1,28 @@ +MIT License + +Copyright (c) window-function contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- + +Krishnized License (https://github.com/krishnized/license) + +This work is also offered as seva (selfless service) under the Krishnized License. +All results of this work are offered to Krishna. diff --git a/README.md b/README.md index b9e81e9..8dc32ae 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# window-function [![test](https://github.com/audiojs/window-function/actions/workflows/test.yml/badge.svg)](https://github.com/audiojs/window-function/actions/workflows/test.yml) [![npm](https://img.shields.io/npm/v/window-function)](https://www.npmjs.com/package/window-function) +# window-function [![test](https://github.com/audiojs/window-function/actions/workflows/test.yml/badge.svg)](https://github.com/audiojs/window-function/actions/workflows/test.yml) [![npm](https://img.shields.io/npm/v/window-function)](https://www.npmjs.com/package/window-function) [![license](https://img.shields.io/badge/license-MIT%20%C2%B7%20%E0%A5%90-white)](https://github.com/krishnized/license) Collection of window functions for signal processing and spectral analysis. @@ -475,19 +475,10 @@ cola(hann, 1024, 512) // 0 — perfect STFT reconstruction - **`scallopLoss(fn, N, ...params)`** — worst-case amplitude error in dB between DFT bins. Rectangular = 3.92, Hann = 1.42, flat-top ≈ 0. - **`cola(fn, N, hop, ...params)`** — COLA deviation. 0 = perfect STFT reconstruction at given hop size. -## Migrating from v2 - -v3 is ESM-only — `require()` no longer works. 18 → 34 windows, subpath imports preserved. - -```diff -- const hann = require('window-function/hann') -- const apply = require('window-function/apply') -+ import hann from 'window-function/hann' -+ import { generate, apply } from 'window-function/util' -``` The per-sample API `fn(i, N, ...params) → number` is unchanged. + [^dolph1946]: C.L. Dolph, "A Current Distribution for Broadside Arrays," *Proc. IRE* 34, 1946. [^gabor1946]: D. Gabor, "Theory of Communication," *J. IEE* 93, 1946. [^bartlett1950]: M.S. Bartlett, "Periodogram Analysis and Continuous Spectra," *Biometrika* 37, 1950. From 4a090f046cb362c51ad00ca4e2dd33b842eec980 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 26 Mar 2026 10:33:22 -0400 Subject: [PATCH 02/10] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8dc32ae..1338174 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# window-function [![test](https://github.com/audiojs/window-function/actions/workflows/test.yml/badge.svg)](https://github.com/audiojs/window-function/actions/workflows/test.yml) [![npm](https://img.shields.io/npm/v/window-function)](https://www.npmjs.com/package/window-function) [![license](https://img.shields.io/badge/license-MIT%20%C2%B7%20%E0%A5%90-white)](https://github.com/krishnized/license) +# window-function [![test](https://github.com/audiojs/window-function/actions/workflows/test.yml/badge.svg)](https://github.com/audiojs/window-function/actions/workflows/test.yml) [![npm](https://img.shields.io/npm/v/window-function)](https://www.npmjs.com/package/window-function) [![MIT](https://img.shields.io/badge/MIT-%E0%A5%90-white)](https://github.com/krishnized/license) Collection of window functions for signal processing and spectral analysis. From bc529755e540a246b59ae6948787b0ac5fe0ea26 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 26 Mar 2026 10:34:11 -0400 Subject: [PATCH 03/10] Update LICENSE --- LICENSE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE b/LICENSE index f873106..5ab8fcd 100644 --- a/LICENSE +++ b/LICENSE @@ -25,4 +25,4 @@ SOFTWARE. Krishnized License (https://github.com/krishnized/license) This work is also offered as seva (selfless service) under the Krishnized License. -All results of this work are offered to Krishna. +All results of this work are offered to the Supreme. From 34e50db979a4eeb357bfdb258f9379b206166f15 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 26 Mar 2026 10:38:33 -0400 Subject: [PATCH 04/10] Final polishing --- README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1338174..c1ccc87 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,7 @@ npm install window-function ``` ```js -// Import everything, or just what you need import { hann, kaiser, generate, apply } from 'window-function' -import hann from 'window-function/hann' // Every window: fn(i, N, ...params) → number hann(50, 101) // single sample → 1.0 @@ -25,6 +23,13 @@ apply(signal, hann) // signal *= hann generate(kaiser, 1024, 8.6) // Kaiser with β = 8.6 ``` +Or import individual windows directly: + +```js +import hann from 'window-function/hann' +import kaiser from 'window-function/kaiser' +``` + ## Reference @@ -306,7 +311,7 @@ $w(n) = \sin^\alpha\!\left(\frac{\pi n}{N-1}\right)$ -sin^α family. Codec design, parameterized spectral analysis. +$\sin^\alpha$ family. Codec design, parameterized spectral analysis. ### `exponential(i, N, tau)` @@ -476,9 +481,6 @@ cola(hann, 1024, 512) // 0 — perfect STFT reconstruction - **`cola(fn, N, hop, ...params)`** — COLA deviation. 0 = perfect STFT reconstruction at given hop size. -The per-sample API `fn(i, N, ...params) → number` is unchanged. - - [^dolph1946]: C.L. Dolph, "A Current Distribution for Broadside Arrays," *Proc. IRE* 34, 1946. [^gabor1946]: D. Gabor, "Theory of Communication," *J. IEE* 93, 1946. [^bartlett1950]: M.S. Bartlett, "Periodogram Analysis and Continuous Spectra," *Biometrika* 37, 1950. From df44aabbfa8cd8ea1a50c66cc62591260d56672d Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 26 Mar 2026 10:38:53 -0400 Subject: [PATCH 05/10] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e21599c..4d71180 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "window-function", - "version": "3.0.0", + "version": "2.1.0", "type": "module", "description": "Window functions for signal processing and spectral analysis", "exports": { From 48d1ca655d536d1dc2b5ce46af834fbaeb78317d Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Thu, 26 Mar 2026 10:38:54 -0400 Subject: [PATCH 06/10] 3.0.0 --- package.json | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 4d71180..b2cf082 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "window-function", - "version": "2.1.0", + "version": "3.0.0", "type": "module", "description": "Window functions for signal processing and spectral analysis", "exports": { @@ -42,7 +42,13 @@ "./util": "./util.js" }, "types": "./index.d.ts", - "typesVersions": { "*": { "*": ["./index.d.ts"] } }, + "typesVersions": { + "*": { + "*": [ + "./index.d.ts" + ] + } + }, "scripts": { "test": "node --test test.js" }, From fab4cc0d546c724b902bb07fc6f01a31ea1dcb89 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Tue, 31 Mar 2026 08:01:30 -0400 Subject: [PATCH 07/10] Adjust plot constraints --- docs/generate.js | 12 +++++++----- docs/plots/dolphChebyshev.svg | 12 +++++++----- docs/plots/flatTop.svg | 26 +++++++++++++------------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/docs/generate.js b/docs/generate.js index 8ad4958..6f60fe1 100644 --- a/docs/generate.js +++ b/docs/generate.js @@ -41,15 +41,17 @@ for (let name of wins) { let db = new Float64Array(mag.length) for (let i = 0; i < mag.length; i++) db[i] = 20 * Math.log10(Math.max(mag[i] / peak, 1e-15)) - // Time-domain y-range - let tMax = 0 - for (let i = 0; i < N; i++) if (samples[i] > tMax) tMax = samples[i] + // Time-domain y-range (handle windows that go negative like flatTop, dolphChebyshev) + let tMax = 0, tMin = 0 + for (let i = 0; i < N; i++) { if (samples[i] > tMax) tMax = samples[i]; if (samples[i] < tMin) tMin = samples[i] } let yTop = tMax <= 1.1 ? 1 : Math.ceil(tMax) - let yTicks = tMax <= 1.1 ? [0, 0.5, 1] : Array.from({ length: yTop + 1 }, (_, i) => i) + let yBot = tMin >= -0.01 ? 0 : Math.floor(tMin * 2) / 2 // round down to nearest 0.5 + let yTicks = tMax <= 1.1 && tMin >= -0.01 ? [0, 0.5, 1] : [] + if (!yTicks.length) for (let y = yBot; y <= yTop; y += yTop > 2 ? 1 : 0.5) yTicks.push(Math.round(y * 10) / 10) let svg = `\n` - svg += panel(L, samples, 0, 1, 0, yTop, [0, 0.5, 1], yTicks, true) + svg += panel(L, samples, 0, 1, yBot, yTop, [0, 0.5, 1], yTicks, true) svg += panel(R, db, 0, 0.5, -120, 0, [0, 0.1, 0.2, 0.3, 0.4, 0.5], [0, -40, -80, -120], false) // Axis labels diff --git a/docs/plots/dolphChebyshev.svg b/docs/plots/dolphChebyshev.svg index 1c394e1..3865395 100644 --- a/docs/plots/dolphChebyshev.svg +++ b/docs/plots/dolphChebyshev.svg @@ -1,8 +1,10 @@ - 0 - - 0.5 + -0.5 + + 0 + + 0.5 1 @@ -13,8 +15,8 @@ 1 - - + + 0 diff --git a/docs/plots/flatTop.svg b/docs/plots/flatTop.svg index 12f92c4..e35cf58 100644 --- a/docs/plots/flatTop.svg +++ b/docs/plots/flatTop.svg @@ -1,16 +1,16 @@ - 0 - - 1 - - 2 - - 3 - - 4 - - 5 + -0.5 + + 0.5 + + 1.5 + + 2.5 + + 3.5 + + 4.5 0 @@ -19,8 +19,8 @@ 1 - - + + 0 From 5fcec53b959c7d5305141bd06c511e60aaa2cdab Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Tue, 7 Apr 2026 12:26:10 -0400 Subject: [PATCH 08/10] feat: add sideEffects false for tree-shaking --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index b2cf082..7b618da 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "window-function", "version": "3.0.0", "type": "module", + "sideEffects": false, "description": "Window functions for signal processing and spectral analysis", "exports": { ".": "./index.js", From ca4102f4f0654cf74cc44b2063d302a4804d7015 Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Tue, 7 Apr 2026 12:26:10 -0400 Subject: [PATCH 09/10] v3.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7b618da..c12a68c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "window-function", - "version": "3.0.0", + "version": "3.0.1", "type": "module", "sideEffects": false, "description": "Window functions for signal processing and spectral analysis", From 41fc5384080c8c720ea3a2fb476328b978130f5a Mon Sep 17 00:00:00 2001 From: "Dmitry Iv." Date: Fri, 10 Jul 2026 21:11:13 -0400 Subject: [PATCH 10/10] funding: github/sponsors/audiojs (field + FUNDING.yml); patch bump (release sweep) --- .github/FUNDING.yml | 1 + package.json | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..3d11e0a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +github: audiojs diff --git a/package.json b/package.json index c12a68c..0bb4671 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "window-function", - "version": "3.0.1", + "version": "3.0.2", "type": "module", "sideEffects": false, "description": "Window functions for signal processing and spectral analysis", @@ -84,5 +84,6 @@ "license": "MIT", "devDependencies": { "fourier-transform": "^2.2.0" - } + }, + "funding": "https://github.com/sponsors/audiojs" }