From ca6e9110e85d9344d92d4519c2a99a2c8ce43f9f Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Mon, 22 Oct 2018 02:52:33 +0200 Subject: [PATCH] Closes #5 The Autohand works on the first note-event it can find Included DocString for embellishments.ily --- lib/embellishments.ily | 32 +++++++++++++++++++++----------- lib/musical_functions.ily | 2 ++ 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/embellishments.ily b/lib/embellishments.ily index 8762614..97c065b 100644 --- a/lib/embellishments.ily +++ b/lib/embellishments.ily @@ -53,19 +53,29 @@ sruffddr = \drummode { \drumgrace { d16[\dr g g] } } % Swiss Ruff left with sta %% Embellishment functions, automatic left or right %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -#(define (autohandFunc left right) - (define-music-function (parser location note) (ly:music? ) - #{ - #(if (string=? (symbol->string (ly:music-property note 'drum-type)) "left-hand") - #{ $left #} - #{ $right #}) - - % print the note, else it won't show up - #note - #} - ) +get-first-note = #(define-music-function (music) (ly:music?) + "Get the first note-event in @var{music}" + (let ((note(car (extract-typed-music music 'note-event)))) + note + ) ) +#(define (autohandFunc left right) + "Return a music function that prepends @var{left} if the first next note-event is of type 'left-hand, +else it will prepend @var{right}" + (define-music-function (parser location music) (ly:music? ) + (let ((note (get-first-note music))) + #{ + #(if (string=? (symbol->string (ly:music-property note 'drum-type)) "left-hand") + #{ $left #} + #{ $right #}) + + % print the note, else it won't show up + #music + #} + ) + ) +) % Flam flam = #(autohandFunc flamg flamd) flamdr = #(autohandFunc flamgdr flamddr ) diff --git a/lib/musical_functions.ily b/lib/musical_functions.ily index 7d771d1..7992f83 100644 --- a/lib/musical_functions.ily +++ b/lib/musical_functions.ily @@ -89,11 +89,13 @@ odr = #(define-event-function (parser location) () #{ -\tag #'tutti \startGroup ofr = #(define-event-function (parser location) () #{ -\tag #'tutti \stopGroup #}) #(define (allbutlastnote mus) + "Reverse the elements, Pop of (cdr) the first element, Reverse again, put it in a SequentialMusic" (let ((elts (ly:music-property mus 'elements))) (make-music 'SequentialMusic 'elements (reverse (cdr (reverse elts)))) ) ) #(define (lastnote mus) + "Get the last element, make it a list, put it in a SequentialMusic" (let ((elts (ly:music-property mus 'elements))) (make-music 'SequentialMusic 'elements (list (last elts))) )