Skip to content

Conversation

@arshiacont
Copy link

Fixes #150

Add a dur unit possibility to TagParameter and parsing in quarter-note.
This feature is fully backward compatible and should not break current behavior.

Info:

  • Adjusted duration-based tag positioning to look up the measure that actually contains the target time (can cross barlines) and compute offsets from that spacing instead of clamping to the current measure; keeps the debug trace for visibility. src/engine/graphic/GRTag.cpp
  • Made measure-bound lookup robust even when only the upcoming barline is present by scanning all barlines, choosing nearest previous/next, and deriving a previous start from the meter (with a 1/1 fallback). This feeds correct widths to duration-based offsets. src/engine/graphic/GRStaff.cpp
  • Apply duration offsets only after position tags finish anchoring so tags have stable positions before we shift them. src/engine/graphic/GRStaff.cpp

(cherry picked from commit f894985)
(cherry picked from commit 5be3cd2)
- Adjusted duration-based tag positioning to look up the measure that actually contains the target time (can cross barlines) and compute offsets from that spacing instead of clamping to the current measure; keeps the debug trace for visibility. src/engine/graphic/GRTag.cpp
- Made measure-bound lookup robust even when only the upcoming barline is present by scanning all barlines, choosing nearest previous/next, and deriving a previous start from the meter (with a 1/1 fallback). This feeds correct widths to duration-based offsets. src/engine/graphic/GRStaff.cpp
- Apply duration offsets only after position tags finish anchoring so tags have stable positions before we shift them. src/engine/graphic/GRStaff.cpp

(cherry picked from commit 0251923)
@dfober
Copy link
Member

dfober commented Dec 4, 2025

Sorry for the slow response. I had started working on it (with a new unit named 'rl' - for relative location), but you were faster.
I have several questions:

  • I didn't quite understand what duration the new unit 'dur' refers to: is it a whole note, a quarter note?
  • looking at the source code, the strategy adopted is based on bars, which means that without bar it shouldn't work. For my part, I was thinking of evaluating the space between 2 successive signs (which frame the tag) to calculate the displacement, which is a bit more complex but more general.
  • I compiled the code but I couldn't get the new unit to work

@arshiacont
Copy link
Author

arshiacont commented Dec 4, 2025

Test and see it on regression-tests/g-issue150.gmn :

  • That's why I used bars: in that example you have several harmonies on a single note with nothing else! Using bars (and my limited knowledge of Guido Internals) was the only way. :)
  • "dur" is in whole note but in Double (I started with fractions but abandonned before getting the parser too messy).
  • I made it work on regression-tests/g-issue150.gmn meaning on Harmony tags! Didn't go much far as to test it on other units.

We can keep iterating this PR until we are satisfied. I will try to setup more unit tests.

@dfober
Copy link
Member

dfober commented Dec 5, 2025

OK. I managed to get it working but it doesn't work as expected, e.g. with this simple case:

[
	\meter<"2/4">
	\i<"p", dx=0.25dur> a  b c a d f g f e d c
]

the 'p' is shifted to the 'c' but it works when the \i is placed after the first 'a'
Maybe using the mapping (already computed) could help for a more general solution. I'll give it a try (but I'm a little overwhelmed).

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.

Feature Request: Relative dx (offset) tag parameter

2 participants