[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Moving objects using "wrong" extent --- a question, valid solution n
From: |
Mark Polesky |
Subject: |
Re: Moving objects using "wrong" extent --- a question, valid solution needed! |
Date: |
Mon, 17 May 2010 21:43:23 -0700 (PDT) |
Dmytro O. Redchuk wrote:
> I've found that it's possible to move objects (scripts,
> dynamics..) with "wrong" Y-extent so that they start to overlay
> other objects --- specifying Y-extent like #'(1 . -1) or like
> that
>
> [ ... ]
>
> So, now "i have a lot of questions", specifically:
> 1. Is it "valid" way? May this behavior be changed?
> 2. Which way would be more "valid"?
As documented in the IR, The default height of a hairpin is 0.6666
staff-spaces, so if you want the hairpin to make only enough space
for itself with no extra padding, you could do:
\override DynamicLineSpanner #'Y-extent #'(-0.3333 . 0.3333)
If you want the surrounding items to be placed as if there were no
hairpin, use:
\override DynamicLineSpanner #'Y-extent #'(0 . 0)
Personally, I don't see the benefit in making the lower extent
higher than the upper extent. I think it makes things needlessly
confusing, and I don't think it was designed to be used that way.
Anyway, once you've overridden the DynamicLineSpanner, then you
can adjust the #'Y-offset, though I'd suggest overriding the
#'Y-offset for the Hairpin grob instead of the DynamicLineSpanner:
\override DynamicLineSpanner #'Y-extent = #'(0 . 0)
\override Hairpin #'Y-offset = #0.6666
So setting the Hairpin grob's #'Y-offset to its height value
(0.6666) centers the tip on the bottom staff-line. Adding 1 to
the Y-offset moves it up another line.
If you want to be really fancy, you could write a music function
to do all the work for you:
setHairpinPosition =
#(define-music-function
(parser location staff-position)
(number?)
#{
\once \override DynamicLineSpanner #'Y-extent = #'(0 . 0)
\once \override Hairpin #'Y-offset =
#(lambda (hairpin-grob)
(let ((hairpin-height
(ly:grob-property hairpin-grob 'height)))
(+ 2 hairpin-height (/ $staff-position 2))))
#})
Then you can just do:
\setHairpinPosition #0
to put the hairpin tip on the middle line. The music function
here interprets the numeric argument as a staff-position (ie.,
bottom line = -4, middle line = 0, top line = 4).
I also recommend using \once (as I've done in the above music
function). Things get really confusing when an override is still
in effect from 4 pages ago.
Okay, so the only problem with all of this is that by overriding
the DynamicLineSpanner #'Y-extent, you not only affect the Hairpin
grobs, but unfortunately also the DynamicText grobs, and off the
top of my head, I don't see a trivial way around this. This means
that if you do:
\setHairpinPosition #0 c4\f\> c c c\!
...then the "f" dynamic will be open to collisions, such as with
the staff itself. But maybe that won't be an issue with your
current project? I don't know.
By the way, if you want the hairpin outside the staff, you'll
probably want to set the DynamicLineSpanner's #'Y-extent to
something other than #'(0 . 0).
Well, hopefully this points you in a better direction at least.
It's a bad idea to get in the habit of abusing syntax.
Hope this helps.
- Mark