WaveBeans / wavebeans

Audio Processing. On scale.
https://wavebeans.io
Apache License 2.0
24 stars 0 forks source link

`.rangeProject` as separate stream #8

Closed asubb closed 4 years ago

asubb commented 4 years ago

Currently the API looks like this:

someStream.rangeProjection(0,1000, MILLISECONDS)

which relies on the same stream implementation to be able to generate the stream, however most of the stream are just reading up to the point and skipping unneeded.

The idea is to make it as a separate stream. It'll remove a lot of ugliness in the code where BeanStream<T,S> must have second generic type only to return back the proper type of the stream.

So, it should simplify the BeanStream<T,S> to BeanStream<T> and rangeProjection will become an extension function, and might be event renamed.


fun BeanStream<T>.range(from: Int, to: Int?, timeUnit: TimeUnit): BeanStream<T> { /* ... */ }

BeanStream<T> should be extended with the function that converts time to sample index within certain sample rate.

asubb commented 4 years ago

Fixed in https://github.com/asubb/wavebeans/pull/9