Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
LilyPond wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Force unparenthesized accidentals
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
If you want to force an accidental in all accidental styles, you will find situations where LilyPond places a (parenthesized) cautionary accidental instead. Here are three methods how to remove the parenthesis from selected cautionary accidentals, based on an example like this: <code>\partial 4 cis''4( | c'')</code> * Precede the pitch with a function call to set a before-line-breaking procedure. Since version 2.16.0 this works both within and outside of a chord definition. * Define a before-line-breaking procedure for all cautionary accidentals, which removes the parenthesis only if the pitch got the ‘force-accidental’ flag by adding the ‘!’. * Add an engraver that checks the force-accidental flag and then removes the parenthesis from the cautionary accidentals. <lilypond version="2.24.0" full> %% http://lsr.di.unimi.it/LSR/Item?id=874 %here starts the snippet: %% http://lsr.di.unimi.it/LSR/Item?id=874 %by: ArnoldTheresius %corrected 2013-03-12: make before-line-breaking procedure and engraver % work on pitches with '!', but not with '?' %partial incompatible: Version "2.12.3" %%% Version 2.14.2 and below: % modern = #(set-accidental-style 'modern) % modernCautionary = #(set-accidental-style 'modern-cautionary) %%% Version 2.16.0 and above: modern = \accidentalStyle modern modernCautionary = \accidentalStyle modern-cautionary %%%% The LILYPOND Standard: \header { tagline = ##f } MusicI = { \key f \major cis''4( c''2) r8 \set doubleSlurs = ##t ges' <b' e'>4( <g' bes'>2.) \set doubleSlurs = ##f } \score { \new Staff { \partial 4 s4*0^"modern:" \modern \MusicI \bar "||" s4*0^"modern-cautionary:" \modernCautionary \MusicI \bar "|." } \header { piece = "LilyPond's default result" } } %%%% Example 1: #(define (remove-parenthesis-from-accidental grob) (let ((accidental (ly:grob-object grob 'accidental-grob))) (if (not (null? accidental)) (ly:grob-set-property! accidental 'parenthesized #f) (display " accidental-grob not found! ")))) unparenthesizeAccidental = #(define-music-function (music) (ly:music?) (set! (ly:music-property music 'tweaks) (acons 'before-line-breaking remove-parenthesis-from-accidental (ly:music-property music 'tweaks))) music) % With 2.16.1 you can define: %{ unparenthesizeAccidental = #(define-music-function (music) (ly:music?) #{ \tweak before-line-breaking #remove-parenthesis-from-accidental $music #}) %} MusicII = { \key f \major cis''4( <\unparenthesizeAccidental c''>2) r8 \set doubleSlurs = ##t ges' <b' e'>4( %%% NOTE! <g' \unparenthesizeAccidental bes'>2.) \set doubleSlurs = ##f } %%% NOTE! % you need to put '\unparenthesizeAccidental' into a chord definition for version 2.14.2 and before, % e.g. '<\unparenthesizeAccidental c''>2)' to make it work with version 2.14.2 and before \score { \new Staff { \partial 4 s4*0^"modern:" \modern \MusicII \bar "||" s4*0^"modern-cautionary:" \modernCautionary \MusicII \bar "|." } \header { piece = \markup \column { "preceding the critical notes/pitches with the user defined function \\unparenthesizeAccidental" "(before version 2.16.0 you had to put this command inside a chord!)" } } } %%%% Example 2: MusicIII = { \key f \major % \partial 4 cis''4( c''!2) r8 \set doubleSlurs = ##t ges' <b' e'>4( <g' bes'!>2.) \set doubleSlurs = ##f } #(define (visit-cautionary-accidentals grob) (let* ((my-notehead-grob (ly:grob-property grob 'cause)) (my-notehead-prob (ly:grob-property my-notehead-grob 'cause)) (accidental-is-forced (and (ly:prob-property my-notehead-prob 'force-accidental #f) (not (ly:prob-property my-notehead-prob 'cautionary #f))))) (if accidental-is-forced (ly:grob-set-property! grob 'parenthesized #f)))) \score { \new Staff { \override AccidentalCautionary.before-line-breaking = #visit-cautionary-accidentals \partial 4 s4*0^"modern:" \modern \MusicIII \bar "||" s4*0^"modern-cautionary:" \modernCautionary \MusicIII \bar "|." } \header { piece = \markup \column { "remove all parenthesis from cautionary accidentals, if a »force« flag is found" "(Exlamation mark »!« after the pitch, and setting the user defined before-line-breaking procedure" "by »\\override AccidentalCautionary.before-line-breaking = #visit-cautionary-accidentals«)" } } } %%%% Example 3: % This will not run on version 2.12.3! #(define (Parenthesis_on_cautionary_accidentals_purger ctx) `((acknowledgers (accidental-interface . ,(lambda (trans grob source) (let ((grob-name (grob::name grob))) (if (equal? (symbol->string grob-name) "AccidentalCautionary") (let* ((my-notehead-grob (ly:grob-property grob 'cause)) (my-notehead-prob (ly:grob-property my-notehead-grob 'cause)) (accidental-is-forced (and (ly:prob-property my-notehead-prob 'force-accidental #f) (not (ly:prob-property my-notehead-prob 'cautionary #f))))) (if accidental-is-forced (ly:grob-set-property! grob 'parenthesized #f)))))))))) \score { \new Staff \with { \consists #Parenthesis_on_cautionary_accidentals_purger } { \partial 4 s4*0^"modern:" \modern \MusicIII \bar "||" s4*0^"modern-cautionary:" \modernCautionary \MusicIII \bar "|." } \header { piece = "remove all parenthesis from cautionary accidentals by an engraver, if a »force« flag is found" } } </lilypond> [[Category:Pitches]] [[Category:Pitches]] [[Category:Chords]] [[Category:Tweaks and overrides]]
Summary:
Please note that all contributions to LilyPond wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Meta:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Force unparenthesized accidentals
Add topic