urisala wrote: > > > Would it be possible to make a generic function that works for the > tuplet in red and also in green? > > >
I was curious to puzzle this one out and learn something about scheme. A partial answer, building on some snippets already out there, follows. The numerical logic is easy, but I've not been able to see how to use scheme to count the notes in the music expression (though entering the number by hand isn't that hard) and somehow can't combine the production of a bracket within scheme with an expression to set the TupletNumber to show the note length as well as the ratio. What this does do is calculate the tuplet durations, the ratios, and draw the music. Of course, depending what you're writing, it might be easier to set up some re-usable patterns. Hope this helps. Peter %%%%%%% \version "2.11.49" %% Applies duration number to each note #(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 )) %% Deals with chords #(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 - here dnl is one of 1, 2, 4, 8... with no "."s attached #(define (string->duration dnl num dnm) ( let*( (dur (ly:intlog2 dnl)) ;; dur = 0 1 2 3 ... (need for ly:make-duration) ) (ly:make-duration dur 0 num dnm) )) %% Calculates the durations and constructs the tuplet %% Inputs: span = number of baseunit notes to fill; baseunit = note unit you're filling; count = number of new notes to input; notes = music expression, pitches and articulations only makeTuplet = #(define-music-function (parser location span baseunit count notes) (number? number? number? ly:music?) ( let*( (udf (expt 2 (truncate (/ span count)))) ;; unit duration factor (dnl (/ baseunit udf )) ;; displayed note length of tuplet (den (* count udf)) ;; denominator of tuplet ratio ) (music-map (lambda (x) (getChords x (string->duration dnl span den))) notes ) (make-music 'TimeScaledMusic 'denominator span 'numerator count 'element notes ) )) \relative { \time 4/4 \autoBeamOff \override TupletNumber #'text = #tuplet-number::calc-fraction-text c16 \makeTuplet #11 #16 #5 {d^\p( e f\< g a-.) } b4\! c1 } %%%%%%% EOF -- View this message in context: http://www.nabble.com/different-rhythmic-units-for-tuplet%27s-numerator-and-denominator-tp18321046p18367973.html Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com. _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org http://lists.gnu.org/mailman/listinfo/lilypond-user