Skip to content

Commit

Permalink
Fix tricky bug in smart_cross#is_ready. The issue is tied to a DIRTY …
Browse files Browse the repository at this point in the history
…workaround in the core source class. Now that the bug is fixed, set a better default for conservative in smart_crossfade.
  • Loading branch information
dbaelde committed Jul 3, 2012
1 parent 280a848 commit c723612
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/utils.liq
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ end
def smart_crossfade (~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)
~width=2.,~conservative=true,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])
Expand Down
9 changes: 7 additions & 2 deletions src/operators/smartcross.ml
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,19 @@ object (self)
method remaining =
match status with
| `Idle | `After _ -> source#remaining
| `Limit -> 0
| `Limit -> 0 (* TODO -1? *)
| `Before ->
let rem = source#remaining in
if rem<0 then -1 else
source#remaining +
Generator.length gen_before

method is_ready = source#is_ready
(** Contrary to cross.ml, the transition is only created (and stored in
* the source instance variable) after that status has moved from `Limit to
* `After. If is_ready becomes false at this point, source.ml will end the
* track before that the transition (or bare end of track) gets a chance
* to be played. *)
method is_ready = source#is_ready || status = `Limit

method abort_track = source#abort_track

Expand Down
5 changes: 4 additions & 1 deletion src/source.ml
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,10 @@ object (self)
* having to worry about availability.
* So we add this branch, which makes the whole protocol a bit
* sloppy because it removes any constraint tying #is_ready and
* #get. *)
* #get. It prevents the detection of "bad" calls of #get without
* having checked #is_ready. It also makes it really important
* to have #is_ready = true during tracks, otherwise this bit
* of code will forcefully end the track! *)
Frame.add_break buf (Frame.position buf)
else
let b = Frame.breaks buf in
Expand Down

0 comments on commit c723612

Please sign in to comment.