Fix default_on_toggle and value_map decoding of named float structs - #197
Merged
Conversation
toggle_setup{.init = false} for both default_toggle and default_on_toggle,
so the only thing separating the two was their name: a control declared
halp::toggle<"...", halp::default_on_toggle> came up off.
Nothing caught it because a toggle that reads false is indistinguishable
from one the user turned off, and the binding initialises controls from
range().init in the host but not in a raw struct, so unit tests that
construct the object directly saw the same value either way.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DnNVzm2dPA5iHbSYKrpzZj
to_ossia_value_impl checks for field names before vec-compatibility, so a struct with 2/3/4 float members and halp_field_names is *encoded* as a value_map. The inbound path checked the two in the opposite order, took the vecNf shortcut and called ossia::convert<vecNf>(map), which returns zeroes. The round trip therefore lost the value entirely: a std::vector of such structs - the ordinary shape for detector output - arrived as a list of correctly-sized, entirely zero elements. Route a map through the field-order decoder instead, in both the nested and the top-level overload. Unnamed all-float structs still encode as vecNf and are unaffected, as is a bare vecNf sent by an external source; the regression test in score covers both directions. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnNVzm2dPA5iHbSYKrpzZj
jcelerier
added a commit
to ossia/score
that referenced
this pull request
Aug 23, 2026
libossia brings the filter, tracking and point-tracker primitives the new processes are built on, the sound_utils and time_interval fixes, and safe_isfinite (ossia/libossia#930). Avendish brings the default_on_toggle fix - Entity To MIDI's Invert Axis is declared with it and would otherwise come up off - and the value_map decoding fix, without which a list of named float structs crosses the cable as a list of zeroes (celtera/avendish#197). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnNVzm2dPA5iHbSYKrpzZj
jcelerier
added a commit
to ossia/score
that referenced
this pull request
Aug 23, 2026
libossia brings the filter, tracking and point-tracker primitives the new processes are built on, the sound_utils and time_interval fixes, and safe_isfinite (ossia/libossia#930). Avendish brings the default_on_toggle fix - Entity To MIDI's Invert Axis is declared with it and would otherwise come up off - and the value_map decoding fix, without which a list of named float structs crosses the cable as a list of zeroes (celtera/avendish#197). Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DnNVzm2dPA5iHbSYKrpzZj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two independent bugs found while building a process on top of this binding.
default_on_toggledefaulted to offdefault_toggleanddefault_on_togglewere bothtoggle_setup{.init = false}, so the only thing separating them was the name. Any control declaredhalp::toggle<"...", halp::default_on_toggle>came up off.It stayed invisible because a toggle reading
falselooks exactly like one the user turned off, and the binding initialises controls fromrange().initonly in the host — a unit test constructing the object directly sees the same value either way.A named all-float struct lost its value crossing
ossia::valueto_ossia_value_impltests for field names before vec-compatibility, so a struct with 2/3/4 float members andhalp_field_namesencodes as avalue_map. The inbound path tested the two in the opposite order, took thevecNfshortcut, and calledossia::convert<vecNf>(map)— which returns zeroes.So the round trip silently dropped the data: a
std::vectorof such structs (the ordinary shape for detector or tracker output) arrived as a list of correctly-sized, entirely zero elements. Downstream code saw the right number of entries with every field at 0.Maps are now routed through the field-order decoder in both the nested and the top-level overload. Unnamed all-float structs still encode as
vecNfand are unaffected, as is a barevecNfsent by an external source.Testing
Both directions are covered by a regression test in score (
Tests/from_ossia_value_Test.cpp), which asserts the named struct round-trips, that an unnamed one still encodes asvec3f, and that a plainvec3ffrom an external sender still decodes into a named struct.🤖 Generated with Claude Code
https://claude.ai/code/session_01DnNVzm2dPA5iHbSYKrpzZj