# Tweaked custom crossfade to deal with jingles.. def smart_cross(~start_next=5.,~fade_in=3.,~fade_out=3., ~default=(fun (a,b) -> sequence([a, b])), ~high=-15., ~medium=-32., ~margin=4., ~width=2.,~conservative=false,s) fade.out = fade.out(type="sin", duration=fade_out) fade.in = fade.in(type="sin", duration=fade_in) add = fun (a,b) -> add(normalize=false, [b, a]) log = log(label="smart_cross") def transition(a,b,ma,mb,sa,sb) list.iter(fun(x)-> log(level=4, "Before: #{x}"), ma) list.iter(fun(x)-> log(level=4, "After : #{x}"), mb) if ma["type"] == "J" or mb["type"] == "J" then log("Old or new file is a jingle: sequenced transition.") sequence([sa, sb]) elsif # Do not fade if it's already very low. b >= a + margin and a <= medium and b <= high then log("new >= old + margin, old <= medium and new <= high.") log("Do not fade if it's already very low.") log("Transition: crossed, no fade.") add(sa, sb) # What to do with a loud end and a quiet beginning ? # A good idea is to use a jingle to separate the two tracks, # but that's another story. else # Otherwise, A and B are just too loud to overlap nicely, # or the difference between them is too large and overlapping would # completely mask one of them. # log("No transition: using default.") # default(sa, sb) log("Transition: crossed, fade-in, fade-out.") add(fade.out(sa), fade.in(sb)) end end cross(width=width, duration=start_next, conservative=conservative, transition,s) end