Changing clef automatically when pitch falls between a user-defined range of pitches

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Changing clef automatically when pitch falls between a user-defined range of pitches

elmeri
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? 

Thank you,

-Elmo



_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

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

Aaron Hill
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

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

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

Aaron Hill
On 2018-10-18 8:19 am, Aaron Hill wrote:
> On 2018-10-18 7:21 am, elmeri wrote:
>> This also needs to work for \transpose'd music.

I missed that line.  \transpose could be tricky to support if one wanted
both...

   \transpose a b { \autoClef { ... } }

   \autoClef { \transpose a b { ... } }

...to work the same.  The latter is much simpler since \autoClef can
directly work with the music provided since the \transpose is contained
within its input.  The former would require \autoClef to defer its
processing until some later time, since it would not know if it is being
transposed.  At that point, I think you'd be looking at building a
custom engraver, which is not something I have any experience with.  
Perhaps the folks on the list who do have that experience could comment
as to the feasibility.

-- Aaron Hill

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

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

David Nalesnik
In reply to this post by elmeri
On Thu, Oct 18, 2018 at 9:27 AM elmeri <[hidden email]> 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?

You might get some inspiration from http://lsr.di.unimi.it/LSR/Item?id=773.

-David

_______________________________________________
lilypond-user mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/lilypond-user