Re: function to force accidentals on a subset of notes
This is what happens for me too. I think it has something to do with all the other functions I am using. Oct 30, 2023, 21:25 by l...@gmx.de: > > Hi Michael, > > Am 30.10.23 um 10:42 schrieb Michael Winter: > >> But I am confused about what you said. For me, it is posting the >> accidental on tied notes after line breaks. >> > > No I'm confused. :-) If I do > > > > \transpose a c' \relative > { > a8 gis~ gis g fis g gis a > gis1~ \break gis2 gis > } > > > > in my example file, I get: > > > > > > (To wit, no natural sign on the first b in measure 3). > > > Is this different for you? > > > Lukas > >
Re: function to force accidentals on a subset of notes
Hi Michael, Am 30.10.23 um 10:42 schrieb Michael Winter: But I am confused about what you said. For me, it is posting the accidental on tied notes after line breaks. No I'm confused. :-) If I do \transpose a c' \relative { a8 gis~ gis g fis g gis a gis1~ \break gis2 gis } in my example file, I get: (To wit, no natural sign on the first b in measure 3). Is this different for you? Lukas
Re: function to force accidentals on a subset of notes
Thanks! This seems to work quite well : ) But I am confused about what you said. For me, it is posting the accidental on tied notes after line breaks. Best, Michael Oct 28, 2023, 22:40 by l...@gmx.de: > Hi Michael, > >> Thanks Lukas! >> >> This works but also forces the accidental on tied notes. >> > > Sorry for not getting back to you sooner. > > The following version registers ties and removes our auto-generated > accidentals for notes in which a tie ends. (It's a bit overeager and also > removes tied accidentals after line breaks, so we get a behaviour as if > Accidental.hide-tied-accidental-after-break is set to ##t. Please give word > if you want me to change that.) > > Lukas > > \version "2.24.0" > > forced-accidentals-pitches = > #(music-pitches #{ bes b #}) > > #(define (diatonic-pitch-class= p q) > (and (= (ly:pitch-notename p) (ly:pitch-notename q)) > (= (ly:pitch-alteration p) (ly:pitch-alteration q > > Force_accidentals_engraver = > #(lambda (context) > (let > ((ties '()) > (affected-note-events '())) > (make-engraver > (end-acknowledgers > ((tie-interface engraver grob source-engraver) > (set! ties (cons grob ties > ((stop-translation-timestep engraver) > (for-each > (lambda (tie) > (let* ((right-notehead (ly:spanner-bound tie RIGHT)) > (right-notehead-cause (ly:grob-property right-notehead > 'cause))) > (if (member right-notehead-cause affected-note-events) > (ly:grob-suicide! > ;;; the accidental grob should be guaranteed to > ;;; exist since we forced it into existence... > (ly:grob-object > right-notehead 'accidental-grob) > ties) > (set! ties '()) > (set! affected-note-events '())) > (listeners > ((note-event engraver event) > (when (member (ly:event-property event 'pitch) > forced-accidentals-pitches > diatonic-pitch-class=) > (ly:event-set-property! event 'force-accidental #t) > (set! affected-note-events > (cons event affected-note-events > > \layout { > \context { > \Voice > \consists #Force_accidentals_engraver > } > } > > \transpose a c' \relative > { > a8 gis~ gis g fis g gis a > gis1~ gis2 gis > } >
Re: function to force accidentals on a subset of notes
Hi Michael, Thanks Lukas! This works but also forces the accidental on tied notes. Sorry for not getting back to you sooner. The following version registers ties and removes our auto-generated accidentals for notes in which a tie ends. (It's a bit overeager and also removes tied accidentals after line breaks, so we get a behaviour as if Accidental.hide-tied-accidental-after-break is set to ##t. Please give word if you want me to change that.) Lukas \version "2.24.0" forced-accidentals-pitches = #(music-pitches #{ bes b #}) #(define (diatonic-pitch-class= p q) (and (= (ly:pitch-notename p) (ly:pitch-notename q)) (= (ly:pitch-alteration p) (ly:pitch-alteration q Force_accidentals_engraver = #(lambda (context) (let ((ties '()) (affected-note-events '())) (make-engraver (end-acknowledgers ((tie-interface engraver grob source-engraver) (set! ties (cons grob ties ((stop-translation-timestep engraver) (for-each (lambda (tie) (let* ((right-notehead (ly:spanner-bound tie RIGHT)) (right-notehead-cause (ly:grob-property right-notehead 'cause))) (if (member right-notehead-cause affected-note-events) (ly:grob-suicide! ;;; the accidental grob should be guaranteed to ;;; exist since we forced it into existence... (ly:grob-object right-notehead 'accidental-grob) ties) (set! ties '()) (set! affected-note-events '())) (listeners ((note-event engraver event) (when (member (ly:event-property event 'pitch) forced-accidentals-pitches diatonic-pitch-class=) (ly:event-set-property! event 'force-accidental #t) (set! affected-note-events (cons event affected-note-events \layout { \context { \Voice \consists #Force_accidentals_engraver } } \transpose a c' \relative { a8 gis~ gis g fis g gis a gis1~ gis2 gis }
Re: function to force accidentals on a subset of notes
Thanks Lukas! This works but also forces the accidental on tied notes. Best, Michael Oct 22, 2023, 10:19 by l...@gmx.de: > > Hi Michael, > > > this is easily accomplished with an custom engraver. (I perfectly > understand that the terms "easily" and "custom engraver" don't seem to > go well together at first - I thought so for many years as well -, but > after some getting used to it, the concept is actually quite simple and > elegant.) > > > > \version "2.24.0" > > forced-accidentals-pitches = > #(music-pitches #{ bes b #}) > > #(define (diatonic-pitch-class= p q) > (and (= (ly:pitch-notename p) (ly:pitch-notename q)) > (= (ly:pitch-alteration p) (ly:pitch-alteration q > > Force_accidentals_engraver = > #(lambda (context) > (make-engraver > (listeners > ((note-event engraver event) > (if (member (ly:event-property event 'pitch) > forced-accidentals-pitches > diatonic-pitch-class=) > (ly:event-set-property! event 'force-accidental #t)) > > \layout { > \context { > \Voice > \consists #Force_accidentals_engraver > } > } > > \transpose a c' \relative > { > a8 gis g fis g gis a4 > } > > > > Lukas > > Am 21.10.23 um 11:37 schrieb Michael Winter via LilyPond user discussion: > >> Thanks Jean, >> >> I am not sure I completely follow. >> >> Lets say I have a music sequence: >> >> a b c d e f g a bes c d e f g ... >> >> How do I apply what you have written as a functionto only show the >> flats and naturals for b and bes. Again. I donot want to apply this >> to individual notes. >> >> Sorry if I am missing something. >> >> Best, >> >> Michael >> >> >> Oct 21, 2023, 01:37 by >> j...@abou-samra.fr>> : >> >>> >>> Try >>> >>> \displayMusic c'! >>> >>> This shows you that the >>> !>>> syntax corresponds to setting >>> the >>> force-accidental>>> property to true. Thus, if you >>> have identified the note events you want to force accidentals >>> on, you can do >>> >>> (ly:music-set-property! the-note-event 'force-accidental #t) >>> >>> on each of them. >>> >>> >>> Best, >>> >>> >>> Jean >>> >>> >> >>
Re: function to force accidentals on a subset of notes
Hi Michael, this is easily accomplished with an custom engraver. (I perfectly understand that the terms "easily" and "custom engraver" don't seem to go well together at first - I thought so for many years as well -, but after some getting used to it, the concept is actually quite simple and elegant.) \version "2.24.0" forced-accidentals-pitches = #(music-pitches #{ bes b #}) #(define (diatonic-pitch-class= p q) (and (= (ly:pitch-notename p) (ly:pitch-notename q)) (= (ly:pitch-alteration p) (ly:pitch-alteration q Force_accidentals_engraver = #(lambda (context) (make-engraver (listeners ((note-event engraver event) (if (member (ly:event-property event 'pitch) forced-accidentals-pitches diatonic-pitch-class=) (ly:event-set-property! event 'force-accidental #t)) \layout { \context { \Voice \consists #Force_accidentals_engraver } } \transpose a c' \relative { a8 gis g fis g gis a4 } Lukas Am 21.10.23 um 11:37 schrieb Michael Winter via LilyPond user discussion: Thanks Jean, I am not sure I completely follow. Lets say I have a music sequence: a b c d e f g a bes c d e f g ... How do I apply what you have written as a function to only show the flats and naturals for b and bes. Again. I do not want to apply this to individual notes. Sorry if I am missing something. Best, Michael Oct 21, 2023, 01:37 by j...@abou-samra.fr: Try |\displayMusic c'! | This shows you that the |!| syntax corresponds to setting the |force-accidental| property to true. Thus, if you have identified the note events you want to force accidentals on, you can do |(ly:music-set-property! the-note-event 'force-accidental #t) | on each of them. Best, Jean
Re: function to force accidentals on a subset of notes
Thanks Jean, I am not sure I completely follow. Lets say I have a music sequence: a b c d e f g a bes c d e f g ... How do I apply what you have written as a function to only show the flats and naturals for b and bes. Again. I do not want to apply this to individual notes. Sorry if I am missing something. Best, Michael Oct 21, 2023, 01:37 by j...@abou-samra.fr: > > Try > > \displayMusic c'! > > This shows you that the > !> syntax corresponds to settingthe > > force-accidental> property to true. Thus, if you haveidentified the note > events you want to force accidentalson, you can do > > (ly:music-set-property! the-note-event 'force-accidental #t) > > on each of them. > > > Best, > > > Jean > >
Re: function to force accidentals on a subset of notes
Try ``` \displayMusic c'! ``` This shows you that the `!` syntax corresponds to setting the `force-accidental` property to true. Thus, if you have identified the note events you want to force accidentals on, you can do ``` (ly:music-set-property! the-note-event 'force-accidental #t) ``` on each of them. Best, Jean signature.asc Description: This is a digitally signed message part
function to force accidentals on a subset of notes
I have a piece that is in the following scale: c d e fis g aes bes b Is it possible to force the accidentals just for the bes and the b? But here is the catch... I am both transposing the part and respelling pitch-classes as show below. The scale above is actually the resulting printed set of notes. The music is already generated and I would not want to have to do this manually for each occurance. Thanks in advance, Michael transposePitchClasses = #(define-music-function (scaleA scaleB music) (ly:music? ly:music? ly:music?) (let* ((scaleA (ly:music-property scaleA 'elements)) (scaleB (ly:music-property scaleB 'elements)) (scaleA (map (lambda (x) (ly:music-property x 'pitch)) scaleA)) (scaleB (map (lambda (x) (ly:music-property x 'pitch)) scaleB)) (classesA (map (lambda (p) (cons (ly:pitch-notename p) (ly:pitch-alteration p))) scaleA))) (map-some-music (lambda (m) (let ((p (ly:music-property m 'pitch))) (if (not (null? p)) (let* ((nn (ly:pitch-notename p)) (oct (ly:pitch-octave p)) (alt (ly:pitch-alteration p)) (pos (list-index (lambda (x) (and (= (car x) nn) (= (cdr x) alt))) classesA))) (if pos (let* ((p2 (list-ref scaleA pos)) (oct2 (ly:pitch-octave p2)) (p3 (list-ref scaleB pos)) (new-pitch (ly:pitch-transpose p3 (ly:make-pitch (- oct oct2) 0 (ly:music-set-property! m 'pitch new-pitch))) m) #f))) music) music)) \new Staff \with { instrumentName = #"synth I (2)" shortInstrumentName = #"synI" \remove "Time_signature_engraver" } << \transpose a c' \transposePitchClasses {a b cis dih e fih geh gis} {a b cis dis e f g gis} \include "includes/ammann_part_6.ly" %this is the music >>
Re: auto force accidentals
At 19:16 on 20 Apr 2015, Mátyás Seress wrote: Hi all, I have a question: do you know any command in Lilypond to automatically force those accidentals which have been changed in the preceding measure? Let me give you an example: See Documentation: Notation Reference 1.1.3 Displaying pitches - Automatic accidentals, and choose your preferred accidental style. -- Mark Knoop ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
RE:auto force accidentals
take a look here http://fritz.rmi.de/dokumentation/lilypond/Documentation/user/lilypond/Automatic-accidentals.html HTH Stephen ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
auto force accidentals
Hi all, I have a question: do you know any command in Lilypond to automatically force those accidentals which have been changed in the preceding measure? Let me give you an example: \score { \relative c' { \clef G \key c \major \time 4/4 a8 b c d e f gis a a g f e d c b a } } Because it is annoying that I have to constantly look out for notes like the g in the second measure to code it like g! in order for making the score look nicer. Do you know any good solution on how to automatize this? Thanks in advance, Mat ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: auto force accidentals
Hi guys, thank you for the support! I got the answer! :) Best regards, Mat 2015-04-20 20:17 GMT+02:00 Stephen MacNeil classicalja...@gmail.com: take a look here http://fritz.rmi.de/dokumentation/lilypond/Documentation/user/lilypond/Automatic-accidentals.html HTH Stephen ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: force accidentals
Mehmet a ecrit: I beg your pardon if I did not express myself as well as a native English speaking person. I felt unusually confident I knew what you really meant because I have one of the Universal Editions you were talking about as a reference and we had discussed it a little further. Your english is really very good. The function is very useful and it must be uploaded at the code snippets. I am having trouble with it when I put it in a PianoStaff. Please quote the message to which your replying, in order to bring some context to the discussion I am trying, but it does not happen automatically because I am not subscibed to user-lilypond only lilypond-devel. then engine compares note alterations with the key signature, which contains only non-existant alterations. When I place the functions inside a PianoStaff, it prints a key signature unfortunately. Skipping the explanation, I'll just attach the example I made if you don't mind. The KeySignature print-function override only occurs after the line breaks are set. Removing the engraver nullifies the function entirely. I am wondering if there is a way to override the print-function before line-breaking? Perhaps in the layout block. Or is there a way to get the note alterations we want without creating a key signature. I already experimented with the pitch-alist to no avail. How does tonic (ly:make-pitch -1 4 0) work? I there something we can do there to stop printing the key signature? I think this is the most staight-forward way to manipulate the accidetal_engraver.cc to do what we want without re-writing it, but can it be done without creating a real key signature at all? Alternatively, perhaps I don't understand where to place the function. Or perhaps there might be a way to change the context of the function? Maybe just the right context would put it outside the scope of printing the keysignature while still affecting the notes. Anyway, it is a nice function. Check out atonicKey.ly to see what I am talking about. By the way, the error messages also stopped once it started to print a key signature. Stephen \version 2.6.0 atonicKey = #(def-music-function (parser location) () #{ #(ly:export (make-music 'EventChord 'origin $location 'elements (list (make-music 'KeyChangeEvent 'tonic (ly:make-pitch -1 4 0) 'pitch-alist '((5 . 1) (6 . 1) (0 . 1) (1 . 1) (2 . 1) (3 . 1) (4 . 1)) \set Score . extraNatural = ##f #}) \layout { %\context { \Staff \remove Key_engraver } raggedright = ##t } \context PianoStaff \override PianoStaff.KeySignature #'print-function = ##f \context Staff = upper \transpose c c' { \time 6/8 \tempo 4.=80 \override Score.Hairpin #'height = #'0.5 \override Score.Beam #'auto-knee-gap = #'4.5 \set Score.allowBeamBreak = ##t \override Score.MetronomeMark #'extra-offset = #'(5.0 . 2.0) #(set-accidental-style 'modern-voice) % Add bar numbers in a cirlce every 5th bar \override Score.BarNumber #'break-visibility = #end-of-line-invisible \set Score.barNumberVisibility = #(every-nth-bar-number-visible 5) \override Score.BarNumber #'font-size = #1 \override Score.BarNumber #'print-function = #(make-stencil-circler 0.1 0.25 Text_interface::print) \clef G \atonicKey r8^\markup { \translate #(cons -5.5 2.25) \bold \huge Rasch } e'-.\p f'-. g4^( \ des'8^.) \! | ges es8. ^\ as16( \! d8-.) r b ~ ^\sf | \noBreak b \once \override Script #'extra-offset = #'(0.5 . -0.5) c^^[ \once \override Script #'extra-offset = #'(0.5 . 0.0) a,^^] r r \once \override Script #'extra-offset = #'(0.5 . 0.0) \once \override DynamicText #'extra-offset = #'(-0.9375 . -1.75) as^. ^\p \break { \override Script #'extra-offset = #'(0.5 . 0.0) \override DynamicText #'self-alignment-X = #1 \override DynamicText #'extra-offset = #'(-0.875 . -2.375) ces'-. r r ges[ c']-.- ^\sf } \\ { \override Script #'extra-offset = #'(-0.5 . 0.0) es( d)-. f( ~ f[ e]) } f'\rest | } \context Staff = lower \transpose c c { \clef F \atonicKey r4 r8 bes8.^^\mf[ ces'^^ | des^^ g^^] r8 { { c^\p( a, | d4 gis,16) } \once \override Hairpin #'extra-offset = #'(0.0 . -1.375) { s4 \ | s4*8/45 \once \override Hairpin #'extra-offset = #'(0.0 . -1.8125) s4*22/45 \ s4*3/12 s4*1/12 \! s16 } } \\ { \override Script #'extra-offset = #'(-0.5 . 0.0) f,8-.\pp fis,-. | es,-.[
Re: force accidentals
Stephen [EMAIL PROTECTED] writes: I am not sure what the error message means: warning: accidental `5' not found How is '5' an accidental? Of course, since it's not that's why is can't be found, but how is it that it gets looked for? Stephen Please quote the message to which your replying, in order to bring some context to the discussion: Nicolas Sceaux [EMAIL PROTECTED] writes: Here is *very* dirty trick, which produces lots of warnings, these are the warning you're wondering about. but the output seems to be OK. The good way would be to pay Han-Wen to implement that feature. \version 2.7.0 atonicKey = #(def-music-function (parser location) () #{ #(ly:export (make-music 'EventChord 'origin $location 'elements (list (make-music 'KeyChangeEvent 'tonic (ly:make-pitch -1 4 0) 'pitch-alist '((4 . 5) (5 . 5) (6 . 5) (0 . 5) (1 . 5) (2 . 5) (3 . 5)) \set Score . extraNatural = ##f #}) You can see the '5' accidentals in `pitch-alist'. That's why I called that a very dirty trick: then engine compares note alterations with the key signature, which contains only non-existant alterations. That's why the engine puts alteration on all notes it sees (unless a note with the same pitch and the same octave has been seen before in the same measure). As a side-effect, a warning is produced each time the alterations from the key signature are treated. nicolas ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: force accidentals
I am not sure what the error message means: warning: accidental `5' not found How is '5' an accidental? Of course, since it's not that's why is can't be found, but how is it that it gets looked for? Stephen ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: force accidentals
Nicoas, Mehmet meant to say Can the function be modified to not put an accidental or natural on notes repeated in the same measure. Put it another way and the question is: Can we make the accidental engraver treat the natural exactly the way it treats the sharp and flat? In Atonal music, there is not key signature. Normally, if there are not accidentals in the key signature, that means the key is either C Major or a minor. So how do we indicate on paper that there is no key signature? Simple. Put the natural on the same footing as the sharp and flat, treat each note as if it has an equal chance of being a natural, sharp, or flat. Accidentals are only normally put on a note the first time they occur in a measure, so we want the natural to be treated that way too. Instead of putting an accidental on every note, we want notes repeated in the same measure to be absent an accidental. Somewhere in the function forceAlterations you might have the line: (eqv? (ly:music-property m 'measureLength) 0) checking to see whether the present note is the first occurance of that note (within the same octave, as Mehmet stated) since the measure began. Doing it that way would be cumbersome and might make the function more complicated than it would have to be, but I am indicating what the function should do to engrave Atonal music properly. Shoenberg did note approve to the term 'Atonal'. However, this is how his music was originally published in the Universal Edition engravings. The proper term is 'Music without a Key Signature', but that is not as catchy as 'Atonal'. So how would you enforce the idea that the music has no key signature when absence of accidentals in the key signature indicates C major? The answer is treating the natural the same as the other two accidentals. This could be written into the accidental engraver as a standard style: #(set-accidental-style 'atonal) Stephen ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user
Re: force accidentals
Mehmet Okonsar [EMAIL PROTECTED] writes: can the function be modified for NOT having the alteration or the natural on repeated notes in the same octave.. forceAlterations = #(def-music-function (parser location music) (ly:music?) (music-map (lambda (m) (if (eqv? (ly:music-property m 'name) 'NoteEvent) (set! (ly:music-property m 'force-accidental) #t)) m) music) music) * Please keep discussion on the mailing list. I'm not sure what you exactly want. If you want that alterations of notes on the same octave AND the same bar are not repeated, the quick answer is: I don't know. Otherwise, you might experiment with the following function and try to tailor it to your needs. \version 2.7.0 forceAlterations = #(let ((alteration-memo (make-hash-table 50))) (define (last-alteration ly-pitch) (hash-ref alteration-memo (cons (ly:pitch-notename ly-pitch) (ly:pitch-octave ly-pitch (define (register-alteration! ly-pitch) (hash-set! alteration-memo (cons (ly:pitch-notename ly-pitch) (ly:pitch-octave ly-pitch)) (ly:pitch-alteration ly-pitch))) (def-music-function (parser location music) (ly:music?) (music-map (lambda (m) (if (eqv? (ly:music-property m 'name) 'NoteEvent) (let ((pitch (ly:music-property m 'pitch))) (if (not (equal? (last-alteration pitch) (ly:pitch-alteration pitch))) (set! (ly:music-property m 'force-accidental) #t)) (register-alteration! pitch))) m) music) music)) \forceAlterations { \time 5/4 c' des' e' fis' gis' c' des' e' fis' gis' c' d' e' f' g' c' d' e' f' g' } But I don't think this is near what you want. nicolas ___ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user