Search code examples
puredata

How do I make sure that an instance of an abstraction updates its heights when the subpatch's height changes (purr-data)?


I have made a drum machine abstraction that allows you to choose any number of tracks and make them visible for editing. Here is an example of the patch in use (the object being created is [rhythmbox 5] but the whole point is to be able to enter any number and see that number of tracks with the object height adjusted accordingly).what I want

The problem is that I can't get the created instance to update, the result being that no tracks are visible:

what I get

The tracks are generated correctly in the subpatch and are visible in the subpatch: enter image description here

Once I close that subpatch window, the update happens and the instance looks like the first image.

The main abstraction consists of another abstraction called drumcontrol.pd which is the section that is always visible in the instance (containing preset handling and a time line), and a dynamically-patched subpatch. As you can see in the 3rd image, I am resizing the subpatch GOP area and the main abstraction GOP area, using [donecanvasdialog].

I have read everything that I could find about the resizing process and I have tried sending a [map 0, map 1( refresh message to the main window right after the [donecanvasdialog] message to the main window. This caused purr-data to hang (the patch opened and was blank, so I assume map 0 clears it and then it can't recover but I haven't yet found documentation for this).

I experimented too (unsuccessfully) with using [coords] instead of [donecanvasdialog] but still had the same issue (not impossible that I was using [coords] incorrectly though).


Solution

  • I was using [coords] incorrectly. I removed the [donecanvasdialog] messages and replaced them with corresponding [coords] messages: enter image description here

    This was a little hard to identify because purr data generated its own coords message in the pd file every time I edited it, which caused the file to hang on reload. Watch out for that (v 2.4.9).