lilypond-user
[Top][All Lists]
Advanced

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

Re: Function to add articulation to all notes


From: Caagr98
Subject: Re: Function to add articulation to all notes
Date: Thu, 28 Dec 2017 22:31:18 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0

I think this is as specific as I can make it:

\addArticulation \staccato {
        a      % a-.       %% Plain notes should be articulated
        <a b>  % <a b>-.   %% Chords should be articulated once
        <>     % <>        %% Empty chords probably shouldn't be articulated
        \foo a % a         %% Some way to exclude one or more notes would be 
appreciated

        a-.    % a-.       %% No duplicates
        a\f    % a\f-.     %% Non-ArticulationEvents shouldn't be affected
        a-!    % a-!       %% If there already is an articulation, keep it (see 
below)
        a\coda % a\coda-.  %% Some articulations do make sense with others, 
though
}

I can't think of any situation where, for example, a---. would make sense (just 
write a-_), so it's probably better to turn { a b c-- d } into { a-. b-. c-- 
d-. }.
However, a->-. and a\upbow-. seem valid to me (I don't play any string 
instruments, though, so I don't know for sure).
I can think of two ways to implement this:
* Have a list of names in an external variable (like afterGraceFraction)
* Add a property to default-script-alist
Whichever way is chosen, if both the articulation to be placed and any that 
already exist match that predicate, don't add it.
The most obvious mutually exclusive articulations are '(staccato staccatissimo 
tenuto portato marcato), but there are probably others.

I don't know how ties should work - probably another default-script-alist 
property to determine whether it should be placed at the start or end of the 
tie.

I feel kinda bad for requesting this without having anything to contribute in 
return :(

On 12/28/17 21:42, David Nalesnik wrote:
> Hi,
> 
> On Thu, Dec 28, 2017 at 1:37 PM, Caagr98 <address@hidden> wrote:
>> That function seems rather destructive: removes all properties on existing 
>> articulations (including tweaks, direction, and midi stuff), and doesn't 
>> seem to handle anything other than ArticulationEvents at all. Dynamics, 
>> slurs, ties, etc are removed. Also, this version has no way to exclude a 
>> note from being articulated, unlike the earlier versions (where you can set 
>> 'articulations to an empty list to exclude it).
>>
> 
> OK, this will preserve what's already there:
> addArticulation =
> #(define-music-function (scripts music) (list? ly:music?)
>    (define (add mus)
>      (let* ((art (ly:music-property mus 'articulations))
>             (types (map (lambda (a) (ly:music-property a 'articulation-type))
>                      art)))
>        (for-each
>         (lambda (x)
>           (if (not (member x types))
>               (ly:music-set-property! mus 'articulations
>                (append! (ly:music-property mus 'articulations)
>                  (list (make-articulation x))))))
>         scripts)))
>    (for-some-music
>     (lambda (mus)
>       (cond
>        ((music-is-of-type? mus 'event-chord) (add mus))
>        ((music-is-of-type? mus 'note-event) (add mus))
>        (else #f)))
>     music)
>    music)
> 
> {
>   \addArticulation #'("staccato" "accent") { c~ c <c e g>->\f d d' c'^! }
> }
> 
> You'll note the wrong behavior at ties.  This could be fixed with a
> bunch more code.  I should note in this connection that the original
> definition of addArticulation which you inherited is flawed in regard
> to ties::
> 
> {
>   \addArticulation \accent { c~ c } % use original definition from top of 
> thread
>   \addArticulation \staccato { c~ c }
> }
> 
> It would be helpful if you would provide a test example so we could
> get an idea of what you want to work.
> 
> Thanks,
> David
> 



reply via email to

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