Lifecycle
constructor bb_bus_open → bb_register_instance → bb_add_output / bb_add_input
restore state bb_set_instance_uid(saved uid) → bb_load_connections(saved text)
audio callback bb_begin_block → bb_read_input … bb_write_output → bb_end_block
save state bb_endpoint_uid → bb_save_connections
UI / timer bb_list_outputs (source menus), bb_connect / bb_disconnect,
bb_endpoint_patch_version (mark the set dirty)
destructor bb_unregister_instance → bb_bus_close
Rules:
- Register in the constructor with UID 0 (a fresh UID), so the instance is on the bus before the host restores its state.
- When the host restores state, call
bb_set_instance_uidwith the saved UID. If it returnsBB_ERR_UID_IN_USE, the user duplicated the device: keep the fresh UID, and still load the saved cables. - Add all inputs before
bb_load_connections. - Save
bb_endpoint_uid(not the UID you asked for) and thebb_save_connectionstext in your plugin state. - Poll
bb_endpoint_patch_versionon the message thread a few times per second. When it changes, tell the host your state changed. In JUCE:updateHostDisplay(ChangeDetails().withNonParameterStateChanged(true)). - Unregister before closing the bus.