From 72a2e534b000dff29c273a5341842c776ef30145 Mon Sep 17 00:00:00 2001 From: Romain Beauxis Date: Thu, 4 Jan 2024 13:43:02 -0600 Subject: [PATCH] More. --- src/libs/fades.liq | 51 ++++++++++++++++++++++------------------- tests/streams/cross.liq | 2 +- 2 files changed, 28 insertions(+), 25 deletions(-) diff --git a/src/libs/fades.liq b/src/libs/fades.liq index 34d1821728..304baec40d 100644 --- a/src/libs/fades.liq +++ b/src/libs/fades.liq @@ -510,6 +510,23 @@ def cross.smart( end end +# @docof cross +# @param ~deduplicate Crossfade transitions can generate duplicate metadata. When `true`, the operator \ +# removes duplicate metadata from the returned source. +def replaces cross(%argsof(cross), ~deduplicate=true, transition, s) = + if + not deduplicate + then + cross(%argsof(cross), transition, s) + else + s = cross(%argsof(cross[!id]), transition, s) + def replaces s = + metadata.deduplicate(s) + end + s + end +end + # Crossfade between tracks, taking the respective volume levels into account in # the choice of the transition. # @category Source / Fade @@ -664,28 +681,14 @@ def crossfade( transition = if smart then smart_transition else simple_transition end - let (cross_id, deduplicate_id) = - deduplicate ? (null(), null(id)) : (null(id), null()) - - crossed = - cross( - id=cross_id, - width=width, - duration=duration, - persist_override=persist_override, - override_duration=override_duration, - transition, - s - ) - - s = - if - deduplicate - then - metadata.deduplicate(id=deduplicate_id, crossed) - else - crossed - end - - s.{cross_duration={crossed.cross_duration()}} + cross( + id=id, + width=width, + duration=duration, + persist_override=persist_override, + override_duration=override_duration, + deduplicate=deduplicate, + transition, + s + ) end diff --git a/tests/streams/cross.liq b/tests/streams/cross.liq index f16d12e8d7..f96f3ceb79 100644 --- a/tests/streams/cross.liq +++ b/tests/streams/cross.liq @@ -34,7 +34,7 @@ def check_duplicate(m) = end end -s.on_metadata(check_duplicate) +s = source.on_metadata(s, check_duplicate) clock.assign_new(sync="none", [s]) def on_stop() =