From e43b8307fddd17e25c21df0e028165cad5a99df4 Mon Sep 17 00:00:00 2001 From: TroyHernandez Date: Sat, 6 Jun 2026 20:15:16 -0500 Subject: [PATCH 1/2] to_timecode(): default rate to the RationalTime's own rate Exposes OTIO's no-rate to_timecode overload: `rate` now defaults to `rate(rt)` (via a NULL sentinel to avoid the recursive default-argument reference), so `to_timecode(RationalTime(17982, 30000/1001))` infers drop-frame and returns "00:10:00;00". Explicit rate/drop_frame still work unchanged. --- R/time.R | 8 ++++++-- inst/tinytest/test_time.R | 4 ++++ man/to_timecode.Rd | 5 +++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/R/time.R b/R/time.R index f299481..27ab6c2 100644 --- a/R/time.R +++ b/R/time.R @@ -100,7 +100,8 @@ rescaled_to <- function(rt, new_rate) cpp_rt_rescaled_to(rt, new_rate) #' SMPTE timecode conversions #' #' @param rt A \code{RationalTime}. -#' @param rate Timecode rate. +#' @param rate Timecode rate. Defaults to the \code{RationalTime}'s own rate +#' (OTIO's no-rate \code{to_timecode} overload). #' @param drop_frame -1 infer, 0 force non-drop, 1 force drop-frame. #' @return A timecode string. #' @examples @@ -108,7 +109,10 @@ rescaled_to <- function(rt, new_rate) cpp_rt_rescaled_to(rt, new_rate) #' tc #' from_timecode(tc, 24) #' @export -to_timecode <- function(rt, rate, drop_frame = -1L) { +to_timecode <- function(rt, rate = NULL, drop_frame = -1L) { + if (is.null(rate)) { + rate <- rate(rt) + } cpp_rt_to_timecode(rt, rate, as.integer(drop_frame)) } diff --git a/inst/tinytest/test_time.R b/inst/tinytest/test_time.R index c93ba1c..7ab0984 100644 --- a/inst/tinytest/test_time.R +++ b/inst/tinytest/test_time.R @@ -19,6 +19,10 @@ expect_equal(value(rescaled_to(RationalTime(24, 24), 48)), 48) expect_equal(to_timecode(RationalTime(48, 24), 24), "00:00:02:00") expect_equal(value(from_timecode("00:00:02:00", 24)), 48) +## no-rate overload: uses the RationalTime's own rate + infers drop-frame +expect_equal(to_timecode(RationalTime(48, 24)), "00:00:02:00") +expect_equal(to_timecode(RationalTime(17982, 30000 / 1001)), "00:10:00;00") + ## arithmetic and comparison (Ops) expect_equal(value(RationalTime(10, 24) + RationalTime(5, 24)), 15) expect_equal(value(RationalTime(10, 24) - RationalTime(4, 24)), 6) diff --git a/man/to_timecode.Rd b/man/to_timecode.Rd index 25564a2..01ba4c0 100644 --- a/man/to_timecode.Rd +++ b/man/to_timecode.Rd @@ -4,14 +4,15 @@ \alias{from_timecode} \title{SMPTE timecode conversions} \usage{ -to_timecode(rt, rate, drop_frame = -1L) +to_timecode(rt, rate = NULL, drop_frame = -1L) from_timecode(timecode, rate) } \arguments{ \item{rt}{A \code{RationalTime}.} -\item{rate}{Timecode rate.} +\item{rate}{Timecode rate. Defaults to the \code{RationalTime}'s own rate +(OTIO's no-rate \code{to_timecode} overload).} \item{drop_frame}{-1 infer, 0 force non-drop, 1 force drop-frame.} From 75ab33bb766af60a20764d0d913d8eb7f2277dd6 Mon Sep 17 00:00:00 2001 From: TroyHernandez Date: Sat, 6 Jun 2026 20:15:16 -0500 Subject: [PATCH 2/2] Bump version to 0.0.0.7 --- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1ba5efe..395804a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: rotio Type: Package Title: R Bindings for OpenTimelineIO -Version: 0.0.0.6 +Version: 0.0.0.7 Date: 2026-06-04 Authors@R: c( person("Troy", "Hernandez", role = c("aut", "cre"), diff --git a/NEWS.md b/NEWS.md index 7f4adc8..a929ca3 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# rotio 0.0.0.7 + +* `to_timecode()` `rate` now defaults to the `RationalTime`'s own rate (OTIO's + no-rate `to_timecode` overload), e.g. `to_timecode(RationalTime(17982, 30000/1001))` + infers drop-frame and returns `"00:10:00;00"`. + # rotio 0.0.0.6 * Add GitHub Actions CI (r-ci) on Ubuntu and macOS, building