Skip to content

Commit

Permalink
More.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Jan 4, 2024
1 parent cb441c2 commit 72a2e53
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 25 deletions.
51 changes: 27 additions & 24 deletions src/libs/fades.liq
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
2 changes: 1 addition & 1 deletion tests/streams/cross.liq
Original file line number Diff line number Diff line change
Expand Up @@ -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() =
Expand Down

0 comments on commit 72a2e53

Please sign in to comment.