ruuda / hound

A wav encoding and decoding library in Rust

Home Page:https://codeberg.org/ruuda/hound

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Lazy loading / Chunked reading / BufReader access

theronic opened this issue · comments

How do I access the underlying lazy WAV stream, instead of having to fold samples all at once?

I'm trying to test some properties of an agnostic sound stream, but Hound makes it hard for me to write chunked/streaming processing without access to the underlying buffer reader.

Perhaps it can return some kind of iterator for the file?

OK, I see WavSamples implements Iterator, and samples() returns this. So looks like I wrongly assumed samples() is greedy.

WavReader::samples() is an iterator, constructing it does not yet read anything from the underlying reader. Every call to next() on the samples iterator will read as much as necessary from the underlying reader to return one sample.