lilypond-user
[Top][All Lists]
Advanced

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

Re: Wondering if there's a way to not just hide N.C symbols, but have th


From: Matthew Probst
Subject: Re: Wondering if there's a way to not just hide N.C symbols, but have them not erase "current" chord.
Date: Fri, 17 Feb 2023 19:03:11 -0600

This is indeed the first time I'm really understanding adding properties to notes with music functions, and it makes much more sense to me now that I'm deeper in this than it did in the past.  Thanks, I'll stop bugging the lits and will get writing now.

On Fri, Feb 17, 2023 at 5:06 PM Jean Abou Samra <jean@abou-samra.fr> wrote:

Le vendredi 17 février 2023 à 16:58 -0600, Matthew Probst a écrit :

One last question regarding this:

  • Given that now I have a way to not have to set the N.C. symbol to the empty string, is there a way to preserve a method of using the N.C symbol when I want it?  In other words, can you escape a rest so that it doesn't get converted to a skip, say by using a variable or function to wrap it?

That would be nice to know, but not absolutely necessary.

Thanks yet again.

Sure. Something like this should do:

\version "2.24.1"

firstNoteOfChord =
#(define-music-function (music) (ly:music?)
   (define (iter mus)
     (let ((elt (ly:music-property mus 'element))
           (elts (ly:music-property mus 'elements)))
       (map iter elts)
       (if (not (null? elt)) (iter elt))
       (if (and (music-is-of-type? mus 'event-chord) (not (null? elts)))
           (ly:music-set-property! mus 'elements (list (car elts))))))
   (iter music)
   music)

restsToSkips =
#(define-music-function (music) (ly:music?)
   (music-map (lambda (m)
                (if (and (music-is-of-type? m 'general-rest-event)
                         (not (ly:music-property m 'keep-as-rest #f)))
                    (make-music 'SkipEvent m)
                    m))
              music))

keepAsRest = \withMusicProperty keep-as-rest ##t \etc


VerseRhythmChords = {
    \chordmode {
        e16:9 r8 q16 r8 q16 r16 r16 q16 r8 q16 q16 r8
        e16:9 r8 q16 r8 q16 r16 r16 q16 r8 q16 q16 r8
        e16:9 r8 q16 r8 q16 r16 r16 q16 r8 q16 q16 r8
        bes16 q16 r16 q16 q4 g16 q16 \keepAsRest r16 q16 q4
    }
}

<<
    \new ChordNames {
        \set chordChanges = ##t
        \restsToSkips \VerseRhythmChords
    }
    \new Voice \with {
        \consists "Pitch_squash_engraver"
    } {
        \improvisationOn
        \firstNoteOfChord \VerseRhythmChords
        \improvisationOff
    }
>>

reply via email to

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