Skip to content

Add a len field to track the size of the window.#199

Open
silvestrpredko wants to merge 1 commit intoRustAudio:masterfrom
silvestrpredko:silvestr/limit-window-iterator
Open

Add a len field to track the size of the window.#199
silvestrpredko wants to merge 1 commit intoRustAudio:masterfrom
silvestrpredko:silvestr/limit-window-iterator

Conversation

@silvestrpredko
Copy link
Copy Markdown

Currently, the iterator of the window produces samples indefinitely. This is not intuitive at first glance. Also, if I just want to work with samples in a plain for each, I need to remember to call take a fixed number of samples first; otherwise, it will loop indefinitely.

…ite item production in the window iterator.
@PanieriLorenzo
Copy link
Copy Markdown
Collaborator

PanieriLorenzo commented May 2, 2026

I understand that it seems unintuitive for Window to be an infinite iterator, however the reason is that it is a signal. Signals are modelled as infinite iterators, that's just the way the crate is designed, and it also is how signals are usually modelled in DSP theory.

The behavior you want is actually already implemented in Windowed, which according to the docs "Returns None once the Window has been exhausted."

Windower yields Windowed, not Window, so your test is actually not testing the change you made.

While this change makes sense, it is a breaking change, and it also diverges from how signals are represented in the rest of the crate. Signals in dasp_signal are infinite iterators, this is just how the crate is designed.

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.

2 participants