Hi all,
I am trying to copy the data I am receiving from OSC to a buffer. I’ m doing this from whithin the OSCdef. I was doing it like this:
(
var accData = 0.dup(6);
var accbuf = Buffer.alloc(s, 6);
OSCdef(\accMob,{
arg msg;
//msg.postln;
xdataMa = msg[1].linlin(-10, 10, 0, 1);
ydataMa = msg[2].linlin(-10, 10, 0, 1);
zdataMa = msg[3].linlin(-10, 10, 0, 1);
accData[0] = xdataMa;
accData[1] = ydataMa;
accData[2] = zdataMa;
accbuf.loadCollection(accData);
}, '/accxyz', recvPort: 57120);
)
I was getting the error described in this post: Temp-file throws ‘Forma not recognised’ error. Despite of the error, the code still worked. To get rid of the error I realized that I have to create a temporal “copy” or an instance of the buffer, which I reckon is kept in the temp folder. So, the code becomes as following:
(
var accData = 0.dup(6);
var accbuf = Buffer.alloc(s, 6);
OSCdef(\accMob,{
arg msg;
//msg.postln;
xdataMa = msg[1].linlin(-10, 10, 0, 1);
ydataMa = msg[2].linlin(-10, 10, 0, 1);
zdataMa = msg[3].linlin(-10, 10, 0, 1);
accData[0] = xdataMa;
accData[1] = ydataMa;
accData[2] = zdataMa;
accbuf = Buffer.loadCollection(s, accData);
}, '/accxyz', recvPort: 57120);
)
Apparently there were no errors. However, 10 seconds after executing the code, I got the following error:
The preceding error dump is for ERROR: No more buffer numbers -- free some buffers before allocating more.
Everything stop working. I increased the number os busses in the server: s.options.numBuffers_(10000);, which only delay the error. I reckon the memory of the server must be filled because it is creating temporal Buffers at the rate of the OSCdef. How can I free “temporal” Buffers? Perhaps I’m missing something basic. How could I get this working properly?, How does the copy of data from an array to a buffer function?, thanks
pd. I realized that there is access to the Cached Buffers. However there is no method to erase the ones that has been already used, they can be accessed just by number, not by name and they are removed from the cache when the Buffer is freed.