How to get a subset of a buffer as a list?
Is there a way to get an arbitrary subset of samples out of a buffer~, as a list?
I've seen a number of threads about putting arbitrary data into a buffer~ -- this is going the opposite direction.
msg(start sample, num samples) --> [something~ myBufferName] --> a list of floats
[capture~] stores a list of samples as text -- which could be helpful, if there is a straightforward way to convert that to a list, without user interaction.
hjh
use peek~ and uzi
collect output into whatever you want, text, capture, coll ...
> use peek~ and uzi
Got it -- no magic, just do it yourself ;) can do.
hjh
If you are open to using code, Scheme for Max has a function that does just this. Technically, it converts buffer contents to a vector, but when you output a vector, that is converted to a list. So this reads from a buffer, channel 0, starting at point 0, for 4 samples, and outputs the list out outlet 0:
(out 0 (buffer->vector 'my-bufname 0 0 4))

Docs page on the buffer i/o functions is here:
https://iainctduncan.github.io/scheme-for-max-docs/api.html#buffer-i-o
Note that in this example, this is the entire patch. As in, you don't need to load a file into s4m to execute one liners, you can just send the interpreter a line of code as a message. Also note the single quote mark before the name of the buffer, that is important to let Scheme know you are using the symbol foo, not the contents of a variable named foo.
> If you are open to using code, Scheme for Max has a function that does just this.
Ooh, that's nice :-D I missed this message, sorry about that. I never got deep into Scheme but that looks straightforward enough.
Thanks!
hjh
Feel free to ping me with any questions on the github discussion board! Scheme is really easy to learn, it's the ultimate minimal language. I wrote an intro on it here: https://iainctduncan.github.io/learn-scheme-for-max/introduction.html