\version "2.24.0"
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Quelle: https://lilypondforum.de/index.php?msg=5860
#(define script-at-side
(lambda (grob)
(let* ((side-axis (ly:grob-property grob 'side-axis)))
(when (equal? X side-axis)
(let* ((par-x (ly:grob-parent grob X))
(par-y (ly:grob-parent grob Y))
(dir (ly:grob-property grob 'direction))
(nhd
(cond ((grob::has-interface par-x 'note-column-interface)
(car
(ly:grob-array->list
(ly:grob-object par-x 'note-heads))))
((grob::has-interface par-x 'note-head-interface)
par-x)
((grob::has-interface par-y 'note-head-interface)
par-y)
(else (ly:error "Need note-head as parent!"))))
(nc (ly:grob-parent nhd X))
(stem (ly:grob-object nc 'stem))
(nhds (ly:grob-array->list (ly:grob-object nc 'note-heads)))
(conditional-elts-array
(ly:grob-object nc 'conditional-elements #f))
(conditional-elts
(if conditional-elts-array
(ly:grob-array->list conditional-elts-array)
'()))
(acc-placement (ly:note-column-accidentals nc))
(accs
(if (ly:grob? acc-placement)
(map cadr (ly:grob-object acc-placement 'accidental-grobs))
'()))
(dot-col (ly:note-column-dot-column nc))
(dots
(if (ly:grob? dot-col)
(ly:grob-array->list (ly:grob-object dot-col 'dots))
'())))
(ly:grob-set-object! grob 'side-support-elements
(ly:grob-list->grob-array
(append
(list stem)
conditional-elts
nhds
accs
dots)))
(ly:grob-set-parent! grob Y nhd)
(let* ((script-row (ly:grob-object grob 'script-column #f))
(script-row-scripts-array
(if script-row
(ly:grob-object script-row 'scripts #f)
#f))
(script-row-scripts
(if script-row-scripts-array
(ly:grob-array->list script-row-scripts-array)
'()))
(already-offsetted
(filter
(lambda (sc)
(assoc-get
'x-offset-done
(ly:grob-property sc 'details)))
script-row-scripts))
(left-done
(filter
(lambda (sc)
(eqv? dir (ly:grob-property sc 'direction)))
already-offsetted))
(right-done
(filter
(lambda (sc)
(eqv? dir (ly:grob-property sc 'direction)))
already-offsetted)))
(ly:grob-set-object! grob 'side-support-elements
(ly:grob-list->grob-array
(append
left-done
right-done
(ly:grob-array->list
(ly:grob-object grob 'side-support-elements)))))
;; debugging aid
;(ly:grob-set-property! grob 'color cyan)
(ly:grob-set-property! grob 'Y-offset 0)
(ly:grob-set-nested-property! grob '(details x-offset-done) #t)
(ly:grob-set-property! grob 'X-offset
ly:side-position-interface::x-aligned-side)))))))
sideScript =
#(define-event-function (dir mus)(ly:dir? ly:music?)
#{
\tweak before-line-breaking #script-at-side
\tweak side-axis #X
\tweak direction #dir
$mus
#})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% override stencil
tweakPrall = -\tweak stencil
#(lambda (grob)
(ly:make-stencil
'(path 0.1
( lineto 0.5 0.5
lineto 0.5 -0.5
closepath)
round
round
#t)
; x-extend
(cons -0.1 1.5)
; y-extend
(cons 0 1))) \prall
% shortcut
tri = \sideScript #1 \tweakPrall
% example
{
f' \tri
g' \tri
}
\version "2.24.0"
% shortcuts
% Nennt man das 'mute' oder 'chuck'?
mute = { \once \override NoteHead.style = #'xcircle }
{
\parenthesize c'
\mute d'
d'^\lheel
c'^\rheel
}
\version "2.24.0"
\new Staff{
c'1^\markup \fret-diagram-terse #"2 4 6;x;o;1 2;3 9;1 5 12;"
<d a d' f'>1^\markup {
\fret-diagram-verbose #'(
(mute 6)
(place-fret 6 2)
(place-fret 6 4)
(place-fret 6 5)
(place-fret 6 8)
(mute 5)
(open 4)
(place-fret 3 2)
(place-fret 3 5)
(place-fret 2 3)
(place-fret 1 1)
)
}
}
\version "2.19.32"
#(define* (get-pages-line-measures layout pages #:optional print-to-file)
"If @var{print-to-file} is set #t the output is written to a file named like
current one, with attached `-pages-lines-measures.log', otherwise the output is
usually displayed in Terminal"
(let* ((first-page-number (ly:prob-property (car pages) 'page-number))
(port #t)
(lines (map (lambda (page) (ly:prob-property page 'lines)) pages))
;; List of systems of each pages
(page-systems
(map
(lambda (line)
(append-map
(lambda (l) (list (ly:prob-property l 'system-grob #f)))
line))
lines))
;; Get (NonMusical)PaperColumns per line and page
(columns-locations
(map
(lambda (page-system)
(map
(lambda (systems)
(and
systems
;; Last column has the same rhythmic location as the first
;; of the new line, we simply drop it.
(drop-right
(map
grob::rhythmic-location
;; TODO safe to assume always a grob-array?
(ly:grob-array->list
(ly:grob-object systems 'columns)))
1)))
page-system))
page-systems))
;; Get first/last rhythmic location of each relevant
;; (NonMusical)PaperColumn, keep only bar number, drop the moment.
(line-measures
(map
(lambda (col-locs)
(map
(lambda (x)
(if (pair? x)
(list (caar x) (car (last x)))
x))
col-locs))
columns-locations)))
;; Write to a log-file if `print-to-file' is true
(if print-to-file
(let* ((output-name (ly:parser-output-name))
(outfilename
(format #f "~a-pages-lines-measures.log" output-name)))
(set! port (open-output-file outfilename))))
(for-each
(lambda (i measures)
(format port "\nOn page ~a:\n" (+ i first-page-number))
(if (any number-list? measures)
(for-each
(lambda (x)
(format port "~3tLine from ~a to ~a\n" (car x) (last x)))
(filter number-list? measures))
(format port "~3tno measures\n")))
(iota (length pages) 0 1)
line-measures)
(if (output-port? port)
(close-output-port port))))
\paper {
%% first-page-number is taken into account
%first-page-number = 3
#(define (page-post-process layout pages)
(get-pages-line-measures layout pages #f))
}
%%%%%%%%%%%%%%%%%%%%%%%
%% EXAMPLES
%%%%%%%%%%%%%%%%%%%%%%%
{
%\repeat unfold 1000 { c'1 }
\repeat unfold 32 {c'32}
\repeat unfold 999 { c'1 }
}
%% Advanced examples:
%{
\header { title = "TITLE" }
\pageBreak
\score {
\new Staff {
\repeat unfold 2 {
\time 4/4 c''1
\time 3/4 d''2.
\time 3/8 e''8 8 8
}
}
}
\pageBreak
\markup "MARKUP"
\pageBreak
\score {
\new Staff {
\repeat unfold 2 {
\time 4/4 c''1
\time 3/4 d''2.
\pageBreak
\time 3/8 e''8 8 8
}
}
}
\score {
\new Staff {
\repeat unfold 2 {
\time 4/4 c''1
\time 3/4 d''2.
\time 3/8 e''8 8 8
}
}
}
%}