Skip to content

Add support for segno reading#134

Open
SemitoneGene wants to merge 1 commit into
webern:mainfrom
SemitoneGene:gene/351
Open

Add support for segno reading#134
SemitoneGene wants to merge 1 commit into
webern:mainfrom
SemitoneGene:gene/351

Conversation

@SemitoneGene

Copy link
Copy Markdown
Contributor

Segno are now read and made available in the public API.

@SemitoneGene

Copy link
Copy Markdown
Contributor Author

I also made a fix to catch.h in cpul that was causing a crash when building on the M1.

@SemitoneGene

Copy link
Copy Markdown
Contributor Author

Coda reading added as well.

@SemitoneGene

Copy link
Copy Markdown
Contributor Author

Added rehearsal reading.

In typical Gene fashion, I just realized all these changes only deal with reading. I am working on getting the writer work done.

@SemitoneGene

Copy link
Copy Markdown
Contributor Author

I stubbed in the writing functions, but need to do some more work to understand the correct way to write the info out. Any help is appreciated!

@webern

webern commented Jan 18, 2023

Copy link
Copy Markdown
Owner

I'll take a look.

@webern

webern commented Jan 18, 2023

Copy link
Copy Markdown
Owner

Your commit history lol 😅

Don't push anything else ATM, I'll fix it.

@webern

webern commented Jan 18, 2023

Copy link
Copy Markdown
Owner

I think I fixed the git history at least. I force pushed to your fork and branch (because you can do that with GitHub, it's crazy).

So, Assuming your fork is at "origin", you should:

cd mx
git remote add upstream git@github.com:webern/mx.git
git checkout master
git fetch upstream master
git reset --hard upstream/master
git push origin -f master
git fetch origin gene/351
git checkout gene/351
git reset --hard origin gene/351

The reading side (DirectionReader, the *Data headers and the
DirectionData vectors) already landed on main, so the rebase reduces
to the writer. Port the per-item write-back for segnos, codas and
rehearsals onto the new core API (DirectionTypeChoice factories taking
OneOrMore<...>). These remain stubs: they emit one empty element per
item and do not yet transfer position, color or text.
webern added a commit that referenced this pull request Jun 17, 2026
## Summary

`mx::api` exposed `SegnoData`/`CodaData` but support was partial: the
reader only captured position
and color (and even then never set `isColorSpecified`, so color was
dropped), and the writer emitted
nothing for segno or coda, silently losing them on write.

This widens both data classes to the full `<segno>`/`<coda>` attribute
surface and makes the trip
lossless in both directions:

- Added `fontData`, `smufl` (+ `isSmuflSpecified`), and `id` (+
`isIdSpecified`) to `SegnoData` and
`CodaData`. Position and halign/valign already ride along in
`positionData`.
- `DirectionReader::parseSegno`/`parseCoda` now read font, smufl, id,
and set `isColorSpecified`.
- `DirectionWriter` now writes segno and coda (position, font, color,
smufl, id), replacing the
  lossy `MX_UNUSED` stub proposed in the superseded PR.

Note: `positionData` carries a `placement` member that does not apply to
`<segno>`/`<coda>`
(placement lives on the parent `<direction>`). The read/write helpers
are attribute-tolerant
(`if constexpr (requires ...)`), so this is inert, not a data bug.
Documented in the headers.

## Testing

- [x] New impl round-trip test `segnoAndCodaRoundTrip_DirectionWriter`:
builds a segno and a coda
with every field set, writes via `DirectionWriter`, reads back via
`DirectionReader`, asserts
equality. Passes (8 assertions in 2 test cases with the existing ottava
test).
- [x] `make dev` builds clean; `make fmt` applied.
- [x] Full `make test` deferred to CI.

## TODO (planned, not done in this PR)

- #204 Add an api-level round-trip test over
`data/synthetic/segno.{3.0,3.1}.xml` and
`coda.{3.0,3.1}.xml` (register them in `MxFileRepository`) so the public
`DocumentManager` path is
exercised, not just the impl layer. These fixtures already carry every
attribute (the 3.1 variants
  add `id` and `smufl`).
- #205 Implement rehearsal writing in `DirectionWriter`. Rehearsals are
read but not written; PR #134
bundled a lossy rehearsal writer. Scoped out here to keep this
segno/coda-only.
- #206 Honor `orderedComponents` in `DirectionWriter`. The writer emits
each component kind in its own
loop (segnos, then codas), so direction-type children interleaved with
other kinds are not
guaranteed to round-trip in original order. Pre-existing limitation
surfaced by this work.
- #207 Fix the same latent bug in `parseWords`:
`WordsData.isColorSpecified` is never set on read, so
words color does not round-trip (same bug class fixed here for
segno/coda).

## References

- Closes #133
- Supersedes #134
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