lilypond-user
[Top][All Lists]
Advanced

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

Re: Extracting pitch of first note, then assign duration


From: Matthew Fong
Subject: Re: Extracting pitch of first note, then assign duration
Date: Sun, 7 Mar 2021 14:06:27 -0800

Hello Lucas,

Yes, this works perfectly. I did not know first existed!

I stole the example from
https://lilypond.org/doc/v2.20/Documentation/notation/substitution-function-examples

However, I still need to find a way to automagically manage the stem direction of the custos, since the notes may be transposed. This method below assigns a glyph manually.

addCustos =
#(define-music-function (noteList)
(ly:music?)
#{
\tweak NoteHead.stencil #ly:text-interface::print
\tweak NoteHead.font-size #3
\tweak NoteHead.text \markup {
\musicglyph "custodes.vaticana.u2"
}
\tweak Stem.stencil ##f
$(first (music-pitches noteList)) 4
#}
)

Many thanks,
mattfong

On Sun, Mar 7, 2021 at 11:54 AM Lukas-Fabian Moser <lfm@gmx.de> wrote:
Hi Matthew,

Am 07.03.21 um 20:03 schrieb Matthew Fong:
> I am in the process of writing a note replacement function that allows
> me to place a custos anywhere I might need.
>
> I am stuck on writing a function that extracts the pitch of the first
> note, given a list of notes, and then forcing a duration of 1/4. Any
> pointers would be appreciated.
>
> For example given the list of notes below, I would like a function to
> output c4.
> {
>   \clef treble
>   c2 d e f
>   g4 a b c
> }
>
Something like this?

\version "2.22.0"

test = \relative c' {
   \clef treble
   c2 d e f
   g4 a b c
}

firstnote =
#(define-music-function (mus dur) (ly:music? ly:duration?)
    #{ $(first (music-pitches test)) $dur #})

\score {
   \firstnote \test 8
}

Lukas


reply via email to

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