lilypond-user
[Top][All Lists]
Advanced

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

Re: Changing clef automatically when pitch falls between a user-defined


From: Aaron Hill
Subject: Re: Changing clef automatically when pitch falls between a user-defined range of pitches
Date: Thu, 18 Oct 2018 08:19:00 -0700
User-agent: Roundcube Webmail/1.3.6

On 2018-10-18 7:21 am, elmeri wrote:
Hey ML,

I asked a similar question on the Music Practice & Theory Stack Exchange site, and I was told that the idea of changing clef automatically is - in
most cases - a bad idea, at least musically/practically speaking.
Nevertheless, I would like to ask for pointers as to how to accomplish this with pre-existing LilyPond capabilities or just try to implement it myself
-- I am not at all familiar with the codebase.

The ideal situation would be that there's some kind of \clefAutoChange or similar command, and a mechanism to override the changing points would also be provided. This also needs to work for \transpose'd music. For example, a cellist told me that when there's a passage that lingers long enough above E1 (but not too much above A1 or so), the music is usually written with the tenor clef. A similar rule (of thumb) applies to viola music and its use of
the treble clef, bassoon music etc.

Any pointers or thoughts on this?

Hi Elmo,

Virtually anything can be done with custom Scheme functions. It sounds like what you want is something akin to how \relative takes care of octaves except for automatically inserting \clef commands in the specified music.

The challenge here is deciding upon the interface for the so-called "rules of thumb". I would probably start by defining a global alist where a clef can be associated with a range of pitches. This could look something like this:

%%%%
#(define auto-clef-pitch-range (list
  (cons (cons '(-1 5 0) '(1 0 0)) 'bass)
  (cons (cons '( 0 5 0) '(2 0 0)) 'treble)))
%%%%

Here, as an example, I am referencing specific pitches by the values one would pass to ly:make-pitch to define a range. So the bass clef is associated with notes from a, to c' and the treble clef for notes from a to c''.

The idea is to provide some overlap in the ranges so as to not trigger clef changes too often. So, as long as a note falls within the range, the current clef would be continued. But once the next note is outside that range, then a better clef is inserted.

You could introduce some temporal tolerance (i.e. going outside the range for a short enough moment is permitted) and that will require looking ahead beyond simply the next note. Similarly, if you only wanted clefs to change at the beginning of measures, so that the majority of the measure is within the range of the clef, that would be another approach to try to avoid excessive clef changes.

Finally, the usage could be something like this:

%%%%
\autoClef \relative g {
  g8 a b c b a g4 |
  g8 b d g fis g d4 |
  c8 b a g d b g4
}
%%%%

Which, assuming the above-mentioned pitch ranges but without any of the temporal restrictions, could translate to:

%%%%
\relative g {
  \clef bass g8 a b c b a g4 |
  g8 b \clef treble d g fis g d4 |
  c8 b a \clef bass g d b g4
}
%%%%

NOTE: I have not written any of the underlying Scheme. This is just a mock-up, but I do not suspect that it would be too hard to write a function that can iterate some input music and insert \clef changes conditionally.

-- Aaron Hill



reply via email to

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