[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-user
Subject: Re: Function to add articulation to all notes
From: Caagr98 <caagr98 () gmail ! com>
Date: 2017-12-28 21:31:18
Message-ID: e940db93-f114-336c-5506-2e6593fc64b9 () gmail ! com
[Download RAW message or body]
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 <caagr98@gmail.com> 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
>
_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic