Re: Horizontally centered notes

2018-02-14 Thread Kieren MacMillan
Hi Caio,

> It is a bit strange that there is no method (that I know of) to write 
> centralized notes

#(define center-column
   (lambda (col)
 (let* ((left-col (ly:grob-object col 'left-neighbor))
(right-col (ly:grob-object col 'right-neighbor))
; If a column adjoining our column is a PaperColumn, ours
; is not alone in the measure.  We make no adjustments.
(alone?
 (and (eq? #t (ly:grob-property left-col 'non-musical))
  (eq? #t (ly:grob-property right-col 'non-musical)
   (if alone?
   (let* ((elts-list
   (ly:grob-array->list (ly:grob-object col 'elements)))
  (note-cols
   (filter
(lambda (elt)
  (grob::has-interface elt 'note-column-interface))
elts-list))
  (all-rests
   (map (lambda (c)
  (ly:grob-object c 'rest))
 note-cols))
  (all-rests (filter ly:grob? all-rests))
  (all-notes
   (map
(lambda (c)
  (ly:grob-object c 'note-heads))
note-cols))
  (all
   (map (lambda (ga)
  (if (ly:grob-array? ga)
  (ly:grob-array->list ga)
  '()))
 all-notes))
  (all (flatten-list all))
  (all (append all all-rests))
  (same-dur?
   (every (lambda (o)
(equal?
 (ly:grob-property o 'duration-log)
 (ly:grob-property (car all)
   'duration-log)))
 all)))
 (if same-dur?
 (let* ((sys (ly:grob-system col))
(col-center (interval-center
 (ly:grob-extent col sys X)))
(left-right-X
 (cdr (ly:grob-extent left-col sys X)))
(right-left-X
 (car (ly:grob-extent right-col sys X)))
(middle-X
 (- (average left-right-X right-left-X)
   col-center)))
   (ly:grob-translate-axis! col middle-X X

centerSolitaryPaperColumn =
  \override Score.PaperColumn.after-line-breaking = #center-column

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: Horizontally centered notes

2018-02-14 Thread Caio Barros
>
> It's not optimal, since I have to judge the "centralization" by eye, but
> at least I can get a satisfactory output.
>

Well, now that I tried another example with 5 notes that method didn't
work. The solution was to use \override NoteColumn.X-offset. It is a bit
strange that there is no method (that I know of) to write centralized
notes, since it is a relatively common thing in 18th century engravings.
See, for instance this engraving of Beethoven's String Quartet N. 1
attached.

music = \relative {
\override NoteColumn.X-offset = #'8.3
  c'2 d e f g
}

\score {
\new Staff {
  \time 5/2
  \clef "baritone^8" \music
}
  \layout{
\context {
  \Score
  \omit Clef
  \omit ClefModifier
  \omit Stem
  \omit TimeSignature
  \omit BarLine
  \override StaffSymbol.line-positions = #'(-2 0)
}
ragged-last = ##f
  }
}
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Horizontally centered notes

2018-02-14 Thread Caio Barros
>
> What about
>
> \version "2.19"
>
> music = \relative {
>   \tweak extra-spacing-width #'(-14 . 5) e'2 f g
> }
>
> \score {
>   \new Staff {
> \time 3/2
> \clef "baritone^8" \music
>   }
>   \layout{
> \context {
>   \Score
>   \omit Clef
>   \omit ClefModifier
>   \omit Stem
>   \omit TimeSignature
>   \omit BarLine
>   \override StaffSymbol.line-positions = #'(0)
>   \override NoteHead.extra-spacing-width = #'(-5 . 5)
> }
> ragged-last = ##f
>   }
> }
>
>
That helps, yes. It's not optimal, since I have to judge the
"centralization" by eye, but at least I can get a satisfactory output.
I also didn't know about \omit yet. Nice!

Caio
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: Horizontally centered notes

2018-02-14 Thread Kieren MacMillan
Hi Caio,

What about

\version "2.19"

music = \relative {
  \tweak extra-spacing-width #'(-14 . 5) e'2 f g
}

\score {
  \new Staff {
\time 3/2
\clef "baritone^8" \music
  }
  \layout{
\context {
  \Score
  \omit Clef
  \omit ClefModifier
  \omit Stem
  \omit TimeSignature
  \omit BarLine
  \override StaffSymbol.line-positions = #'(0)
  \override NoteHead.extra-spacing-width = #'(-5 . 5)
}
ragged-last = ##f
  }
}

Hope this 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


Horizontally centered notes

2018-02-14 Thread Caio Barros
Hi,

I'm writing some music snippets for a friend that is creating a music text
book, and they want to have and example in which a single musical line
shows three notes: one below the line, one on the line and one above it.

I managed to write almost what they want, except that would be nicer that
the notes were horizontally centered. Lilypond automatically engraves notes
a little bit to the left so that notes more or less reflect their duration,
and I'm having trouble finding a way to override that to have the desired
output:

music = \relative {
 e'2 f g
}

\score{
\new Staff {
\time 3/2
\clef "baritone^8" \music
}

\layout{
\context {
  \Score
  \override Clef.stencil = ##f
  \override ClefModifier.stencil = ##f
  \override Stem.stencil = ##f
  \override TimeSignature.stencil = ##f
  \override BarLine.stencil = ##f
  \override StaffSymbol.line-positions = #'(0)
}
ragged-last = ##f
}
}

I tried proportional notation overrides and even found that multimeasure
rests (which are engraved in the center of the measure) have an attribute
called spacing-pair, so calling \override MultiMeasureRest.spacing-pair =
#'(staff-bar . staff-bar) for instance would align them to the center of
the measure ignoring clefs, time signatures and so on... but this property
is no applicable to note heads...

Any help?
Caio
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user