|
From: | Urs Liska |
Subject: | Re: Align above "current" staff |
Date: | Sat, 7 Jul 2018 18:13:49 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 |
Hi David, Am 07.07.2018 um 16:15 schrieb David
Kastrup:
Urs Liska <address@hidden> writes:Hi all, I want a music function to produce an ossia staff. The NR states that in order to place that above alignAboveContext should be used: \new Staff = "main" \relative { c''4 b d c << { c4 b d c } \new Staff \with { \remove "Time_signature_engraver" alignAboveContext = #"main" \magnifyStaff #2/3 firstClef = ##f } { e4 d f e } >> c4 b c2 } But is that also possible when I (or my music-function) doesn't know the staff's nameYou can use \applyContext for getting it before you initiate your own (hopefully uniquely named) Staff. Thank you for the suggestion, which looks like it's what I need. However, unfortunately I didn't get anywhere looking at the various examples in the docs. It's still a mystery to me what does what and evaluates to what and when that happens or not ... OK, \applyContext passes the current context as the single argument to a function. Within that function one can access (retrieve and set) the properties of that context. I can sort of understand what that does in the example with "desaturating" colors. But that function call always returns a (make-music 'ApplyContext ...) music _expression_, which is nothing I can use for my purposes, it seems everything is about the side-effects. So I thought I'd define a variable and have the \applyContext function populate that variable with the context name, so I could use that later. But that doesn't work either, it looks like the \applyContext is only executed *after* I would need to use the variable: \version "2.19.80" ossia = #(define-music-function (music ossia-music) (ly:music? ly:music?) (let ((name "initialized")) #{ \applyContext #(lambda (context) (set! name (ly:context-id (ly:context-parent context))) ; I know this has to be more robust ... (ly:message "1. context name inside \\applyContext: ~a" name) ; the following \new Staff has no effect #{ \new Staff { c' } #}) #(ly:message "2. context name after \\applyContext was called: ~a" name) #music % Create \new Staff with ossia-music #})) \new Staff = "My Staff" \relative { g'8 a b c \ossia { d c b a } { c b a g } g b d b g2 } => Parsing... 2. context name after \applyContext was called: initialized Interpreting music... 1. context name inside \applyContext: My StaffI'm sorry, but I need more concrete pointers or even an example. Thanks Urs |
[Prev in Thread] | Current Thread | [Next in Thread] |