% * Add Mordents (reported by Patrick Karl)
%
-\version "2.16.0"
+\version "2.17.11"
#(use-modules (srfi srfi-1))
+#(use-modules (srfi srfi-11))
#(use-modules (ice-9 debug))
#(use-modules (scm display-lily))
% How much to slow down for a rall. or a poco rall.
% (or speed up for accel or poco accel)
-#(define ac:rallFactor (ly:make-moment 60 100)) % 40% slowdown
-#(define ac:pocoRallFactor (ly:make-moment 90 100)) % 10% slowdown
+#(define ac:rallFactor (ly:make-moment 60/100)) % 40% slowdown
+#(define ac:pocoRallFactor (ly:make-moment 90/100)) % 10% slowdown
% The absolute time for a twiddle in a trill, in minutes.
% Start with 1/4 seconds == 1/240 minutes
-#(define ac:maxTwiddleTime (ly:make-moment 1 240))
+#(define ac:maxTwiddleTime (ly:make-moment 1/240))
% How long ordinary grace notes should be relative to their notated
% duration. 9/40 is LilyPond's built-in behaviour for MIDI output
(cons 6 0))))
-#(define ac:currentTempo (ly:make-moment 15 1)) % 4 = 60, measured wholes per minute
+#(define ac:currentTempo (ly:make-moment 15/1)) % 4 = 60, measured wholes per minute
#(define ac:lastTempo ac:currentTempo) % for 'a tempo' or 'tempo I'
% The duration of the current note. Start at a crotchet
% for no good reason.
-#(define ac:currentDuration (ly:make-duration 2 0 1 1))
+#(define ac:currentDuration (ly:make-duration 2 0 1/1))
% Amount of musical time (in whole notes) that we need to steal from the
% next events seen.
(ly:music-property music 'elements)))
(pre-t (if (pair? tr) (ly:music-property (car tr) 'twiddle)
'()))
+ (hemisemimom (ly:make-moment 1/64))
(t (ac:targetTwiddleTime)))
(if (ly:moment? pre-t)
pre-t
- (let loop ((len (ly:music-length music)))
- (if (ly:moment<? t len)
- (loop (ly:moment-mul len (ly:make-moment 1 2)))
- len)))))
+ hemisemimom)))
#(define (ac:trill music)
" Replace music with time-compressed repeats of the music,
maybe accelerating if the length is longer than a crotchet "
- (let* ((hemisemidur (ly:make-duration 5 0 1 1))
+ (let* ((hemisemidur (ly:make-duration 5 0 1/1))
(orig-len (ly:music-length music))
(t (ac:twiddletime music))
(uppernote '())
- (note_moment (ly:moment-mul t (ly:make-moment 1 2)))
- (c1 (ly:moment-div orig-len note_moment))
+ (note_moment (ly:moment-mul t (ly:make-moment 1/2)))
+ (c1 (ly:moment-div orig-len t))
(c2 (inexact->exact
(round (/ (ly:moment-main-numerator c1)
(* 2 (ly:moment-main-denominator c1))))))
; (ac:accel trillMusic factor))
)))
+
+% Copy music and strip articulations, ties, etc., for generating
+% mordents etc.
+#(define (ac:note-copy music)
+ "return a copy of music that is only notes, no articulations, ties, slurs etc"
+ (let ((new-music (ly:music-deep-copy music)))
+ (set! (ly:music-property new-music 'articulations) '())
+ (set! (ly:music-property new-music 'elements)
+ (filter (lambda (y) (eq? 'NoteEvent (ly:music-property y 'name)))
+ (ly:music-property new-music 'elements)))
+ new-music))
+
%
% Generate a tempoChangeEvent and its associated property setting.
%
'metronome-count
tempo
'tempo-unit
- (ly:make-duration 0 0 1 1))
+ (ly:make-duration 0 0 1/1))
(context-spec-music
(make-property-set 'tempoWholesPerMinute tempo) 'Score))))
(list-tabulate
(- rc (length ealtl))
(lambda (i) (list (ly:music-deep-copy body) (ly:music-deep-copy (car ealtl)))))
- (map (lambda (alt) (list (ly:music-deep-copy body) alt))))))))))
+ (map (lambda (alt) (list (ly:music-deep-copy body) alt)) ealtl))))))))
+ ((EventChord)
+ (let-values
+ (((trem evl)
+ (partition (lambda (v) (eq? (ly:music-property v 'name) 'TremoloEvent))
+ (ly:music-property m 'elements))))
+ (if (null? trem)
+ m
+ (let*
+ ((tremtype (ly:music-property (car trem) 'tremolo-type))
+ (tremtype-log (1- (integer-length tremtype)))
+ (durev (find (lambda (v) (not (null? (ly:music-property v 'duration)))) evl))
+ (totaldur (if durev (ly:music-property durev 'duration) (ly:make-duration tremtype-log 0 1)))
+ (tgt-nrep (/ (duration-visual-length totaldur) (duration-log-factor tremtype-log)))
+ (eff-nrep (max (truncate tgt-nrep) 1))
+ (tremdur (ly:make-duration tremtype-log 0
+ (* (/ tgt-nrep eff-nrep) (ly:duration-scale totaldur)))))
+ (or (and (= eff-nrep tgt-nrep) (= (ash 1 tremtype-log) tremtype))
+ (ly:warning (_ "non-integer tremolo ~a:~a")
+ (duration->lily-string (duration-visual totaldur) #:force-duration #t #:time-scale 1)
+ tremtype))
+ (for-each
+ (lambda (v)
+ (or (null? (ly:music-property v 'duration))
+ (set! (ly:music-property v 'duration) tremdur)))
+ evl)
+ (set! (ly:music-property m 'elements) evl)
+ (make-sequential-music
+ (list-tabulate eff-nrep (lambda (i) (ly:music-deep-copy m))))))))
((MultiMeasureRestMusic)
(make-sequential-music
(list
; or a half-shake -- a short, two twiddle trill.
; We implement as a half-shake.
(let*
- ((totallength (ly:music-length music))
- (newlen (ly:moment-sub totallength (ly:make-moment 3 32)))
- (newdur (ly:make-duration
- 0 0
- (ly:moment-main-numerator newlen)
- (ly:moment-main-denominator newlen)))
- (gracedur (ly:make-duration 5 0 1 1))
- (gracenote (ly:music-deep-copy music))
- (abovenote (ly:music-deep-copy music))
- (mainnote (ly:music-deep-copy music))
- (prall (make-sequential-music (list gracenote abovenote)))
- )
- (music-map (lambda (n)
- (if (eq? 'NoteEvent (ly:music-property n 'name))
- (set! (ly:music-property n 'duration) gracedur))
- n)
- abovenote)
- (music-map (lambda (n)
- (if (eq? 'NoteEvent (ly:music-property n 'name))
- (set! (ly:music-property n 'duration) gracedur))
- n)
- gracenote)
- (music-map (lambda (n)
- (if (eq? 'NoteEvent (ly:music-property n 'name))
- (set! (ly:music-property n 'duration) newdur))
- n)
- mainnote)
-
- (map (lambda (y) (ac:up y))
- (filter
- (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name)))
- (ly:music-property abovenote 'elements)))
- (make-sequential-music (list abovenote gracenote abovenote mainnote))))
+ ((origlength (ly:music-length music))
+ (gracedur (ly:make-duration 5 0 1/1))
+ (gracenote (ac:note-copy music))
+ (abovenote (ac:note-copy music))
+ (abovenoteTwo (ac:note-copy music))
+ (mainnote (ly:music-deep-copy music)))
+
+ (map (lambda (y) (ac:setduration y gracedur))
+ (ly:music-property gracenote 'elements))
+ (map (lambda (y) (ac:setduration y gracedur))
+ (ly:music-property abovenote 'elements))
+ (map (lambda (y) (ac:setduration y gracedur))
+ (ly:music-property abovenoteTwo 'elements))
+ (map (lambda (y) (ac:up y))
+ (filter
+ (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name)))
+ (ly:music-property abovenote 'elements)))
+ (map (lambda (y) (ac:up y))
+ (filter
+ (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name)))
+ (ly:music-property abovenoteTwo 'elements)))
+ (let* ((prallMusic (make-sequential-music
+ (list abovenote gracenote abovenoteTwo mainnote)))
+ (newlen (ly:music-length prallMusic))
+ (factor (ly:moment-div origlength newlen)))
+ (ly:music-compress prallMusic factor))))
((mordent)
(let*
- ((totaldur (ly:music-property
- (car (ly:music-property music 'elements)) 'duration))
- (dur (ly:duration-length totaldur))
- (newlen (ly:moment-sub dur (ly:make-moment 2 32)))
- (newdur (ly:make-duration
- 0 0
- (ly:moment-main-numerator newlen)
- (ly:moment-main-denominator newlen)))
- (gracenote (ly:music-deep-copy music))
- (belownote (ly:music-deep-copy music))
- (mainnote (ly:music-deep-copy music))
- (mordent (make-sequential-music (list gracenote belownote)))
- )
- (begin
- (music-map (lambda (n)
- (if (eq? 'NoteEvent (ly:music-property n 'name))
- (set! (ly:music-property n 'duration)
- (ly:make-duration 5 0 1 1)))
- n)
- mordent)
- (music-map (lambda (n)
- (if (eq? 'NoteEvent (ly:music-property n 'name))
- (set! (ly:music-property n 'duration) newdur))
- n)
- mainnote)
- (map (lambda (y) (ac:down y))
- (filter
- (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name)))
- (ly:music-property belownote 'elements)))
- (make-sequential-music (list mordent mainnote)))))
+ ((origlength (ly:music-length music))
+ (gracedur (ly:make-duration 5 0 1/1))
+ (gracenote (ac:note-copy music))
+ (belownote (ac:note-copy music)))
+ (map (lambda (y) (ac:setduration y gracedur))
+ (ly:music-property gracenote 'elements))
+ (map (lambda (y) (ac:setduration y gracedur))
+ (ly:music-property belownote 'elements))
+ (map (lambda (y) (ac:down y))
+ (filter
+ (lambda (z) (eq? 'NoteEvent (ly:music-property z 'name)))
+ (ly:music-property belownote 'elements)))
+ (display belownote)
+
+ (let* ((mordentMusic (make-sequential-music (list gracenote belownote music)))
+ (newlen (ly:music-length mordentMusic))
+ (factor (ly:moment-div origlength newlen)))
+ (ly:music-compress mordentMusic factor))))
+
((turn)
(let*
((dur (ly:music-property
(lambda ()
(music-map
ac:articulate-chord
- (event-chord-wrap! (ac:unfoldMusic music) parser)))
+ (ac:unfoldMusic (event-chord-wrap! music parser))))
(lambda ()
(or (= ac:stealForward 0)
(begin
(main-orig-len (ly:music-length main))
(numerator (ly:moment-main-numerator maindur))
(factor (if (eq? (remainder numerator 3) 0)
- (ly:make-moment 1 3) (ly:make-moment 1 2))))
+ (ly:make-moment 1/3) (ly:make-moment 1/2))))
(ly:music-compress grace
(ly:moment-mul factor (ly:moment-div main-orig-len grace-orig-len)))
- (ly:music-compress main (ly:moment-sub (ly:make-moment 1 1) factor))
+ (ly:music-compress main (ly:moment-sub (ly:make-moment 1/1) factor))
(set! (ly:music-property grace 'elements)
(append (ly:music-property grace 'elements)