Thanks to Tina's modularized code and their hints it's quite easy although I have no clue about scheme and don't know if it's done THE clean way:

I renamed the format-time function which outputs minutes and seconds to format-time-minsec:

#(define (format-time-minsec seconds) ; example: 2'15''
   (let* ((minutes (euclidean-quotient seconds 60))
          (rest (euclidean-remainder seconds 60)))
     (string-append (if (zero? minutes) "" (format #f "~a'" minutes))
                    (format #f "~a''" (round rest)))))


and added another function, format-time-smpte, with a framerate fps as a second parameter:

#(define (format-time-smpte seconds fps)
   (let* ((total-seconds (inexact->exact (floor seconds)))
          (fraction (- seconds total-seconds))

          (hours   (euclidean-quotient total-seconds 3600))
          (rem-h   (euclidean-remainder total-seconds 3600))
          (minutes (euclidean-quotient rem-h 60))
          (secs    (euclidean-remainder rem-h 60))

          (frames  (inexact->exact (round (* fraction fps)))))

     (let* ((carry-sec (euclidean-quotient frames fps))
            (frames2   (euclidean-remainder frames fps))
            (secs2     (+ secs carry-sec))
            (carry-min (euclidean-quotient secs2 60))
            (secs3     (euclidean-remainder secs2 60))
            (mins2     (+ minutes carry-min))
            (carry-hr  (euclidean-quotient mins2 60))
            (mins3     (euclidean-remainder mins2 60))
            (hrs2      (+ hours carry-hr)))
       (format #f "~2,'0d:~2,'0d:~2,'0d:~2,'0d"
               (inexact->exact (truncate hrs2))
               (inexact->exact (truncate mins3))
               (inexact->exact (truncate secs3))
               (inexact->exact (truncate frames2))))))


(not sure if this is "beautiful" code, but it works - thanks to chatGPT...)

In addition to that I have wrapper functions for format-time (which is called in the time-mark::text-from-seconds function):

% uncomment one (and only one) of the following lines to choose \timeMark format, and framerate for SMTPE
#(define (format-time seconds) (format-time-smpte seconds 29.97))
% #(define (format-time seconds) (format-time-minsec seconds))

This way I can switch the \timeMark format to my needs. I suppose you have one prevailing use case so it's fine to keep this globally in a *.ily file.

Tidying up is welcome ;-)

HTH
- Stephan

Am 27.12.2025 um 16:42 schrieb Kieren MacMillan:
What’s the easiest way to apply different formats, such as SMPTE timecode 
w/differing frame rates etc.?



Reply via email to