Skip to content

Commit

Permalink
Fix blank logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
toots committed Dec 12, 2023
1 parent 46b79af commit 6b93328
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/core/sources/blank.ml
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ class blank duration =
| _ -> failwith "Invalid content type!")
frame
in
if remaining < length then (
let frame = Frame.add_track_mark frame remaining in
remaining <- length - remaining;
frame)
else frame
match remaining with
| -1 -> frame
| r ->
if r < length then (
remaining <- length - r;
Frame.add_track_mark frame r)
else (
remaining <- r - length;
frame)
end

let blank =
Expand Down
3 changes: 3 additions & 0 deletions tests/streams/dtmf.liq
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ s = amplify(0.5, dtmf(duration=1., keys))

# s = add([s, amplify(0.5, noise())]) # Removed to make the test deterministic
s = dtmf.detect(debug=false, s, f)

clock.assign_new(sync="none", [s])

output.dummy(fallible=true, s)
4 changes: 4 additions & 0 deletions tests/streams/dtmf_pcm_s16.liq
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
log.level.set(4)

keys = "1234567890*#ABCD"
detected = ref("")

Expand All @@ -23,4 +24,7 @@ s = audio.decode.pcm_s16(s)

# s = add([s, amplify(0.5, noise())]) # Removed to make the test deterministic
s = dtmf.detect(debug=false, s, f)

clock.assign_new(sync="none", [s])

output.dummy(fallible=true, s)

0 comments on commit 6b93328

Please sign in to comment.