Re: Horizontal shifting of chords
> > -- Forwarded message -- > From: Robert Blackstone > To: lilypond-user > Cc: > Bcc: > Date: Mon, 4 Feb 2019 08:59:30 +0100 > Subject: Horizontal shifting of chords > Hi All, > > I have been transcribing a piano piece in \time 4/2, that ends with a > chord \breve. The penultimate bar ends with the same chord half note. > What LilyPond does here I find rather ugly : both chords need more space, > and I would like to center the breve and increase the distance between the > penultimate chord and the bar line. > The available space would be would be more than sufficient. > This is what I want: > > This is what I get: > > I have not been able to get what I want. \override > NoteColumn.force-hshift = #x (some value) does nothing. I have tried to > cheat a bit by surreptitiously changing the "time" of the last 2 bars from > 4/2 to 6/2 and add a hidden whole note to the end of the penultimate bar > and to the beginnig of te final bar but nothing changes. > > Has anybody a suggestion or advice? > > Thanks in advance. > > Best regards, > > Robert Blackstone > I saw you got lots of answers that approached this from a space tweaking perspective. I wanted to offer another approach, which is to insert a spacer rest before your final chord and then scale the chord as appropriate. You can pick the duration of rest that suits your taste. This has the slight benefit, as compared to tweaking specific horizontal values, that it will scale if you change page layouts, when the measure takes up different amounts of space. It has the downside that, if you are also doing midi output, you would need to use tags to differentiate content for layout and midi blocks. \layout { line-width = 5\in ragged-right = ##f } { c''4 4 4 4 | s32 c''1*31/32 \bar "|." } { c''4 4 4 4 | s16 c''1*15/16 \bar "|." } { c''4 4 4 4 | s8 c''1*7/8 \bar "|." } { c''4 4 4 4 | s4 c''1*3/4 \bar "|." } Elaine Alt 415 . 341 .4954 "*Confusion is highly underrated*" ela...@flaminghakama.com Producer ~ Composer ~ Instrumentalist ~ Educator -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Horizontal shifting of chords
Hi Robert, > I will have a go with the extensive and complicated thing you forwarded. (But > not today. ) You can also go with a short and simple, but manually-set, thing: \layout { line-width = 5\in ragged-right = ##f } { c''4 4 4 4 \tweak extra-offset #'(6.75 . 0) 1 \bar "|." } Hope that helps! Kieren. Kieren MacMillan, composer ‣ website: www.kierenmacmillan.info ‣ email: i...@kierenmacmillan.info ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Horizontal shifting of chords
Hi Andrew, Thank you for your reaction. I can understand that you did not understand why I wanted to centre the final chord. I was thinking of the perectly centered final rests, and if the last bar had not contained a \breve chord but a rest R1*2 would have produced it. I thought that such a thing should somehow also be possible for a chord but I could not find out how. Hence the subject title of my question. I will have a go with the extensive and complicated thing you forwarded. (But not today. ) Best regards, Robert On 4 Feb 2019, at 10:07 , Andrew Bernard wrote: > You asked to centre the chord, but then if you add barline offset it's not > centred, so I am a bit confused what you mean. although the picture makes it > clear. > > I just wanted to say that there are often times when you really do want to > centre a chord or a rest in a single, especially in Baroque music. To this > end, when I asked about this in the past, David Nalesnik and Thomas Morley > produced this excellent code. Note that it only works for one thing in a bar, > but it's great. > > Hope this may help. > > One of those things that ought to go in LSR I suppose. > > > Andrew > > % > % Thanks to David Nalesnik and Thomas Morley. > > #(define (sort-by-X-coord sys grob-lst) >"Arranges a list of grobs in ascending order by their X-coordinates" >(let* ((X-coord (lambda (x) (ly:grob-relative-coordinate x sys X))) > (comparator (lambda (p q) (< (X-coord p) (X-coord q) > > (sort grob-lst comparator))) > > #(define (find-bounding-grobs note-column grob-lst) >(let* ((sys (ly:grob-system note-column)) > (X-coord (lambda (n) (ly:grob-relative-coordinate n sys X))) > (note-column-X (X-coord note-column))) > > (define (helper lst) >(if (and (< (X-coord (car lst)) note-column-X) > (> (X-coord (cadr lst)) note-column-X)) >(cons (car lst) (cadr lst)) >(if (null? (cddr lst)) >(cons note-column note-column) >(helper (cdr lst) > > (helper grob-lst))) > > #(define (read-out ls1 ls2 ls3 symbol) >"Filters all elements of ls1 from ls2 and appends it to ls3" >(set! ls3 (append ls3 (filter (lambda (x) (eq? (car ls1) (symbol x))) > ls2))) >(if (null? (cdr ls1)) >ls3 >(read-out (cdr ls1) ls2 ls3 symbol))) > > #(define ((center-note-column x-offs) grob) >(let* ((sys (ly:grob-system grob)) > (elements-lst (ly:grob-array->list (ly:grob-object sys > 'all-elements))) > (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))) > (X-extent (lambda (q) (ly:grob-extent q sys X))) > ;; NoteColumn > (note-column-coord (ly:grob-relative-coordinate grob sys X)) > (grob-ext (X-extent grob)) > (grob-length (interval-length grob-ext)) > ;; NoteHeads > (note-heads (ly:grob-object grob 'note-heads)) > (note-heads-grobs (if (not (null? note-heads)) > (ly:grob-array->list note-heads) > '())) > (one-note-head (if (not (null? note-heads-grobs)) > (car note-heads-grobs) > '())) > (one-note-head-length (if (not (null? one-note-head)) > (interval-length (X-extent > one-note-head)) ;; NB > 0)) > ;; Stem > (stem (ly:grob-object grob 'stem)) > (stem-dir (ly:grob-property stem 'direction)) > (stem-length-x (interval-length (X-extent stem))) ;; NB > ;; DotColumn > (dot-column (ly:note-column-dot-column grob)) > ;; AccidentalPlacement > (accidental-placement (ly:note-column-accidentals grob)) > ;; Arpeggio > (arpeggio (ly:grob-object grob 'arpeggio)) > ;; Rest > (rest (ly:grob-object grob 'rest)) > ;; Grobs to center between > (args (list 'BarLine > 'Clef > 'KeySignature > 'KeyCancellation > 'TimeSignature)) > (grob-lst (read-out args elements-lst '() grob-name)) > (new-grob-lst (remove (lambda (x) (interval-empty? (X-extent x))) > grob-lst)) > (sorted-grob-lst (sort-by-X-coord sys new-grob-lst)) > ;; Bounds > (bounds (find-bounding-grobs grob sorted-grob-lst)) > (left (cdr (X-extent (car bounds > (right (car (X-extent (cdr bounds > > ;;(bounds-coord (cons left right)) ;; delete > > (basic-offset >(- (average left right) > (interval-center (X-extent grob)) > (* -1 x-offs))) > (dir-correction >(if (> grob-length one-note-head-length) >(* stem-dir (* -2 stem-length-x) grob-length)
Re: Horizontal shifting of chords
Thanks Lukas, This also works nicely. I have added this override to my list of overrides which still is, as I realize now, very incomplete. Also I had not, up till now, realized that when looking for a solution of a problem in "learning.pdf" or" notation.pdf", or on the LilyPond website, one has to be familiar with items such as "Score.Barline" and operations such as "break.visibility". Thanks again. Best regards, Robert Blackstone On 4 Feb 2019, at 09:52 , Lukas-Fabian Moser wrote: > \version "2.19.82" > > \new Staff { > a4 a a a \once \override Score.BarLine.X-extent = #'(-10 . 15) > a > } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Horizontal shifting of chords
Am Mo., 4. Feb. 2019 um 10:35 Uhr schrieb Andrew Bernard : > > Hi Robert, > > You asked to centre the chord, but then if you add barline offset it's not > centred, so I am a bit confused what you mean. although the picture makes it > clear. > > I just wanted to say that there are often times when you really do want to > centre a chord or a rest in a single, especially in Baroque music. To this > end, when I asked about this in the past, David Nalesnik and Thomas Morley > produced this excellent code. Note that it only works for one thing in a bar, > but it's great. > > Hope this may help. > > One of those things that ought to go in LSR I suppose. > > > Andrew > > % > % Thanks to David Nalesnik and Thomas Morley. > > #(define (sort-by-X-coord sys grob-lst) >"Arranges a list of grobs in ascending order by their X-coordinates" >(let* ((X-coord (lambda (x) (ly:grob-relative-coordinate x sys X))) > (comparator (lambda (p q) (< (X-coord p) (X-coord q) > > (sort grob-lst comparator))) > > #(define (find-bounding-grobs note-column grob-lst) >(let* ((sys (ly:grob-system note-column)) > (X-coord (lambda (n) (ly:grob-relative-coordinate n sys X))) > (note-column-X (X-coord note-column))) > > (define (helper lst) >(if (and (< (X-coord (car lst)) note-column-X) > (> (X-coord (cadr lst)) note-column-X)) >(cons (car lst) (cadr lst)) >(if (null? (cddr lst)) >(cons note-column note-column) >(helper (cdr lst) > > (helper grob-lst))) > > #(define (read-out ls1 ls2 ls3 symbol) >"Filters all elements of ls1 from ls2 and appends it to ls3" >(set! ls3 (append ls3 (filter (lambda (x) (eq? (car ls1) (symbol x))) > ls2))) >(if (null? (cdr ls1)) >ls3 >(read-out (cdr ls1) ls2 ls3 symbol))) > > #(define ((center-note-column x-offs) grob) >(let* ((sys (ly:grob-system grob)) > (elements-lst (ly:grob-array->list (ly:grob-object sys > 'all-elements))) > (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))) > (X-extent (lambda (q) (ly:grob-extent q sys X))) > ;; NoteColumn > (note-column-coord (ly:grob-relative-coordinate grob sys X)) > (grob-ext (X-extent grob)) > (grob-length (interval-length grob-ext)) > ;; NoteHeads > (note-heads (ly:grob-object grob 'note-heads)) > (note-heads-grobs (if (not (null? note-heads)) > (ly:grob-array->list note-heads) > '())) > (one-note-head (if (not (null? note-heads-grobs)) > (car note-heads-grobs) > '())) > (one-note-head-length (if (not (null? one-note-head)) > (interval-length (X-extent > one-note-head)) ;; NB > 0)) > ;; Stem > (stem (ly:grob-object grob 'stem)) > (stem-dir (ly:grob-property stem 'direction)) > (stem-length-x (interval-length (X-extent stem))) ;; NB > ;; DotColumn > (dot-column (ly:note-column-dot-column grob)) > ;; AccidentalPlacement > (accidental-placement (ly:note-column-accidentals grob)) > ;; Arpeggio > (arpeggio (ly:grob-object grob 'arpeggio)) > ;; Rest > (rest (ly:grob-object grob 'rest)) > ;; Grobs to center between > (args (list 'BarLine > 'Clef > 'KeySignature > 'KeyCancellation > 'TimeSignature)) > (grob-lst (read-out args elements-lst '() grob-name)) > (new-grob-lst (remove (lambda (x) (interval-empty? (X-extent x))) > grob-lst)) > (sorted-grob-lst (sort-by-X-coord sys new-grob-lst)) > ;; Bounds > (bounds (find-bounding-grobs grob sorted-grob-lst)) > (left (cdr (X-extent (car bounds > (right (car (X-extent (cdr bounds > > ;;(bounds-coord (cons left right)) ;; delete > > (basic-offset >(- (average left right) > (interval-center (X-extent grob)) > (* -1 x-offs))) > (dir-correction >(if (> grob-length one-note-head-length) >(* stem-dir (* -2 stem-length-x) grob-length) >0)) > > ) ;; End of Defs in let* > > ;; Calculation > (begin > ;;(display "\n\tbounds: \t")(write bounds) > (for-each >(lambda (x) > (cond ((ly:grob? x) > (ly:grob-translate-axis! > x > (- basic-offset dir-correction) > X >(list > (cond ((not (null? note-heads)) grob)) > dot-column accidental-placement arpeggio rest)) > ))) > > centerNoteColumnOn = \overri
Re: Horizontal shifting of chords
Hi Robert, You asked to centre the chord, but then if you add barline offset it's not centred, so I am a bit confused what you mean. although the picture makes it clear. I just wanted to say that there are often times when you really do want to centre a chord or a rest in a single, especially in Baroque music. To this end, when I asked about this in the past, David Nalesnik and Thomas Morley produced this excellent code. Note that it only works for one thing in a bar, but it's great. Hope this may help. One of those things that ought to go in LSR I suppose. Andrew % % Thanks to David Nalesnik and Thomas Morley. #(define (sort-by-X-coord sys grob-lst) "Arranges a list of grobs in ascending order by their X-coordinates" (let* ((X-coord (lambda (x) (ly:grob-relative-coordinate x sys X))) (comparator (lambda (p q) (< (X-coord p) (X-coord q) (sort grob-lst comparator))) #(define (find-bounding-grobs note-column grob-lst) (let* ((sys (ly:grob-system note-column)) (X-coord (lambda (n) (ly:grob-relative-coordinate n sys X))) (note-column-X (X-coord note-column))) (define (helper lst) (if (and (< (X-coord (car lst)) note-column-X) (> (X-coord (cadr lst)) note-column-X)) (cons (car lst) (cadr lst)) (if (null? (cddr lst)) (cons note-column note-column) (helper (cdr lst) (helper grob-lst))) #(define (read-out ls1 ls2 ls3 symbol) "Filters all elements of ls1 from ls2 and appends it to ls3" (set! ls3 (append ls3 (filter (lambda (x) (eq? (car ls1) (symbol x))) ls2))) (if (null? (cdr ls1)) ls3 (read-out (cdr ls1) ls2 ls3 symbol))) #(define ((center-note-column x-offs) grob) (let* ((sys (ly:grob-system grob)) (elements-lst (ly:grob-array->list (ly:grob-object sys 'all-elements))) (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))) (X-extent (lambda (q) (ly:grob-extent q sys X))) ;; NoteColumn (note-column-coord (ly:grob-relative-coordinate grob sys X)) (grob-ext (X-extent grob)) (grob-length (interval-length grob-ext)) ;; NoteHeads (note-heads (ly:grob-object grob 'note-heads)) (note-heads-grobs (if (not (null? note-heads)) (ly:grob-array->list note-heads) '())) (one-note-head (if (not (null? note-heads-grobs)) (car note-heads-grobs) '())) (one-note-head-length (if (not (null? one-note-head)) (interval-length (X-extent one-note-head)) ;; NB 0)) ;; Stem (stem (ly:grob-object grob 'stem)) (stem-dir (ly:grob-property stem 'direction)) (stem-length-x (interval-length (X-extent stem))) ;; NB ;; DotColumn (dot-column (ly:note-column-dot-column grob)) ;; AccidentalPlacement (accidental-placement (ly:note-column-accidentals grob)) ;; Arpeggio (arpeggio (ly:grob-object grob 'arpeggio)) ;; Rest (rest (ly:grob-object grob 'rest)) ;; Grobs to center between (args (list 'BarLine 'Clef 'KeySignature 'KeyCancellation 'TimeSignature)) (grob-lst (read-out args elements-lst '() grob-name)) (new-grob-lst (remove (lambda (x) (interval-empty? (X-extent x))) grob-lst)) (sorted-grob-lst (sort-by-X-coord sys new-grob-lst)) ;; Bounds (bounds (find-bounding-grobs grob sorted-grob-lst)) (left (cdr (X-extent (car bounds (right (car (X-extent (cdr bounds ;;(bounds-coord (cons left right)) ;; delete (basic-offset (- (average left right) (interval-center (X-extent grob)) (* -1 x-offs))) (dir-correction (if (> grob-length one-note-head-length) (* stem-dir (* -2 stem-length-x) grob-length) 0)) ) ;; End of Defs in let* ;; Calculation (begin ;;(display "\n\tbounds: \t")(write bounds) (for-each (lambda (x) (cond ((ly:grob? x) (ly:grob-translate-axis! x (- basic-offset dir-correction) X (list (cond ((not (null? note-heads)) grob)) dot-column accidental-placement arpeggio rest)) ))) centerNoteColumnOn = \override Staff.NoteColumn #'after-line-breaking = #(center-note-column 0) centerNoteColumnOff = \revert Staff.NoteColumn #'after-line-breaking onceCenterNoteColumn = #(define-music-function (x-offs)(number?) #{ \once \override Staff.NoteColumn #'after-line-breaking = #(center-note-column x-offs) #}) %=
Re: Horizontal shifting of chords
I have not been able to get what I want. \override NoteColumn.force-hshift = #x (some value) does nothing. I have tried to cheat a bit by surreptitiously changing the "time" of the last 2 bars from 4/2 to 6/2 and add a hidden whole note to the end of the penultimate bar and to the beginnig of te final bar but nothing changes. A slightly different variant would be: \version "2.19.82" \new Staff { a4 a a a \once \override Score.BarLine.X-extent = #'(-10 . 15) a } Best Lukas ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Horizontal shifting of chords
Hi Malte, Many thanks for your reaction. Did it help? Sure, or rather, you gave me the solution for my problem with "\once \override Staff.BarLine.extra-spacing-width = #'(-10 . 10)". I had never seen this anywhere up till now. So I didn't even have to use your testexample. But I will definitely save it in my collection of LilyPond testfiles Thanks again. Best regards, Robert Blackstone On 4 Feb 2019, at 09:23 , Malte Meyn wrote: > > > Am 04.02.19 um 08:59 schrieb Robert Blackstone: >> Hi All, >> I have been transcribing a piano piece in \time 4/2, that ends with a chord >> \breve. The penultimate bar ends with the same chord half note. >> What LilyPond does here I find rather ugly : both chords need more space, >> and I would like to center the breve and increase the distance between the >> penultimate chord and the bar line. >> The available space would be would be more than sufficient. >> […] >> Has anybody a suggestion or advice? > > Hi Robert, > > please always give a minimal code example. Does the following help? > > %%% > > \version "2.19.82" > \language "deutsch" > > \new PianoStaff << > \new Staff { >\time 4/2 >2 q q q >\once \override Staff.BarLine.extra-spacing-width = #'(-10 . 10) >q\breve > } > \new Staff { >\clef bass >2 q q q >q\breve > } > >> > > ___ > lilypond-user mailing list > lilypond-user@gnu.org > https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Horizontal shifting of chords
Am 04.02.19 um 08:59 schrieb Robert Blackstone: Hi All, I have been transcribing a piano piece in \time 4/2, that ends with a chord \breve. The penultimate bar ends with the same chord half note. What LilyPond does here I find rather ugly : both chords need more space, and I would like to center the breve and increase the distance between the penultimate chord and the bar line. The available space would be would be more than sufficient. […] Has anybody a suggestion or advice? Hi Robert, please always give a minimal code example. Does the following help? %%% \version "2.19.82" \language "deutsch" \new PianoStaff << \new Staff { \time 4/2 2 q q q \once \override Staff.BarLine.extra-spacing-width = #'(-10 . 10) q\breve } \new Staff { \clef bass 2 q q q q\breve } >> ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Horizontal shifting of chords
Hi All, I have been transcribing a piano piece in \time 4/2, that ends with a chord \breve. The penultimate bar ends with the same chord half note. What LilyPond does here I find rather ugly : both chords need more space, and I would like to center the breve and increase the distance between the penultimate chord and the bar line. The available space would be would be more than sufficient. This is what I want: This is what I get: I have not been able to get what I want. \override NoteColumn.force-hshift = #x (some value) does nothing. I have tried to cheat a bit by surreptitiously changing the "time" of the last 2 bars from 4/2 to 6/2 and add a hidden whole note to the end of the penultimate bar and to the beginnig of te final bar but nothing changes. Has anybody a suggestion or advice? Thanks in advance. Best regards, Robert Blackstone ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user