Forums > Dev

buffer_ref_notify with multiple buffers

November 3, 2013 | 5:36 am

Hi folks,

I’m still fairly new to the MSP API, so please be patient with me :)
When working on a multi-buffer MSP object I dissected the simpwave example. I understand that the simpwave_notify function is a callback to update a module’s state when its referenced buffers have changed.

simpwave_notify uses this return value:
return buffer_ref_notify(x->w_buf, s, msg, sender, data);
But what does this do? And how does this translate to an MSP object with multiple buffers — how do I now which of my buffers was modified so I can put its reference here as an argument?
The reference PDF just says "Your notify method should then call this notify method for the t_buffer_ref", but it does not reveal (to me) what it does.

Thanks for any help…

Best, Boris

November 3, 2013 | 6:23 am

I should add that this is a nasty issue for me right now: If I call buffer_ref_notify for the wrong (= the unchanged and thus still empty) buffer, Max crashes…
Best, Boris

November 11, 2013 | 8:30 am

Among other things, you need to call this when you receive notifications from the buffer~ for the following scenario:

The buffer~ object is freed

The buffer reference then must be updated to about this event so that it doesn’t do something bad (like try to call into the buffer~ that no longer exists).

In this case you should look at the "sender" parameter to your notify method. You can use an if statement to see which buffer~ it matches and forward as necessary.

– .. —

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > Dev