Hi Greg, Hi Lukas, Here is a slightly more powerful approach.
Cheers,
Valentin
Am Freitag, 7. Jänner 2022, 23:14:41 CET schrieb Lukas-Fabian Moser:
> Hi Greg,
>
> Am 07.01.22 um 22:05 schrieb Gregory Hollands:
> > This solution sounds ideal.
> > I would prefer to add the articulations directly to the music and just
> > filter them out when necessary.
>
> Valentin already gave a solution involving a music function.
>
> A dynamic solution (that might be switched on and off during a piece)
> would be:
>
> \version "2.22"
>
> removeArticulations =
> #(define-music-function (types) (list?)
> #{
> \override Script.before-line-breaking =
> #(lambda (grob)
> (if (member (ly:event-property (event-cause grob)
> 'articulation-type)
> types)
> (ly:grob-suicide! grob)))
> #})
>
> \layout {
> \removeArticulations #'("downbow" "upbow")
> }
>
> { c'4\downbow d'\upbow }
>
> Note that this will not work anymore with 2.23.6; the corresponding
> solution will then be a bit nicer syntax-wise:
>
> \version "2.23.6"
>
> removeArticulations =
> #(define-music-function (types) (symbol-list?)
> #{
> \override Script.before-line-breaking =
> #(lambda (grob)
> (if (memq (ly:event-property (event-cause grob)
> 'articulation-type)
> types)
> (ly:grob-suicide! grob)))
> #})
>
> \layout {
> \removeArticulations downbow, upbow
> }
>
> { c'4\downbow d'\upbow }
>
> Also Valentin's solution will have to be changed to:
>
> \version "2.23.6"
>
> chooseArticulations =
> #(define-music-function (arts music) (symbol-list? ly:music?)
> (define (predicate music)
> (if (music-is-of-type? music 'articulation-event)
> (let ((type (ly:music-property music
> 'articulation-type)))
> (memq type arts))
> #t))
> (music-filter predicate music))
>
> Chords = \chords {
> \set chordChanges = ##t
> c1 c1 f2 g2 c1
> }
>
> Music = \relative c' {
> e8\downbow dis e g\upbow ~ g4 e\downbow
> g8 a g c ~ c8 b c d
> e d c b c d4 c8 ~
> c2. r4
> }
>
> \chooseArticulations downbow <<
> \Chords
> \new Staff \new Voice <<
> \Music
> >>
>
>
> \chooseArticulations upbow <<
> \Chords
> \new Staff \new Voice <<
> \Music
> >>
>
>
> \chooseArticulations downbow, upbow <<
> \Chords
> \new Staff \new Voice <<
> \Music
> >>
>
>
> Although I'm a bit surprised that Valentin let you choose what
> articulations to keep instead of what articulations to remove. This
> would be done with:
>
> removeArticulations =
> #(define-music-function (arts music) (list? ly:music?)
> (define (predicate music)
> (if (music-is-of-type? music 'articulation-event)
> (let ((type (ly:music-property music
> 'articulation-type)))
> (not (member type arts)))
> #t))
> (music-filter predicate music))
>
> or from 2.23.6
>
> removeArticulations =
> #(define-music-function (arts music) (symbol-list? ly:music?)
> (define (predicate music)
> (if (music-is-of-type? music 'articulation-event)
> (let ((type (ly:music-property music
> 'articulation-type)))
> (not (memq type arts)))
> #t))
> (music-filter predicate music))
>
> with the corresponding changes in calling syntax.
>
> Lukas\version "2.22"
#(define DEFAULT_DISPLAY #f) %%$ Should scripts be displayed by default? If set to #f we’ll choose our script-types, else we remove them
\layout {
\override Script.stencil =
#(grob-transformer 'stencil
(lambda (grob orig)
(let* ((key (string->symbol (ly:event-property (event-cause grob) 'articulation-type)))
(details (ly:grob-property grob 'details))
(dispvec (assoc-get 'display details #f))
(default (if dispvec (assoc-get 'default dispvec DEFAULT_DISPLAY) DEFAULT_DISPLAY))
(disp (if dispvec (assoc-get key dispvec default) default)))
(if disp orig empty-stencil))))
}
Chords = \chords {
\set chordChanges = ##t
c1 c1 f2 g2 c1
}
Music = \relative c' {
e8\downbow dis e g\upbow ~ g4 e\downbow
g8-> a-- g-. c ~ c8 b c d
e d c b c d4 c8 ~
c2. r4
}
sys=
<<
\Chords
\new Staff \new Voice <<
\Music
>>
>>
\score {
\sys
\layout {
\override Script.details.display.default = ##t
}
}
\score {
\sys
\layout {
\override Script.details.display.default = ##f
}
}
%%% CHOOSE articulation
\score {
\sys
\layout {
\override Script.details.display.default = ##f
\override Script.details.display.upbow = ##t
\override Script.details.display.downbow = ##t
}
}
%%% REMOVE articulation
\score {
\sys
\layout {
\override Script.details.display.default = ##t
\override Script.details.display.upbow = ##f
\override Script.details.display.downbow = ##f
}
}
Music = \relative c' {
e8\downbow dis-> e-- g\upbow ~ g4 e\downbow
e8\downbow dis-> e-- g\upbow ~ g4 e\downbow
e8\downbow dis-> e-- g\upbow ~ g4 e\downbow
}
<<
\Music
{
\override Script.details.display.default = ##f
\override Script.details.display.upbow = ##t
\override Script.details.display.downbow = ##t
s1
\revert Script.details.display.upbow
\revert Script.details.display.downbow
s
\override Script.details.display.default = ##t
\override Script.details.display.upbow = ##f
\override Script.details.display.downbow = ##f
}
>>
signature.asc
Description: This is a digitally signed message part.
