Re: Scheme help? snippet for movement page headers

2017-11-21 Thread Timothy Lanfear

On 21/11/17 05:57, Shevek wrote:

Hi Timothy,

Where are you defining #'header:piece, inside or outside a \score block? To
clarify, I'm talking about using \fromproperty with score-level headers.

Saul




I put every \score inside its own \bookpart and define #'header:piece in 
the \bookpart, outside the \score. Although I don't recall the details 
now, I probably adopted this structure to get the page headers working.


--
Timothy Lanfear, Bristol, UK.


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Werner LEMBERG

> Oh ugh, Nabble wrapped my lines and now it's all ugly. :(

One of the reasons to avoid source code lines longer than, say 78
characters...


Werner

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Oh ugh, Nabble wrapped my lines and now it's all ugly. :(



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Here is a cleaner, updated version of the snippet. It now gives the stencil
the extent of the longest table of contents entry. Not ideal, but close
enough for practical use. Also added comments and cleaned up variable names.

\version "2.18.2"

#(define-markup-command (current-toc-section layout props)
   ()
   (ly:stencil-add (let* ((titles (map cddr (toc-items)))
  (sorted-titles (stable-sort titles (lambda (item1
item2)
   (<= (length
item1) (length item2)
  (biggest-title (interpret-markup layout props
(caar sorted-titles)))
  (x-extent (ly:stencil-extent biggest-title X))
  (y-extent (ly:stencil-extent biggest-title Y))
  )
 (ly:make-stencil
  `(delay-stencil-evaluation
,(delay (ly:stencil-expr
 (let* ((table (ly:output-def-lookup layout
'label-page-table))
(curr-page (chain-assoc-get
'page:page-number props))
;; TOC entries should be at the
beginning of sections/movements.
;; If a section starts mid-page, the
page header will show the new section.
;; To make it show the title
belonging to the first system of the page,
;; Change >= to <= and put TOC
entries at the END of sections.
;; That breaks the actual TOC,
however.
(labels-up-to-curr (filter (lambda
(item) (>= curr-page (cdr item))) table))
(most-recent-toc-page (apply max
(map cdr labels-up-to-curr)))
;; If there are multiple toc items
on the same page, behavior may be undefined.
(most-recent-label (filter (lambda
(item) (eq? (cdr item) most-recent-toc-page)) labels-up-to-curr))
(title-of-curr-label (cadr
(assoc-get (caar most-recent-label) (toc-items
(curr-markup (interpret-markup
layout props
   title-of-curr-label))
;; How do we get the true extent
outside of the delayed evaluation?
;(x-ext (ly:stencil-extent
curr-markup X))
;(y-ext (ly:stencil-extent
curr-markup Y))
)
   ;(set! x-extent x-ext)
   ;(set! y-extent y-ext)
   curr-markup
   
  ;; Currently, we just use the extent of the longest
toc entry for all of them
  x-extent
  y-extent
  ))
 ))

%% Uncomment below to test
% \paper {
%   evenHeaderMarkup = \markup \current-toc-section
%   oddHeaderMarkup = \markup { "foo" \current-toc-section "bar" }
% }
% 
% \score {
%   \new Staff {
% \tocItem "Title 1"
% s1
% \pageBreak
% s1
% 
%   }
% }
% 
% \score {
%   \new Staff {
% \tocItem "Title 2 is long"
% s1
% \pageBreak
% s1
% 
%   }
% }



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Hi Timothy,

Where are you defining #'header:piece, inside or outside a \score block? To
clarify, I'm talking about using \fromproperty with score-level headers.

Saul



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Scheme help? snippet for movement page headers

2017-11-20 Thread Timothy Lanfear

On 20/11/17 08:45, Shevek wrote:

Hi all,

It would be quite nice to be able to use \fromproperty #'header:piece in
oddHeaderMarkup and evenHeaderMarkup, so that the title of the current
movement will display in the page header. Unfortunately, after investigating
the Lilypond source code, I can't see how to make that work, because it
requires the markup command knowing the top system of the current page and
what score it belongs to. That information isn't included in either the
layout or props argument to a markup function.

This works for me. I have a piece with several parts and several pieces 
per part. I print the piece in the odd page header and the part in the 
even page header, except for the first page of the part where I print a 
full title block.


\version "2.19.80"

\paper {
  oddHeaderMarkup = \markup \column {
    \fill-line {
  \null
  \on-the-fly #not-part-first-page \normalsize \fromproperty 
#'header:piece
  \on-the-fly #print-page-number-check-first \number \teeny 
\fromproperty #'page:page-number-string

    }
    \null
  }
  evenHeaderMarkup = \markup \column {
    \fill-line {
  \on-the-fly #print-page-number-check-first \number \teeny 
\fromproperty #'page:page-number-string
  \on-the-fly #print-page-number-check-first \normalsize 
\fromproperty #'header:part

  \null
    }
    \null
  }

}

--
Timothy Lanfear, Bristol, UK.


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Scheme help? snippet for movement page headers

2017-11-20 Thread Shevek
Hi all,

It would be quite nice to be able to use \fromproperty #'header:piece in
oddHeaderMarkup and evenHeaderMarkup, so that the title of the current
movement will display in the page header. Unfortunately, after investigating
the Lilypond source code, I can't see how to make that work, because it
requires the markup command knowing the top system of the current page and
what score it belongs to. That information isn't included in either the
layout or props argument to a markup function.

But! Lilypond has a table of contents feature that is able to find out what
page a particular musical moment happens on, and to print it in a markup.
I've copied and hacked that code to come up with the following very rough
snippet:

\version "2.18.2"

#(define-markup-command (curent-toc-section layout props)
  ()
  (ly:stencil-add (ly:make-stencil
   `(delay-stencil-evaluation
 ,(delay (ly:stencil-expr
  (let* ((table (ly:output-def-lookup layout 'label-page-table))
  (curr (chain-assoc-get 'page:page-number props))
  (prevs (filter (lambda (item) (<= curr (cdr item)))
table))
  (winpage  (apply min (map cdr prevs)))
  (winner (filter (lambda (item) (eq? (cdr item)
winpage)) prevs))
  (wintext (cdr (assoc-get (caar winner) (toc-items
  (winmarkup (interpret-markup layout props
   (car wintext)))
 )
 (display winner)
 (interpret-markup layout props
   (car wintext))

   )))


\paper {
  evenHeaderMarkup = \markup { \curent-toc-section " " }
  oddHeaderMarkup = \markup { \curent-toc-section " " }
}

\score {
  \new Staff {
s1
\pageBreak
s1
\tocItem "Title 1"
  }
}

\score {
  \new Staff {
s1
\pageBreak
s1
\tocItem "Title 2"
  }
}

The idea here is to put a table of contents entry at the very end of the
music for each movement score, so that the page header reflects the first
system of the page. This behavior can almost certainly be improved, so that
the snippet can coexist with an actual table of context listing movement
beginning pages. Maybe the page header should just reflect if a new movement
starts on that page.

I'd much appreciate feedback on this snippet. In particular, I don't quite
understand how the delayed evaluation part of the code works — I just copied
that from the definition of page-ref in define-markup-commands.scm. It seems
silly to define a whole new stencil when in the end it's just a plain old
markup. For page numbers, it's fine to make the stencil the same size every
time using a template, but since my snippet is for movement titles, and
might be used within text flow, it really ought to have a flexible stencil
extent. Currently, the returned stencil has null extent, since I cut out the
fixed-extent code from page-ref.



--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-14 Thread tisimst
Pierre,

I don't think there's anything inherently wrong with what Chris did, as 
long is it works. In general, I think you are right because we know 
that the default code in titling-init.ly works un-modified, then it 
probably should not be changed, just for that sake. However, if someone 
doesn't like the default layout of header variables, then it kind of 
makes sense to me to change it since we also know that you don't have 
to do anything to make sure this file is included in the compile-path. 
It kind of seems like this is the case.

Personally, I'd advocate your solution, since I try to modify the root 
files as little as possible unless I absolutely need to. 

Great example, by the way, of how to customize the header variables! 
I've been meaning to make a post about it on my blog.

Regards,
Abraham

On Wed, Jan 14, 2015 at 1:46 AM, Schneidy [via Lilypond] 
ml-node+s1069038n17044...@n5.nabble.com wrote:
 Hi Chris,
 
 Do you mean that you modifed titling-init.ly ?
 If yes, I don't think it is a good idea...
 
 How about :
 
 \version 2.18.2
 
 \paper {
   oddHeaderMarkup = \markup\on-the-fly #not-part-first-page 
 \fill-line { 
   \null
   \fromproperty #'header:title 
   \on-the-fly \print-page-number-check-first
 \fromproperty #'page:page-number-string
 }
   evenHeaderMarkup = \markup\on-the-fly #not-part-first-page 
   \fill-line { 
 \on-the-fly \print-page-number-check-first
 \fromproperty #'page:page-number-string
 \fromproperty #'header:title 
 \null
   }
 }
 
 \header {
   title = My Title
 }
 
 {
   \repeat unfold 50 { s1*4 \break }
   \bar |.
 }
 
 HTH,
 Pierre
 
 2015-01-14 0:33 GMT+01:00 Chris Trahan [hidden email]:
 I figured it out. I went into the ly/titling-init.ly file and 
 changed this
 line
 
 \on-the-fly #not-part-first-page \fromproperty #'header:instrument
 
 to this line
 
 \on-the-fly #not-part-first-page \fromproperty #'header:title
 
 in both the oddHeaderMarkup variable and the evenHeaderMarkup 
 variable.
 
 Chris
 
 
 
 --
 View this message in context: 
 http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170429.html
 Sent from the User mailing list archive at Nabble.com.
 
 ___
 lilypond-user mailing list
 [hidden email]
 https://lists.gnu.org/mailman/listinfo/lilypond-user
 
 
 ___ 
 lilypond-user mailing list 
 [hidden email] 
 https://lists.gnu.org/mailman/listinfo/lilypond-user
 ~Pierre
 
 
 If you reply to this email, your message will be added to the 
 discussion below:
 http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170445.html
 To start a new topic under User, email 
 ml-node+s1069038n...@n5.nabble.com 
 To unsubscribe from Lilypond, click here.
 NAML




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170461.html
Sent from the User mailing list archive at Nabble.com.___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-14 Thread Chris Trahan
On Wed, Jan 14, 2015 at 2:45 AM, Pierre Perol-Schneider 
pierre.schneider.pa...@gmail.com wrote:

 Hi Chris,

 Do you mean that you modifed titling-init.ly ?
 If yes, I don't think it is a good idea...

 How about :

 \version 2.18.2

 \paper {
   oddHeaderMarkup = \markup\on-the-fly #not-part-first-page
 \fill-line {
   \null
   \fromproperty #'header:title
   \on-the-fly \print-page-number-check-first
 \fromproperty #'page:page-number-string
 }
   evenHeaderMarkup = \markup\on-the-fly #not-part-first-page
   \fill-line {
 \on-the-fly \print-page-number-check-first
 \fromproperty #'page:page-number-string
 \fromproperty #'header:title
 \null
   }
 }

 \header {
   title = My Title
 }

 {
   \repeat unfold 50 { s1*4 \break }
   \bar |.
 }

 HTH,
 Pierre

 2015-01-14 0:33 GMT+01:00 Chris Trahan trahan.ch...@gmail.com:

 I figured it out. I went into the ly/titling-init.ly file and changed
 this
 line

 \on-the-fly #not-part-first-page \fromproperty #'header:instrument

 to this line

 \on-the-fly #not-part-first-page \fromproperty #'header:title

 in both the oddHeaderMarkup variable and the evenHeaderMarkup variable.

 Chris



 --
 View this message in context:
 http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170429.html
 Sent from the User mailing list archive at Nabble.com.

 ___
 lilypond-user mailing list
 lilypond-user@gnu.org
 https://lists.gnu.org/mailman/listinfo/lilypond-user



Pierre,

Yes, that is what I modified. I know that I will need to modify it again
when there is an upgrade to a new version.l I am a computer programmer by
trade.

I will always want the title printed starting on page 2 so I didn't want to
have to put the code that you specified in each score that I do.

I do not need the instrument name printed. I could have also assigned the
title to the instrument variable but preferred to have the title
automatically printed in the header.

Thanks,
Chris
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-14 Thread Pierre Perol-Schneider
Hi Abraham,

2015-01-14 15:24 GMT+01:00 tisimst tisimst.lilyp...@gmail.com:

 Pierre,

 I don't think there's anything inherently wrong with what Chris did, as
 long is it works. In general, I think you are right because we know that
 the default code in titling-init.ly works un-modified, then it probably
 should not be changed, just for that sake. However, if someone doesn't like
 the default layout of header variables, then it kind of makes sense to me
 to change it since we also know that you don't have to do anything to make
 sure this file is included in the compile-path. It kind of seems like this
 is the case.

 Personally, I'd advocate your solution, since I try to modify the root
 files as little as possible unless I absolutely need to.

 Great example, by the way, of how to customize the header variables! I've
 been meaning to make a post about it on my blog
 http://leighverlag.blogspot.com.

 Regards,
 Abraham


Ok, thanks
Piere
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-14 Thread Pierre Perol-Schneider
Ok, I understand.
I remember doing this few years ago for grace, beams and other stettings
such as \super etc. but I quit because it was a headache when upgrading.

Cheers,
Pierre

2015-01-14 17:16 GMT+01:00 Chris Trahan trahan.ch...@gmail.com:


 Pierre,

 Yes, that is what I modified. I know that I will need to modify it again
 when there is an upgrade to a new version.l I am a computer programmer by
 trade.

 I will always want the title printed starting on page 2 so I didn't want
 to have to put the code that you specified in each score that I do.

 I do not need the instrument name printed. I could have also assigned the
 title to the instrument variable but preferred to have the title
 automatically printed in the header.

 Thanks,
 Chris


___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-14 Thread Pierre Perol-Schneider
Hi Chris,

Do you mean that you modifed titling-init.ly ?
If yes, I don't think it is a good idea...

How about :

\version 2.18.2

\paper {
  oddHeaderMarkup = \markup\on-the-fly #not-part-first-page
\fill-line {
  \null
  \fromproperty #'header:title
  \on-the-fly \print-page-number-check-first
\fromproperty #'page:page-number-string
}
  evenHeaderMarkup = \markup\on-the-fly #not-part-first-page
  \fill-line {
\on-the-fly \print-page-number-check-first
\fromproperty #'page:page-number-string
\fromproperty #'header:title
\null
  }
}

\header {
  title = My Title
}

{
  \repeat unfold 50 { s1*4 \break }
  \bar |.
}

HTH,
Pierre

2015-01-14 0:33 GMT+01:00 Chris Trahan trahan.ch...@gmail.com:

 I figured it out. I went into the ly/titling-init.ly file and changed this
 line

 \on-the-fly #not-part-first-page \fromproperty #'header:instrument

 to this line

 \on-the-fly #not-part-first-page \fromproperty #'header:title

 in both the oddHeaderMarkup variable and the evenHeaderMarkup variable.

 Chris



 --
 View this message in context:
 http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170429.html
 Sent from the User mailing list archive at Nabble.com.

 ___
 lilypond-user mailing list
 lilypond-user@gnu.org
 https://lists.gnu.org/mailman/listinfo/lilypond-user

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Page Headers

2015-01-13 Thread Chris Trahan
I would like to put the title of a score as a page header starting on page
2. This would be on the same line as the page number and could be on the
opposite side from the page number or centered on the page.

I can't find out how to do this. I've searched the learning, notation,
snippets, etc.

I find a reference to oddHeaderMarkup and evenHeaderMarkup but no
description of how to use these variables.

Thanks,
Chris
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-13 Thread tisimst
Chris Trahan wrote
 I would like to put the title of a score as a page header starting on page
 2. This would be on the same line as the page number and could be on the
 opposite side from the page number or centered on the page.
 
 I can't find out how to do this. I've searched the learning, notation,
 snippets, etc.
 
 I find a reference to oddHeaderMarkup and evenHeaderMarkup but no
 description of how to use these variables.

Have you looked at:

http://www.lilypond.org/doc/v2.18/Documentation/notation/custom-titles-headers-and-footers
http://www.lilypond.org/doc/v2.18/Documentation/notation/custom-titles-headers-and-footers
  

HTH,
Abraham



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170413.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-13 Thread Chris Trahan
Abraham,

Yes, I have. The example is not very clear and it's only one example.

Chris



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170428.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Page Headers

2015-01-13 Thread Chris Trahan
I figured it out. I went into the ly/titling-init.ly file and changed this
line

\on-the-fly #not-part-first-page \fromproperty #'header:instrument

to this line

\on-the-fly #not-part-first-page \fromproperty #'header:title

in both the oddHeaderMarkup variable and the evenHeaderMarkup variable.

Chris



--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/Page-Headers-tp170410p170429.html
Sent from the User mailing list archive at Nabble.com.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user