Re: Scheme function to output \bookpart {} ?

2015-10-01 Thread Simon Albrecht

On 30.09.2015 01:28, Thomas Morley wrote:

Could you post a fully compilable example for follow readers?


Here’s a demo file showing the entire framework in action (since you 
seemed to be interested in more detail, I included all of it (except for 
style-sheet information), resulting in quite a lot of code).
I’m working on a work by di Lasso with nine pieces divided in two or 
three ‘partes’ each; the framework is designed such as to give the 
possibility of printing any selection of _parts_ (i.e. voices), partes 
and pieces. For the latter, just use multiple \include "scoreN.ily" in 
your print.ly file.
I don’t want to include the actual music, so I made a small, dummy 
example showing the use of some features. Uncomment the respective lines 
from the \scoreBox function definition to use it for SATB.
I hope it becomes clear how the includes are nested; there are some 
TODOs, most notably I must stop using addlyrics, because it 
center-aligns syllables for melismata – that’s the only bug that I know of.
Thanks to everybody for any help which allowed me to make this really 
useful setup.


Yours, Simon
\version "2.19.27"

%% from library/scm-utility.ily

#(define moment->duration
   (lambda (mom)
 (if (not (= 0 (ly:moment-grace mom)))
 (ly:warning "ly:moment->duration omits grace timing"))
 (ly:make-duration 0 0 (ly:moment-main mom
#(define duration-normalize
   (lambda (dur)
 (moment->duration (ly:duration-length dur
#(define music-length-diminish
   (lambda (mu ra) (ly:moment-sub (ly:music-length mu)
 (ly:make-moment ra
#(define music-is-not-empty?
   (lambda (m) (not (equal? (ly:make-moment 0)
(ly:music-length m)

 library/editorial.ily 
\version "2.18"
%{
 With version 2.18.x, \ed Rest and \ed Mmr need the music
expression to be enclosed into {}. From 2.19.x on (at least .8),
this is not required anymore.
%}

editorsColor = #grey
ed =
#(define-music-function (parser location grob col mus)
   (symbol-list-or-symbol? (color? editorsColor) ly:music?)
   ;; for abbreviations, we need a symbol instead of a one-element list
   (let ((grob (if (and (list? grob) (= 1 (length grob)))
   (car grob)
   grob)))
 (case
  grob
  ;; define abbreviations
  ;; which call the function recursively with a value
  ;; leading into the (else) clause
  ;; (or to _another_ abbreviation)
  ;; be careful to avoid infinite recursion :-)
  ;; – abbreviation names must not be actual grob names
  ;; (at least if they’re used in the corresponding
  ;; clause) or recursion will be infinite also
  ;; It is recommended to use singular forms only
  ;; for abbreviations.
  ((Acc) #{ \ed Staff.Accidental
\ed Staff.AccidentalCautionary
\ed Staff.AccidentalSuggestion
$mus #})
  ((Caut) #{ \ed Staff.AccidentalCautionary $mus #})
  ((LedgerLine) #{ % barline is workaround to issue 3949
\once\hide Score.BarLine
\once\hide Score.SpanBar
\bar "|"
\stopStaff
\ed Staff.LedgerLineSpanner {
  \startStaff
  $mus
  \stopStaff
}
\once\hide Score.BarLine
\once\hide Score.SpanBar
\bar "|"
\startStaff #})
  ((Lyrics) #{ \ed LyricText
   \ed LyricHyphen
   \ed LyricExtender
   $mus #})
  ((Mmr) #{ \ed MultiMeasureRest $mus #})
  ((Note) #{ \ed Staff.Accidental
 \ed Beam
 \ed Dots
 \ed Flag
 %\ed LedgerLine
 \ed NoteHead
 \ed Rest
 \ed Stem
 $mus #})
  ((Pitch) #{ \ed NoteHead $mus #})
  ((Suggest) #{ \ed Staff.AccidentalSuggestion $mus #})
  ((StemWithFlag) #{ \ed Stem \ed Flag $mus #})
  ((Tuplet) #{ \ed TupletNumber \ed TupletBracket $mus #})
  ;; ‘normal’ case
  (else
   #{
 \override $grob . color = #col
 \override $grob . layer = -1
 $mus
 \revert $grob . color
 \revert $grob . layer
   #}
ted =
#(define-music-function (parser location col mus)
   ((color? editorsColor) ly:music?)
   #{
 \tweak color #col $mus
   #})

%{
\relative {
  \ed Note { c'8 d16. e32 fis g a16 r bes }
  \ed Script e,2\trill
  \ed Mmr { R1 } % brackets not required anymore in v.2.19.x
}
%}

suggest =
#(define-music-function (mus) (ly:music?)
   (ed 'Acc mus))
suggestNot =
#(define-music-function (mus) (ly:music?)
   #{
 \omit Staff.Accidental
 \omit Staff.AccidentalCautionary
 \omit Staff.AccidentalSuggestion
 $mus
 \undo\omit Staff.Accidental
 \undo\omit Staff.AccidentalCautionary
 \undo\omit Staff.AccidentalSuggestion
   #})

%% printI.ly 

% load personal library files
% 

Re: Scheme function to output \bookpart {} ?

2015-09-30 Thread Thomas Morley
2015-09-29 11:31 GMT+02:00 Simon Albrecht :
> On 24.09.2015 00:22, Simon Albrecht wrote:
>>
>> On 23.09.2015 22:45, Thomas Morley wrote:
>>>
>>> 2015-09-23 17:50 GMT+02:00 Simon Albrecht :

 Hello,

 is it possible to have a Scheme function output a bookpart? In the
 attached
 example and my real-world setup, I get ‘error: bad expression type’.

 TIA, Simon
>>>
>>> Hi Simon,
>>>
>>> this may give you a starting point:
>>>
>>> \version "2.19.27"
>>>
>>> test =
>>> #(define-scheme-function (mus) (ly:music?)
>>>(ly:book-process
>>>  (ly:make-book-part (list (ly:make-score mus)))
>>>  $defaultpaper
>>>  $defaultlayout
>>>  (ly:parser-output-name)))
>>>
>>> m = { c'4 }
>>>
>>> \test \m
>>
>>
>> Shoot, I did find a flaw: I need a \bookpart {}, not a \book, but it needs
>> to contain a \paper block. How can I do that?
>
>
> What a joy: by accident I found in scm/lily-library.scm that for which I was
> looking. It’s the scheme procedure collect-bookpart-for-book, with which I
> could compile the following function to complete my framework for a project:
>
> 
> bookpartBox =
> #(define-scheme-function (parser location roman) (symbol?)
>(collect-bookpart-for-book
>#{
>  \bookpart {
>\paper {
>  system-count = $(assoc-get roman system-count-alist)
>  systems-per-page = 4
>}
>\scoreBox
>  }
>#}))
> 
>
> Yours, Simon



Hi Simon,

great you found something fitting your needs.
Could you post a fully compilable example for follow readers?

Cheers,
  Harm

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


Re: Scheme function to output \bookpart {} ?

2015-09-29 Thread Simon Albrecht

On 24.09.2015 00:22, Simon Albrecht wrote:

On 23.09.2015 22:45, Thomas Morley wrote:

2015-09-23 17:50 GMT+02:00 Simon Albrecht :

Hello,

is it possible to have a Scheme function output a bookpart? In the 
attached

example and my real-world setup, I get ‘error: bad expression type’.

TIA, Simon

Hi Simon,

this may give you a starting point:

\version "2.19.27"

test =
#(define-scheme-function (mus) (ly:music?)
   (ly:book-process
 (ly:make-book-part (list (ly:make-score mus)))
 $defaultpaper
 $defaultlayout
 (ly:parser-output-name)))

m = { c'4 }

\test \m


Shoot, I did find a flaw: I need a \bookpart {}, not a \book, but it 
needs to contain a \paper block. How can I do that?


What a joy: by accident I found in scm/lily-library.scm that for which I 
was looking. It’s the scheme procedure collect-bookpart-for-book, with 
which I could compile the following function to complete my framework 
for a project:



bookpartBox =
#(define-scheme-function (parser location roman) (symbol?)
   (collect-bookpart-for-book
   #{
 \bookpart {
   \paper {
 system-count = $(assoc-get roman system-count-alist)
 systems-per-page = 4
   }
   \scoreBox
 }
   #}))


Yours, Simon

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


Re: Scheme function to output \bookpart {} ?

2015-09-23 Thread David Kastrup
Simon Albrecht  writes:

> On 23.09.2015 23:43, David Kastrup wrote:
>> Thomas Morley  writes:
>>
>>> 2015-09-23 17:50 GMT+02:00 Simon Albrecht :
 Hello,

 is it possible to have a Scheme function output a bookpart? In the attached
 example and my real-world setup, I get ‘error: bad expression type’.

 TIA, Simon
>>> Hi Simon,
>>>
>>> this may give you a starting point:
>>>
>>> \version "2.19.27"
>>>
>>> test =
>>> #(define-scheme-function (mus) (ly:music?)
>>>(ly:book-process
>>>  (ly:make-book-part (list (ly:make-score mus)))
>>>  $defaultpaper
>>>  $defaultlayout
>>>  (ly:parser-output-name)))
>>>
>>> m = { c'4 }
>>>
>>> \test \m
>> Turns out I have some half-finished branch "bookactive" in my
>> repository.  I just don't remember any more what the problem was.
>
> Meaning? That you think about simplifying the interface/making
> something like my first example work? Which would of course be very
> honourable :-)

No, just that I did at one point of time work on that.

-- 
David Kastrup

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


Re: Scheme function to output \bookpart {} ?

2015-09-23 Thread Simon Albrecht

On 23.09.2015 22:45, Thomas Morley wrote:

2015-09-23 17:50 GMT+02:00 Simon Albrecht :

Hello,

is it possible to have a Scheme function output a bookpart? In the attached
example and my real-world setup, I get ‘error: bad expression type’.

TIA, Simon

Hi Simon,

this may give you a starting point:

\version "2.19.27"

test =
#(define-scheme-function (mus) (ly:music?)
   (ly:book-process
 (ly:make-book-part (list (ly:make-score mus)))
 $defaultpaper
 $defaultlayout
 (ly:parser-output-name)))

m = { c'4 }

\test \m


Shoot, I did find a flaw: I need a \bookpart {}, not a \book, but it 
needs to contain a \paper block. How can I do that?


TIA, Simon

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


Re: Scheme function to output \bookpart {} ?

2015-09-23 Thread Simon Albrecht

On 23.09.2015 23:43, David Kastrup wrote:

Thomas Morley  writes:


2015-09-23 17:50 GMT+02:00 Simon Albrecht :

Hello,

is it possible to have a Scheme function output a bookpart? In the attached
example and my real-world setup, I get ‘error: bad expression type’.

TIA, Simon

Hi Simon,

this may give you a starting point:

\version "2.19.27"

test =
#(define-scheme-function (mus) (ly:music?)
   (ly:book-process
 (ly:make-book-part (list (ly:make-score mus)))
 $defaultpaper
 $defaultlayout
 (ly:parser-output-name)))

m = { c'4 }

\test \m

Turns out I have some half-finished branch "bookactive" in my
repository.  I just don't remember any more what the problem was.


Meaning? That you think about simplifying the interface/making something 
like my first example work? Which would of course be very honourable :-)


Yours, Simon

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


Re: Scheme function to output \bookpart {} ?

2015-09-23 Thread Simon Albrecht

On 23.09.2015 22:45, Thomas Morley wrote:

2015-09-23 17:50 GMT+02:00 Simon Albrecht :

Hello,

is it possible to have a Scheme function output a bookpart? In the attached
example and my real-world setup, I get ‘error: bad expression type’.

TIA, Simon

Hi Simon,

this may give you a starting point:

\version "2.19.27"

test =
#(define-scheme-function (mus) (ly:music?)
   (ly:book-process
 (ly:make-book-part (list (ly:make-score mus)))
 $defaultpaper
 $defaultlayout
 (ly:parser-output-name)))


Brilliant! Thank you so much :-)
After figuring out that the $defaultpaper variable contains an empty 
output def and thus may be easily replaced, this fit perfectly.


Yours, Simon

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


Re: Scheme function to output \bookpart {} ?

2015-09-23 Thread David Kastrup
Thomas Morley  writes:

> 2015-09-23 17:50 GMT+02:00 Simon Albrecht :
>> Hello,
>>
>> is it possible to have a Scheme function output a bookpart? In the attached
>> example and my real-world setup, I get ‘error: bad expression type’.
>>
>> TIA, Simon
>
> Hi Simon,
>
> this may give you a starting point:
>
> \version "2.19.27"
>
> test =
> #(define-scheme-function (mus) (ly:music?)
>   (ly:book-process
> (ly:make-book-part (list (ly:make-score mus)))
> $defaultpaper
> $defaultlayout
> (ly:parser-output-name)))
>
> m = { c'4 }
>
> \test \m

Turns out I have some half-finished branch "bookactive" in my
repository.  I just don't remember any more what the problem was.

-- 
David Kastrup

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


Re: Scheme function to output \bookpart {} ?

2015-09-23 Thread Thomas Morley
2015-09-23 17:50 GMT+02:00 Simon Albrecht :
> Hello,
>
> is it possible to have a Scheme function output a bookpart? In the attached
> example and my real-world setup, I get ‘error: bad expression type’.
>
> TIA, Simon

Hi Simon,

this may give you a starting point:

\version "2.19.27"

test =
#(define-scheme-function (mus) (ly:music?)
  (ly:book-process
(ly:make-book-part (list (ly:make-score mus)))
$defaultpaper
$defaultlayout
(ly:parser-output-name)))

m = { c'4 }

\test \m


HTH,
  Harm

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