Olivier,

On Thu, May 21, 2015 at 7:26 AM, Olivier Vogel [via Lilypond] <
[email protected]> wrote:

>
>
> 2015-05-21 13:54 GMT+01:00 Kieren MacMillan <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=176852&i=0>>:
>
>>
>> May I ask why you’re not using Lilypond’s built-in (and generallly
>> excellent) voice-handling? e.g. In the modified snippet (below), I’m using
>> \voiceOne, \voiceTwo, etc., which eliminates the need for \stemUp,
>> \tieDown, etc., and appears (to my eye) to eliminate all note collisions.
>>
>
> Simply because, I'm learning Lilypond since only a few days.
>

Well, keep going! You'll get the hang of things. I'd follow Kieren's advice
in separating the musical *content* from the score *structure*. You'll find
it will pay off. However, there's an unnecessary duplication of identifying
voices in his solution. Let me explain. There are basically two ways to
create simultaneous voices, an implicit way and an explicit way.

*Implicit Voicing:*

... old voice before ...
<<
  { ... first voice stuff ... }
  \\
  { ... second voice stuff ... }
  \\
  { ... third voice stuff ... }
  \\
   ... etc.
>>
... new voice after ...

In this form, there is no need to include \voiceOne, \voiceTwo, etc. unless
you *really* mean to change the voice, but normally this is not necessary.
Adding them (which is what Kieren did) won't hurt it, it's just
unnecessary. This syntax can be convenient if the sections are not too
long. However, be aware that this syntax creates COMPLETELY NEW voices and
discards the old ones, so don't use this form when you need to attach lyric
text. The voice it's connected to will be lost once this section starts.

*Explicit Voicing:*

... original voice stuff, neutral direction ...
<<
  { \voiceOne ... continuation of original voice (but now as "first") ... }
  \new Voice { \voiceTwo ... second voice stuff ... }
  \new Voice { \voiceThree ... third voice stuff ... }
>>
\oneVoice
... original voice continues, but without a specified direction ...

Notice that there are no "\\" in between the voices here. I tend to prefer
this syntax unless each section is *very* temporary and there are no lyrics
involved. Otherwise, this is the way to go.

In either case, the odd numbered voices move associated elements upwards
(i.e., stems, slurs, ties, articulations, etc.) and move progressively to
the right, away from the primary note column. Even numbered voices move
associated elements downwards and move progressively to the left of the
primary note column.


> Your solution avoids the collision at the third measure, but introduces an
> horizontal shift at the fourth measure, which I'd like to prevent. Is it
> possible?
>

It's certainly possible, but the real issue that keeps makes it this way
that LilyPond deals with things tied to specific voices. As of now, there
isn't a convenient mechanism that allows you to put a tie across voices. To
*fake it*, there are a couple of options:

   1. Use an override similar to what you were using initially (e.g., \override
   NoteColumn.force-hshift = #0) for both notes in the connected ties of
   the third voice.
   2. Use a hidden notehead that connects to the first g1 and create a real
   chord in the first voice for the second set of ties.

In your case, after cooking up both options, the first tends to be easier
(when using the voicing that Kieren described) and the second requires the
same force-shift override anyway to put the tie in the right place.

>
>> p.s. Also note that I abstracted your note code from your score code — it
>> is so much easier to read and debug this way, in my opinion, and it keeps
>> the score block as clean and simple as possible.
>>
>
> Thank you very much for your advice. As a beginner, where can I learn how
> to write a better code?
>

Do you mean syntax structure (e.g., where to put the music vs. structure)
or coding style (e.g., how much to indent, when to start a new line, etc.)?

Regards,
Abraham




--
View this message in context: 
http://lilypond.1069038.n5.nabble.com/How-to-avoid-a-collision-tp176849p176855.html
Sent from the User mailing list archive at Nabble.com.
_______________________________________________
lilypond-user mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to