[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: different rhythmic units for tuplet's numerator and denominator
From: |
Peter Johnson |
Subject: |
Re: different rhythmic units for tuplet's numerator and denominator |
Date: |
Fri, 11 Jul 2008 14:26:43 -0700 (PDT) |
A final point on this thread. These better functions now count the notes in
the tuplet, calculate durations and ratios, and lay it out. It's therefore
a way of filling a time span with a sequence of notes without having to
calculate possibly complex ratios. However, I can't work out why the "\once
override.... " line inserted in the makeTuplet function is ignored. Maybe
it should be possible to add a \note to the 'numerator and 'denominator
elements in this block, but I just can't work it out. Can anyone help solve
this? Cheers.
Peter
\version "2.11.49"
#(define (count-notes notes)
(
let*(
(es (ly:music-property notes 'elements))
(i (length es))
)
i
))
#(define (transformEachNote chordElt d)
(begin
(if (or (eq? 'NoteEvent (ly:music-property chordElt 'name))
(eq? 'RestEvent (ly:music-property chordElt 'name)))
(set! (ly:music-property chordElt 'duration) d)
)
chordElt
))
#(define (getChords musicElt d)
(begin
(if (eq? 'EventChord (ly:music-property musicElt 'name))
(map
(lambda (x) (transformEachNote x d))
(ly:music-property musicElt 'elements)
)
)
musicElt
))
% Converts duration into ly form - dnl is one of {1 2 4 8 ..} with no "."s
attached
#(define (string->duration tdur num den)
(
let*(
(dur (ly:intlog2 tdur)) ;; dur = 0 1 2 3 ..
)
(ly:make-duration dur 0 num den)
))
% Constructs the tuplet
makeTuplet = #(define-music-function (parser location span baseunit notes)
(number? number? ly:music?)
(
let*(
(count (count-notes notes)) ;; number of notes in sequence
(udf (inexact->exact (expt 2 (floor (+ 1 (- (/ (log span) (log
2)) (/ (log
count) (log 2)))))))) ;; unit duration factor
(tdur (/ baseunit udf)) ;; tuplet note duration
(num (if (< udf 1)
(/ span udf)
span)) ;; numerator of
tuplet duration ratio
(den (if (< udf 1)
count
(* count udf))) ;;
denominator of tuplet duration ratio
)
(music-map
(lambda (x)
(getChords x (string->duration tdur num den)))
notes
)
#{
\once \override TupletNumber #'text = #(markup #:italic "$count"
#:fontsize
-5 #:note "$tdur" 1 ":" "$span" #:fontsize -5 #:note "$baseunit" 1)
#}
(make-music 'TimeScaledMusic
'numerator span
'denominator count
'element notes
)
))
\relative
{
\time 4/4
\autoBeamOff
\override TupletNumber #'text = #tuplet-number::calc-fraction-text
c16 \makeTuplet #11 #16 {d e f g a } b4 | c1
}
--
View this message in context:
http://www.nabble.com/different-rhythmic-units-for-tuplet%27s-numerator-and-denominator-tp18321046p18412866.html
Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.
- different rhythmic units for tuplet's numerator and denominator, Uri Sala, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Reinhold Kainhofer, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Uri Sala, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Kieren MacMillan, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Uri Sala, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Kieren MacMillan, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Uri Sala, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Peter Johnson, 2008/07/09
- Re: different rhythmic units for tuplet's numerator and denominator,
Peter Johnson <=
- Re: different rhythmic units for tuplet's numerator and denominator, James E. Bailey, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, Uri Sala, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, James E. Bailey, 2008/07/07
- Re: different rhythmic units for tuplet's numerator and denominator, James E. Bailey, 2008/07/07
Re: different rhythmic units for tuplet's numerator and denominator, Peter Johnson, 2008/07/07