buffer_ref_notify with multiple buffers

Nov 3, 2013 at 5:36am

buffer_ref_notify with multiple buffers

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

#269998
Nov 3, 2013 at 6:23am

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

#270003
Nov 11, 2013 at 8:30am

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.

- .. –

#270763

You must be logged in to reply to this topic.