bug-lilypond
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: extra note head


From: Thomas Morley
Subject: Re: extra note head
Date: Sat, 15 Oct 2016 11:11:19 +0200

2016-10-15 6:47 GMT+02:00 Jack Wilson <address@hidden>:
>> I'm not top posting.
>
> % I want to be able to use chords here
> % in order to create accurate midi files
> % but if I do, the layout is wrong
> % reference: Snippets - Guitar strum rhythms
>
> \version "2.18.2"
>
> \new Voice \with {
>   \consists "Pitch_squash_engraver"
> } {
>   \improvisationOn
>   % chord causes extra note head to be produced
>   a b < c e g > d
> }



Hi Jack,

actually LilyPond creates a "slash"-note-head for every _NoteHead_ of
a NoteColumn. This is done via `improvisationOn'. The
Pitch_squash_engraver, reading `squashedPosition' from the settings
given as well by `improvisationOn', prints the "slash"-note-heads all
at same vertical position.
For chords, where all containing NoteHeads are in the same NoteColumn,
this means the NoteHeads are (partly) printed one upon the other.

Can be made visible with:

\new Voice \with { \consists "Pitch_squash_engraver" }
{
  \improvisationOn
  \once \override NoteColumn.after-line-breaking =
  #(lambda (grob)
    (for-each
      (lambda (i nh) (ly:grob-set-property! nh 'extra-offset (cons i i)))
      (iota 4 1 1)
      (ly:grob-array->list (ly:grob-object grob 'note-heads))))
  < c e g>4
}

I do understand it's unexpected behaviour for you. But what exactly is the bug?
The code works as expected, albeit you want a different behaviour.

For getting what you want I see three possibilities:

(1) Set all NoteHead.stencil of a NoteColumn #f, but give NoteColumn a stencil.

Though I can't recommend it. NoteColumn has no default-stencil, it
serves as a" container" for the NoteHeads and a bit other stuff. A
stencil for NoteColumn will likely break things elsewhere.
Nevertheless, here a naive sketch. It's not elaborated and will not
play nicely with changed fontSize and other durations, though.

\new Voice \with { \consists "Pitch_squash_engraver" }
{
  \improvisationOn
  \once \override NoteColumn.after-line-breaking =
  #(lambda (grob)
    (ly:grob-set-property! grob 'stencil
      (grob-interpret-markup grob (markup #:musicglyph "noteheads.s2slash")))
    (for-each
      (lambda (nh) (ly:grob-set-property! nh 'stencil #f))
      (ly:grob-array->list (ly:grob-object grob 'note-heads))))
  < c e g>4
}

(2) Reduce every chord to a single note and use two scores for layout and midi.

 Leading to:

eventChordReduce =
#(define-music-function (parser location m)(ly:music?)
(event-chord-reduce m))

mus = {
  \improvisationOn
  a4 b < c e g> d
}

\score {
  \new Voice
    \with { \consists "Pitch_squash_engraver" }
    { \eventChordReduce \mus }
}

\score {
  \new Voice
    \with { \consists "Pitch_squash_engraver" }
    \mus
  \midi {}
}

`eventChordReduce' as a music-function is missing in our source,
although we have the `event-chord-reduce'-procedure.
I'd call it a valid feature-request so far.

(3) Use tags.

Because it's anyway good practise to have two scores, one for layout,
another for midi you could use tags as documented.
Leading to:

mus = {
  \improvisationOn
  a4 b
  \tag #'midi < c e g>
  \tag #'layout c
  d
}

\score {
  \new Voice
    \with { \consists "Pitch_squash_engraver" }
    \removeWithTag #'midi \mus
}

\score {
  \new Voice
    \with { \consists "Pitch_squash_engraver" }
    \removeWithTag #'layout \mus
  \midi {}
}

Summary:
- I see no real bug here
- event-chord-reduce should be turned into a music-function and
implemented  into the source
- Eventually we could improve the docs about the improvisation-topic.
Suggestions?


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]