Skip to content

Avoid integer overflow when scaling EEMD noise - #190

Open
antonsoo wants to merge 1 commit into
laszukdawid:masterfrom
antonsoo:fix/eemd-integer-noise-scale
Open

antonsoo wants to merge 1 commit into
laszukdawid:masterfrom
antonsoo:fix/eemd-integer-noise-scale

Conversation

@antonsoo

Copy link
Copy Markdown

EEMD computes max(S) - min(S) in the input dtype before scaling its noise. For signed integer recordings, that subtraction can overflow and produce the wrong noise amplitude. For example, a measured guitar window gives a noise scale of 411.75 as int16, versus 2865.05 after exact conversion to floating point.

Convert integer extrema to Python integers before subtracting. Floating-point inputs retain their existing arithmetic. Add regressions for signed 8-, 16-, 32- and 64-bit input with overflow treated as an error.

Validation:

  • All four new cases fail before and pass afterward, checking the noise scale and seeded decomposition against floating-point copies.
  • All 48 recorded speech/guitar cases now produce byte-identical decompositions to their floating-point references; all failed before. The cases include native 16-bit PCM and exact power-of-two scaling to wider signed types. All 56 floating-point controls remain byte-identical.
  • The full suite runs 117 tests successfully with 21 optional tests skipped on Python 3.12 and 3.14. Black 25.11 and isort pass.

This is separate from the timeline overflow fixed for #90; it affects the signal's amplitude range even for short recordings.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-11T07:06:27.664197Z 39e7b9f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant