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 6dcf755 commit 0511f1b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/core/source.ml
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ class virtual operator ?pos ?(name = "src") sources =

self#on_after_output (fun () ->
match (streaming_state, consumed) with
| `Done _, 0 -> _cache <- None
| `Done buf, 0 -> _cache <- Some buf
| `Done buf, n ->
let pos = Frame.position buf in
assert (n <= pos);
Expand Down
2 changes: 1 addition & 1 deletion src/core/stream/frame.ml
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,4 @@ let free_metadata frame pos =
in
Content.Metadata.set_data new_metadata
(List.filter (fun (p, _) -> p <> pos) (Content.Metadata.get_data metadata));
Fields.add Fields.metadata metadata frame
Fields.add Fields.metadata new_metadata frame
36 changes: 27 additions & 9 deletions src/libs/fades.liq
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,8 @@ end
# @param ~medium Smart crossfade: value, in dB, for medium sound level.
# @param ~margin Smart crossfade: margin to detect sources that have too different \
# sound level for crossing.
# @param ~deduplicate Crossfade transitions can generate duplicate metadata. When `true`, the operator \
# removes duplicate metadata from the returned source.
# @param s The input source.
def crossfade(
~id=null(),
Expand All @@ -549,6 +551,7 @@ def crossfade(
~high=-15.,
~medium=-32.,
~margin=4.,
~deduplicate=true,
~duration_margin=0.1,
~width=2.,
s
Expand Down Expand Up @@ -661,13 +664,28 @@ def crossfade(

transition = if smart then smart_transition else simple_transition end

cross(
id=id,
width=width,
duration=duration,
persist_override=persist_override,
override_duration=override_duration,
transition,
s
)
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()}}
end

0 comments on commit 0511f1b

Please sign in to comment.