[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] buffer problems w/ auto-recorder



Thanks James,

Yes, it works now with b.copyMsg.

Maybe, as this mistake seems frequent, would be helpfull to have more documentation of copyMsg of Buffer helpfile.

best
a


James Harkins wrote:
On Mar 11, 2009, at 6:54 AM, Andre Castro wrote:

unh... I've been breaking my head, but can't seem to to get around it. The buffers added to the  ~buffers Array are all empty (no sound).

It might be something in  completionMessage that is not write. I'm not exactly sure of this code

Buffer.alloc(s, 44100*~length, 1,  completionMessage: {|buf|
                       ~buffers = ~buffers.add(buf); b.copyData(~buffers.last, 0, 0, 44100*~length) } ); 
                        };)


Yes -- the completion message argument is supposed to be a function that returns an array representing an OSC message. Here, the function is an instruction to send an OSC message to the server.

A completion message has to be sent as part of (i.e., at the same time as) the main message. So the workflow is:

1. Get a buffer number from the server's available pool.
2. Pass the new buffer object as the argument to completionMessage.
3. Build and send the /b_alloc message, appending the results of step 2 (if not empty).

The server doesn't allocate buffer memory until step 3.

The way it's currently written here, the flow is instead:

1. Get a buffer number from the server's available pool.
2. The completionMessage function tells the server to copy the data (but, buffer memory is not allocated yet).
3. Build and send the /b_alloc message.

Instead of b.copyData, try b.copyMsg.

This is a really common mistake for me -- I can't count how many times I've written:

b = Buffer.alloc(s, 2048, 1, completionMessage: { |buf| buf.sine1([1]) });

... only to have it fail for the same reason (executing sine1 before b_alloc).

hjh


: H. James Harkins
.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:

"Come said the Muse,
Sing me a song no poet has yet chanted,
Sing me the universal."  -- Whitman