[prev in list] [next in list] [prev in thread] [next in thread]
List: lilypond-user
Subject: Re: Modification of Flam, Drag, Ruff snippet
From: Craig Dabelstein <craig.dabelstein () gmail ! com>
Date: 2019-06-29 18:18:57
Message-ID: CAMhPZ6B0xfv6RR4LAh4AqKo1X-483KcURywDNwNEekpvtRQZkg () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
Absolutely perfect! Thank you Harm.
All the best,
Craig
On Sat, 29 Jun 2019 at 21:37, Thomas Morley <thomasmorley65@gmail.com>
wrote:
> Am Sa., 29. Juni 2019 um 11:06 Uhr schrieb Craig Dabelstein
> <craig.dabelstein@gmail.com>:
> >
> > Hi all,
> >
> > Is there a way to modify the Flams, Drags and Ruff snippet from the LSR (
> http://lsr.di.unimi.it/LSR/Item?id=566) so that there can be open
> versions of the drag and ruff (that's what exists now), and also a closed
> version of the drag and ruff; i.e. joining the two or three notes with a
> slur.
> >
> > At the moment, to write a closed drag takes this code:
> > \grace { sn16 ( sn ) }
> >
> > Could the snippet be modified so that one could type: \dragclosed or
> \dragopen. The same for the ruffs.
> >
> > All the best,
> >
> > Craig
>
> Do you mean like below (2.19.x required):
>
> \version "2.19.82"
>
> %% http://lsr.di.unimi.it/LSR/Item?id=566
>
>
> %% Return repeated single notes or chords, depending on @var{print-chord?}
> %% If @var{print-chord?} is set @code{#f}, the first written note is taken.
> %% The Number of repeats is set by @var{lngth}
> %% Only notes are returned. Other stuff like @code{Script},
> @code{Fingering}
> %% is thrown away.
> #(define (grace-from-main-note print-chord? lngth music slurred?)
> (let* ((elts (ly:music-property music 'elements))
> (has-duration?
> (lambda (x) (ly:duration? (ly:music-property x 'duration))))
> ;; If the whole chord should be printed catch Notes only.
> ;; If the first written note should be printed catch it.
> ;; Otherwise, don't touch the music.
> (mus (cond ((and (music-is-of-type? music 'event-chord)
> print-chord?)
> (make-event-chord (event-chord-notes music)))
> ((music-is-of-type? music 'event-chord)
> (first (event-chord-notes music)))
> (else music)))
> ;; Set duration of note, clear 'articulations.
> (note (map-some-music
> (lambda (m)
> (and (has-duration? m)
> (begin
> (set! (ly:music-property m 'duration)
> (ly:make-duration (if (> lngth 1) 4 3) 0
> 1 1))
> (set! (ly:music-property m 'articulations) '())
> m)))
> (ly:music-deep-copy mus)))
> (next-note (ly:music-deep-copy note))
> (last-note (ly:music-deep-copy note))
> ;; Create a list of notes for use with (> lngth 1)
> (m-list
> (flatten-list
> (list note
> (make-list (max 0 (- lngth 2)) next-note)
> last-note))))
> ;; Return a single note if (= lngth 1 ).
> ;; Insert Beam for (> lngth 1) and return the result.
> (cond ((= lngth 1 )
> note)
> ((> lngth 1)
> (list-set! m-list 0
> (begin
> (ly:music-set-property!
> note
> 'articulations
> (cons
> (make-music
> 'BeamEvent
> 'span-direction -1)
> (if slurred?
> (list
> (make-music
> 'SlurEvent
> 'spanner-id
> 'drag+ruff
> 'span-direction
> -1))
> '())))
> note))
> (list-set! m-list (- lngth 1)
> (begin
> (ly:music-set-property!
> last-note
> 'articulations
> (cons
> (make-music
> 'BeamEvent
> 'span-direction 1)
> (if slurred?
> (list
> (make-music
> 'SlurEvent
> 'spanner-id
> 'drag+ruff
> 'span-direction
> 1))
> '())))
> last-note))
> (make-sequential-music m-list))
> ;; fall back
> (else (make-sequential-music '())))))
>
> graceRepeat =
> #(define-music-function (chord-repeat? how-much note)
> ((boolean? #f) integer? ly:music?)
> "Return @var{note} preceded by repeated and beamed grace-notes. The
> number of
> grace-notes is specified by @var{how-much}.
> If @var{note} is a chord the first written note of it is used.
> If @var{chord-repeat?} is specified the whole chord is repeated during
> @code{GraceMusic}."
> #{
> \slashedGrace { $(grace-from-main-note chord-repeat? how-much note
> #f) }
> $note
> #})
>
> slurredGraceRepeat =
> #(define-music-function (chord-repeat? how-much note)
> ((boolean? #f) integer? ly:music?)
> "Return @var{note} preceded by repeated and beamed grace-notes. The
> number of
> grace-notes is specified by @var{how-much}.
> If @var{note} is a chord the first written note of it is used.
> If @var{chord-repeat?} is specified the whole chord is repeated during
> @code{GraceMusic}.
> Graces are slurred."
> #{
> \slashedGrace { $(grace-from-main-note chord-repeat? how-much note
> #t) }
> $note
> #})
>
> flam =
> #(define-music-function (music)(ly:music?)
> "Return @var{music} preceded by 1 grace-note"
> #{ \graceRepeat #1 $music #})
>
> drag =
> #(define-music-function (slurred music)((boolean? #f) ly:music?)
> "Return @var{music} preceded by 2 grace-notes. Optionally slurred
> graces."
> #{
> \slashedGrace { $(grace-from-main-note #f 2 music slurred) }
> $music
> #})
>
> slurredDrag = \drag ##t \etc
>
> ruff =
> #(define-music-function (parser location slurred music)((boolean? #f)
> ly:music?)
> "Return @var{music} preceded by 3 grace-notes. Optionally slurred
> graces."
> #{
> \slashedGrace { $(grace-from-main-note #f 3 music slurred) }
> $music
> #})
>
> slurredRuff = \ruff ##t \etc
>
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> % EXAMPLE
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
>
> % Note: the new coding works now for \notemode too.
>
> #(set-global-staff-size 18)
>
> \paper { indent = 0 }
>
> \layout {
> \context {
> \Score
> \override NonMusicalPaperColumn.line-break-permission = ##f
> }
> }
>
> <<
> \new DrumStaff {
> \new DrumVoice \drummode {
> r4 \flam sn4 \drag cymr4 \ruff bd4 |
> \flam <sn bd>2 \flam <bd sn>2 |
> \graceRepeat ##t #4 <bd sn>1 |
> \graceRepeat #1 <bd sn>1
> \graceRepeat #2 <bd sn>1
> \graceRepeat #3 <bd sn>1
> \graceRepeat #1 <bd sn>1
> \graceRepeat #2 <bd sn>1
> \graceRepeat #3 <bd sn>1
> \graceRepeat #4 <bd sn>1
> \graceRepeat #5 <bd sn>1
> }
> }
>
> \new Staff
> \new Voice
> \relative c' {
> \flam c \drag d
> \ruff e
> \graceRepeat #4 f-1\2^"foo"
> \flam <c f>
> % Insert the beginning of a (Phrasing)Slur before the grace-notes.
> <>^\(
> \drag <f c>
> % Change appearance of grace-notes.
> $(add-grace-property 'Voice 'NoteHead 'style 'cross)
> \ruff <c f>~ <c f>
> $(remove-grace-property 'Voice 'NoteHead 'style)
> \graceRepeat #4 <f c>
> % Insert the beginning of a (Phrasing)Slur before the grace-notes.
> <>(
> \graceRepeat #5 <c f>
> \graceRepeat ##t #6 <f c-2\3>-"foo"->
> )\)
> }
> >>
>
>
> \new DrumVoice \drummode {
> \drag sn4
> \slurredDrag sn4
> \ruff sn4
> \slurredRuff sn4
> \graceRepeat ##t #6 <bd sn>1
> \slurredGraceRepeat ##t #6 <bd sn>1
> }
>
>
> Cheers,
> Harm
>
--
[image: photograph]
*Craig Dabelstein*
Owner
email: craig@maximesmusic.com.au
Maxime's Music, QLD, Australia
[image: facebook icon] <https://www.facebook.com/maximesmusic.com.au> [image:
twitter icon] <https://twitter.com/MaximesMusic> [image: youtube icon]
<http://www.youtube.com/c/Maximesmusic_for_band> [image: instagram icon]
<https://www.instagram.com/maximes_music/> maximesmusic.com.au
[Attachment #5 (text/html)]
<div dir="ltr">Absolutely perfect! Thank you Harm.<div><br></div><div>All the \
best,</div><div><br></div><div>Craig</div></div><br><div class="gmail_quote"><div \
dir="ltr" class="gmail_attr">On Sat, 29 Jun 2019 at 21:37, Thomas Morley <<a \
href="mailto:thomasmorley65@gmail.com">thomasmorley65@gmail.com</a>> \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Am Sa., 29. Juni 2019 \
um 11:06 Uhr schrieb Craig Dabelstein<br> <<a \
href="mailto:craig.dabelstein@gmail.com" \
target="_blank">craig.dabelstein@gmail.com</a>>:<br> ><br>
> Hi all,<br>
><br>
> Is there a way to modify the Flams, Drags and Ruff snippet from the LSR (<a \
href="http://lsr.di.unimi.it/LSR/Item?id=566" rel="noreferrer" \
target="_blank">http://lsr.di.unimi.it/LSR/Item?id=566</a>) so that there can be open \
versions of the drag and ruff (that's what exists now), and also a closed version \
of the drag and ruff; i.e. joining the two or three notes with a slur.<br> ><br>
> At the moment, to write a closed drag takes this code:<br>
> \grace { sn16 ( sn ) }<br>
><br>
> Could the snippet be modified so that one could type: \dragclosed or \dragopen. \
The same for the ruffs.<br> ><br>
> All the best,<br>
><br>
> Craig<br>
<br>
Do you mean like below (2.19.x required):<br>
<br>
\version "2.19.82"<br>
<br>
%% <a href="http://lsr.di.unimi.it/LSR/Item?id=566" rel="noreferrer" \
target="_blank">http://lsr.di.unimi.it/LSR/Item?id=566</a><br> <br>
<br>
%% Return repeated single notes or chords, depending on @var{print-chord?}<br>
%% If @var{print-chord?} is set @code{#f}, the first written note is taken.<br>
%% The Number of repeats is set by @var{lngth}<br>
%% Only notes are returned. Other stuff like @code{Script}, @code{Fingering}<br>
%% is thrown away.<br>
#(define (grace-from-main-note print-chord? lngth music slurred?)<br>
(let* ((elts (ly:music-property music 'elements))<br>
(has-duration?<br>
(lambda (x) (ly:duration? (ly:music-property x 'duration))))<br>
;; If the whole chord should be printed catch Notes only.<br>
;; If the first written note should be printed catch it.<br>
;; Otherwise, don't touch the music.<br>
(mus (cond ((and (music-is-of-type? music 'event-chord) \
print-chord?)<br>
(make-event-chord (event-chord-notes music)))<br>
((music-is-of-type? music 'event-chord)<br>
(first (event-chord-notes music)))<br>
(else music)))<br>
;; Set duration of note, clear 'articulations.<br>
(note (map-some-music<br>
(lambda (m)<br>
(and (has-duration? m)<br>
(begin<br>
(set! (ly:music-property m \
'duration)<br>
(ly:make-duration (if (> lngth \
1) 4 3) 0 1 1))<br>
(set! (ly:music-property m \
'articulations) '())<br> m)))<br>
(ly:music-deep-copy mus)))<br>
(next-note (ly:music-deep-copy note))<br>
(last-note (ly:music-deep-copy note))<br>
;; Create a list of notes for use with (> lngth 1)<br>
(m-list<br>
(flatten-list<br>
(list note<br>
(make-list (max 0 (- lngth 2)) next-note)<br>
last-note))))<br>
;; Return a single note if (= lngth 1 ).<br>
;; Insert Beam for (> lngth 1) and return the result.<br>
(cond ((= lngth 1 )<br>
note)<br>
((> lngth 1)<br>
(list-set! m-list 0<br>
(begin<br>
(ly:music-set-property!<br>
note<br>
'articulations<br>
(cons<br>
(make-music<br>
'BeamEvent<br>
'span-direction -1)<br>
(if slurred?<br>
(list<br>
(make-music<br>
'SlurEvent<br>
'spanner-id<br>
'drag+ruff<br>
'span-direction<br>
-1))<br>
'())))<br>
note))<br>
(list-set! m-list (- lngth 1)<br>
(begin<br>
(ly:music-set-property!<br>
last-note<br>
'articulations<br>
(cons<br>
(make-music<br>
'BeamEvent<br>
'span-direction 1)<br>
(if slurred?<br>
(list<br>
(make-music<br>
'SlurEvent<br>
'spanner-id<br>
'drag+ruff<br>
'span-direction<br>
1))<br>
'())))<br>
last-note))<br>
(make-sequential-music m-list))<br>
;; fall back<br>
(else (make-sequential-music '())))))<br>
<br>
graceRepeat =<br>
#(define-music-function (chord-repeat? how-much note)<br>
((boolean? #f) integer? ly:music?)<br>
"Return @var{note} preceded by repeated and beamed grace-notes. The number \
of<br> grace-notes is specified by @var{how-much}.<br>
If @var{note} is a chord the first written note of it is used.<br>
If @var{chord-repeat?} is specified the whole chord is repeated during<br>
@code{GraceMusic}."<br>
#{<br>
\slashedGrace { $(grace-from-main-note chord-repeat? how-much note #f) }<br>
$note<br>
#})<br>
<br>
slurredGraceRepeat =<br>
#(define-music-function (chord-repeat? how-much note)<br>
((boolean? #f) integer? ly:music?)<br>
"Return @var{note} preceded by repeated and beamed grace-notes. The number \
of<br> grace-notes is specified by @var{how-much}.<br>
If @var{note} is a chord the first written note of it is used.<br>
If @var{chord-repeat?} is specified the whole chord is repeated during<br>
@code{GraceMusic}.<br>
Graces are slurred."<br>
#{<br>
\slashedGrace { $(grace-from-main-note chord-repeat? how-much note #t) }<br>
$note<br>
#})<br>
<br>
flam =<br>
#(define-music-function (music)(ly:music?)<br>
"Return @var{music} preceded by 1 grace-note"<br>
#{ \graceRepeat #1 $music #})<br>
<br>
drag =<br>
#(define-music-function (slurred music)((boolean? #f) ly:music?)<br>
"Return @var{music} preceded by 2 grace-notes. Optionally slurred \
graces."<br> #{<br>
\slashedGrace { $(grace-from-main-note #f 2 music slurred) }<br>
$music<br>
#})<br>
<br>
slurredDrag = \drag ##t \etc<br>
<br>
ruff =<br>
#(define-music-function (parser location slurred music)((boolean? #f) ly:music?)<br>
"Return @var{music} preceded by 3 grace-notes. Optionally slurred \
graces."<br> #{<br>
\slashedGrace { $(grace-from-main-note #f 3 music slurred) }<br>
$music<br>
#})<br>
<br>
slurredRuff = \ruff ##t \etc<br>
<br>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>
% EXAMPLE<br>
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%<br>
<br>
% Note: the new coding works now for \notemode too.<br>
<br>
#(set-global-staff-size 18)<br>
<br>
\paper { indent = 0 }<br>
<br>
\layout {<br>
\context {<br>
\Score<br>
\override NonMusicalPaperColumn.line-break-permission = ##f<br>
}<br>
}<br>
<br>
<<<br>
\new DrumStaff {<br>
\new DrumVoice \drummode {<br>
r4 \flam sn4 \drag cymr4 \ruff bd4 |<br>
\flam <sn bd>2 \flam <bd sn>2 |<br>
\graceRepeat ##t #4 <bd sn>1 |<br>
\graceRepeat #1 <bd sn>1<br>
\graceRepeat #2 <bd sn>1<br>
\graceRepeat #3 <bd sn>1<br>
\graceRepeat #1 <bd sn>1<br>
\graceRepeat #2 <bd sn>1<br>
\graceRepeat #3 <bd sn>1<br>
\graceRepeat #4 <bd sn>1<br>
\graceRepeat #5 <bd sn>1<br>
}<br>
}<br>
<br>
\new Staff<br>
\new Voice<br>
\relative c' {<br>
\flam c \drag d<br>
\ruff e<br>
\graceRepeat #4 f-1\2^"foo"<br>
\flam <c f><br>
% Insert the beginning of a (Phrasing)Slur before the grace-notes.<br>
<>^\(<br>
\drag <f c><br>
% Change appearance of grace-notes.<br>
$(add-grace-property 'Voice 'NoteHead 'style 'cross)<br>
\ruff <c f>~ <c f><br>
$(remove-grace-property 'Voice 'NoteHead 'style)<br>
\graceRepeat #4 <f c><br>
% Insert the beginning of a (Phrasing)Slur before the grace-notes.<br>
<>(<br>
\graceRepeat #5 <c f><br>
\graceRepeat ##t #6 <f c-2\3>-"foo"-><br>
)\)<br>
}<br>
>><br>
<br>
<br>
\new DrumVoice \drummode {<br>
\drag sn4<br>
\slurredDrag sn4<br>
\ruff sn4<br>
\slurredRuff sn4<br>
\graceRepeat ##t #6 <bd sn>1<br>
\slurredGraceRepeat ##t #6 <bd sn>1<br>
}<br>
<br>
<br>
Cheers,<br>
Harm<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" \
class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div \
dir="ltr"><span src="https://www.mail-signatures.com/signature-generator/selectedTemplatePath">
<table style="font-family:Verdana,sans-serif" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="width:140px;padding:0px;text-align:center;vertical-align:middle" \
width="140" valign="middle"> <img alt="photograph" style="width: 100px; height: \
100px; border-radius: 50px; border: 0px;" \
src="https://drive.google.com/uc?export=view&id=1ae9_McaWGSjbKWeL0BnXx4Od255dtPEt" \
width="100" height="100" border="0"> </td>
<td style="border-bottom:2px solid rgb(237,90,36);padding:0px;vertical-align:top" \
valign="top"> <table style="font-family:Verdana,sans-serif" cellspacing="0" \
cellpadding="0"> <tbody>
<tr>
<td style="font-family:Verdana,sans-serif;color:rgb(237,90,36);padding:0px 0px \
6px;vertical-align:top" valign="top">
<strong><span style="font-size:14pt;font-style:italic">Craig \
Dabelstein</span></strong><br> <span style="font-size:10pt">Owner</span>
</td>
</tr>
<tr>
<td style="font-family:Verdana,sans-serif;color:rgb(68,68,68);padding:0px 0px \
6px;line-height:18px;vertical-align:top" valign="top">
<span style="font-size:10pt">email: <a \
href="mailto:craig@maximesmusic.com.au" \
target="_blank">craig@maximesmusic.com.au</a><br> </span>
</td>
</tr>
<tr>
<td style="font-family:Verdana,sans-serif;color:rgb(68,68,68);padding:0px 0px \
6px;line-height:18px;vertical-align:top" valign="top"> <span \
style="font-size:10pt">Maxime's Music, </span> <span \
style="font-size:10pt">QLD, Australia</span>
</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td style="font-family:Verdana,sans-serif;width:140px;padding-top:6px;padding-left:0px;padding-right:0px;text-align:center;vertical-align:middle" \
width="140" valign="middle"> <span><a \
href="https://www.facebook.com/maximesmusic.com.au" rel="noopener" \
target="_blank"><img alt="facebook icon" style="border: 0px; height: 16px; width: \
16px;" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/photo2/fb.png" \
width="16" border="0"></a> </span><span><a href="https://twitter.com/MaximesMusic" \
rel="noopener" target="_blank"><img alt="twitter icon" style="border: 0px; height: \
16px; width: 16px;" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/photo2/tt.png" \
width="16" border="0"></a> </span><span><a \
href="http://www.youtube.com/c/Maximesmusic_for_band" rel="noopener" \
target="_blank"><img alt="youtube icon" style="border: 0px; height: 16px; width: \
16px;" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/photo2/yt.png" \
width="16" border="0"></a> </span><span><a \
href="https://www.instagram.com/maximes_music/" rel="noopener" target="_blank"><img \
alt="instagram icon" style="border: 0px; height: 16px; width: 16px;" \
src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/photo2/it.png" \
width="16" border="0"></a> </span> </td>
<td style="padding:6px 0px 0px;vertical-align:middle" valign="middle">
<a href="http://maximesmusic.com.au" rel="noopener" target="_blank"><span \
style="color:rgb(237,90,36);font-family:Verdana,sans-serif;font-size:10pt"><span \
style="font-size:10pt">maximesmusic.com.au</span></span></a> </td>
</tr>
</tbody>
</table></span></div></div></div></div></div></div>
[Attachment #6 (text/plain)]
_______________________________________________
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