[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sc-users] Allocating new Buffers in a Score
On Sat, May 22, 2021 at 1:59 PM <geoffbaltan@xxxxxxxxx> wrote:
> I'm currently trying to create bunch of Chebyshev-filled buffers for
> use in a Score. I've established the values elsewhere as an
> environmental variable and I'm using the following to load up the
> buffers and add them in the Score:
> n.add([0.1, [\b_alloc, ~bufs = Array.fill(20, {|i| Buffer.alloc(s,
> 1024, 1, { |buf| buf.chebyMsg(~chebs[i])})})]]);
>
> I'm suspicious that this is causing a problem, but I can't quite prove
> it (something about the multiple "allocs", maybe) . As for this
> question, I was simply hoping that someone could point out whether
> this is the right way of creating a bunch of buffers in a Score.
[/b_alloc, [aBuffer, aBuffer, aBuffer, ...]] is not a valid OSC
message format ;)
Couple of issues here:
1. The score should contain allocation *messages*, NOT buffer objects.
Buffer.alloc sends the allocation message immediately to the given
server and does NOT return the message to you. So if you need to do
something NRTish like add messages to a score, `alloc` simply can't
work.
Or, proceeding from analogy:
Synths:
RT: Synth(\name, ...)
NRT: Synth.basicNew(\name).newMsg(...)
Buffers:
RT: Buffer.alloc(...)
NRT: Buffer.new(s).allocMsg(completionMessage: { |buf| buf.chebyMsg(...) })
2. You would have to add the resulting allocMsg's one by one into the
score. You can't do [0, [[/b_alloc, ...], [/b_alloc, ...]...]].
// note Buffer *new here, NOT alloc
~bufs = Array.fill(20, { Buffer(my_nrt_server_instance) });
~bufs.do { |buf, i|
n.add([
0.1,
buf.allocMsg(completionMessage: {
buf.chebyMsg(~chebs[i])
})
])
};
Or, if you want to do it in one loop:
~bufs = Array.fill(20, { |i|
var buf = Buffer(my_nrt_server_instance);
n.add([
0.1,
buf.allocMsg(completionMessage: {
buf.chebyMsg(~chebs[i])
})
]);
// array fill func should return the object
// if n.add is last, then the array would contain
// side effects but not the objects you're interested in
buf
});
3. The NRT guide suggests creating a NRT Server object so that the
score will have its own allocators (and then removing the instance
after building the score). Otherwise you're allocating buffer IDs etc.
from the real-time server instance.
hjh
_______________________________________________
sc-users mailing list
info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/