Skip to content

Enhance/remove name from params 2 options - #359

Open
tremblap wants to merge 3 commits into
flucoma:mainfrom
tremblap:enhance/remove-name-from-params-2-options
Open

tremblap wants to merge 3 commits into
flucoma:mainfrom
tremblap:enhance/remove-name-from-params-2-options

Conversation

@tremblap

Copy link
Copy Markdown
Member

This is a refactor of #358. It adds 2 interface options for getname and setname and refactors refer:

  • keeping the hack of refer, i.e. putting it in the wrapper
  • putting them in the client, like read/write/load/dump

I prefer the latter. More personal questions in an email. Its tip compiles and works with all CCEs following PRS:

flucoma/flucoma-docs#230
flucoma/flucoma-max#474
flucoma/flucoma-pd#129
flucoma/flucoma-sc#207

The name used to be fixed parameter 0 of every shared client, and the
shared instance adaptor keyed its lookup tables on it, so it could not
change after construction.

The adaptor now owns the name: ParamAliasAdaptor gains name(), setName()
(create-or-join, formerly done in setFixedParameterValues) and rename(),
which re-keys both lookup tables while leaving the shared client and its
parameters untouched. The name parameter and kName are removed from all
shared clients, so remaining parameter indices shift down by one.

Clients that print their name inherit the new NamedObject mixin, which
the adaptor keeps up to date across renames.

Host wrappers need to pass the name through setName() and read it with
name() instead of using parameter 0.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2M1cHdyiJWcPaKy2FRnMe
Both lookup tables hold weak pointers, so an entry can outlive what it
names. Several paths assumed it couldn't:

- ParamAliasAdaptor::refer() left the old data's entry behind when it was
  the data's last user: lookup() then reported the dead name as found,
  and setName() on that name crashed.
- NRTSharedInstanceAdaptor::lookup() and its constructor crashed on an
  entry whose client had gone. That happens when something other than an
  object (e.g. a query) holds a client while its last object goes away.
- rename() onto a name whose client was still held that way succeeded,
  and rekey() then dropped the renamed object's client from the table. It
  dropped it onto a dead entry too.
- The client table's destructor removed whatever entry had its name, not
  only its own (the data table's destructor already checked).

Lookups now treat dead entries as absent without modifying the tables,
since lookup() also runs on audio threads (e.g. FluidKDTreeQuery in
SuperCollider). Dead entries are replaced when their name is registered
again, refer() unregisters data it was the last user of, rename() refuses
a name whose client is still alive, and the client table's destructor
only removes its own entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2M1cHo8cpczLoz3ztCv8Q
Each host wrapper implemented these itself, which kept them out of the
generated documentation and out of reach of tests. NRTSharedInstanceAdaptor
now declares them once, after the client's own messages (NumClientMessages
says where they start), and they act on the adaptor.

To work from inside core, refer must reach every copy of the host object's
parameters: the host's own, and those the threading and sharing adaptors
hold. Copies of a ParamAliasAdaptor therefore now share one Binding, so
re-pointing one re-points them all; mParams-> still reaches the shared
data. refer() also moves the parameter listeners the object added over to
the new data, and fires them so hosts can refresh the values they display.
The client is switched in place, instead of hosts rebuilding theirs.

Behaviour changes for hosts that implemented these themselves:
- refer to an unknown name is an error, always printed, rather than a
  warning printed only when verbose
- refer to the object's own name succeeds (so hosts reply) rather than
  doing nothing
- an object's listeners fire after refer

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J2M1cHo8cpczLoz3ztCv8Q
@tremblap
tremblap requested a review from weefuzzy November 18, 2026 10:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants