On 2014-05-15 15:17, Peter Bjuhr wrote:
is there already a function that converts a string "4." to the fraction '3/8', or the other-way round?

Maybe it's helpful to know that the string is intended for use with \note, e g

\note #"4." #UP

and the fraction is intended for use with \set Timing.baseMoment, e g

\set Timing.baseMoment = #(ly:make-moment 3/8)

After some research I think I've found a way forward with this:

In ' scm/define-markup-commands.scm' there's a function/procedure called 'parse-simple-duration', which is used to translate from '\note' to '\note-by-number'.

In a similar way I could use that to create the arguments to 'ly:make-duration'. And from there it would be easy to get the moment with ' ly:duration->string'.

This all leads to an additional question: Is it possible to include and use 'parse-simple-duration' in a local script (without copy and pasting it)?

If it's not possible I will settle with using \note-by-number instead!

For those of you which find it easier to read code than my ramblings, here is what I've got so far:

#(define (note-to-moment notestr)

(let ((parsed (parse-simple-duration notestr)))

(ly:duration-length

(ly:make-duration (car parsed) (cadr parsed)))))



Best
Peter



_______________________________________________
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user

Reply via email to