4 ms·
> The stream interface is the core of the library, so let’s discuss it first. It is remarkably simple It's interesting (odd?) that the interface doesn't just e
by juunpp 4y ago
> The stream interface is the core of the library, so let’s discuss it first. It is remarkably simple
It's interesting (odd?) that the interface doesn't just expose a function to get the next value, similar to a lazy list in Haskell, which also goes well with the original statement in the post that a stream is basically a function. The 'sine_wave' stream for example is 90% filling the array and 10% actual stream logic, which I imagine you're duplicating in other stream implementations.
- lisyarus 4y agoThat's for efficiency reasons: most streams have way more logic than just filling the array, which can hardly be represented in terms of "getting the next value", and loops are good for optimization by compiler, etc. In fact, the actual sine wave implementation looks exactly the way you describe: it handles a generating function to a helper class that just fills the array https://bitbucket.org/lisyarus/psemek/src/master/libs/audio/source/wave/sine.cpp https://bitbucket.org/lisyarus/psemek/src/master/libs/audio/...