|Subject:||Re: Function for note string to fraction?|
|Date:||Mon, 19 May 2014 22:50:02 +0200|
|User-agent:||Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.5.0|
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?
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:make-duration (car parsed) (cadr
|[Prev in Thread]||Current Thread||[Next in Thread]|