lilypond-user
[Top][All Lists]
Advanced

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

Re: Markup for repeated notes or phrases


From: Gilles THIBAULT
Subject: Re: Markup for repeated notes or phrases
Date: Fri, 13 Nov 2015 11:33:09 +0100
User-agent: KMail/4.14.5 (Linux/4.1.12-desktop-1.mga5; KDE/4.14.5; x86_64; ; )

> And let's say I want to add fingering instructions, but only to the
> first <c e> <d f>, as if I had written
> 
> \relative c' { <c-1 e-3>8 <d-2 f-4>8 <c e>8 <d f>8 <c e>8 <d f>8 <c e>8
> <d f>8 }
> 

Sorry to answer so late.
This snippet can perhaps make your life easier :
  http://lsr.di.unimi.it/LSR/Item?id=768
But it will not work as you expect if you use \repeat. I often use a function 
like that, instead :
%------------------
nCopy = #(define-music-function (parser location n music)(integer? ly:music?)
(cond
  ((> n 1)(make-sequential-music 
            (map (lambda (x)(ly:music-deep-copy music))
                 (make-list n))))
  ((= n 1) music)
  (else (make-music 'Music 'void #t))))
%-----------------

So the full code for you would be :

%------------------------------------------

\version "2.18.2"
\include "fingering.ly"
%% get this file at :
%%   http://gillesth.free.fr/Lilypond/fingering/fingering.ly
%% doc and tests here :
%%   http://gillesth.free.fr/Lilypond/fingering/

nCopy = #(define-music-function (parser location n music)(integer? ly:music?)
(cond
  ((> n 1)(make-sequential-music 
            (map (lambda (x)(ly:music-deep-copy music))
                 (make-list n))))
  ((= n 1) music)
  (else (make-music 'Music 'void #t))))

music = \nCopy #4 \relative c' { <c e>8 <d f>8 }

\addFingering \music
  #"1324"

% RESULT =>
%  { <c-1 e-3>8 <d-2 f-4>8 
%    <c e>8 <d f>8 
%    <c e>8 <d f>8 
%    <c e>8  <d f>8 }

%----------------------------------


DRAWBACKS : You have to use \relative *after* \nCopy :
Something like
  \relative c' {
  ...
  \nCopy #4 { c' d}
  ...
  }
will give you some strange results...
You may want either to  work in \absolute mode or to replace in the code of 
\nCopy, the string :
  (ly:music-deep-copy music)
by :
  (ly:music-deep-copy #{ \relative c' \music #})



-- 
Gilles



reply via email to

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