Skip to content

Commit

Permalink
Properly detect cues ending, fixes #155
Browse files Browse the repository at this point in the history
  • Loading branch information
brunchboy committed Mar 4, 2023
1 parent e155a9d commit acbd4b2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 31 deletions.
42 changes: 25 additions & 17 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,42 @@ This change log follows the conventions of
- Phrase trigger cues were [not reliably sending their end
messages](https://github.com/Deep-Symmetry/beat-link-trigger/issues/142)
when the phrase ended.
- Duplicating a cue did not compile its expressions, so they would not
work until edited, or the show was closed and reopened, #151.
- Duplicating a cue also corrupted the show structure, which would
cause BLT to fail to quit because of an exception later on, #153.
- Duplicating a cue with an empty name would fail because of a
`NullPointerException` trying to assign a unique name to the new
cue, #152.
- Due to a [different
issue](https://github.com/Deep-Symmetry/beat-link-trigger/issues/155),
track cues were never sending their end messages.
- Duplicating a cue [did not compile its
expressions](https://github.com/Deep-Symmetry/beat-link-trigger/issues/151),
so they would not work until edited, or the show was closed and
reopened.
- Duplicating a cue also [corrupted the show
structure](https://github.com/Deep-Symmetry/beat-link-trigger/issues/153),
which would cause BLT to fail to quit because of an exception later
on.
- Duplicating a cue with an empty name [would
fail](https://github.com/Deep-Symmetry/beat-link-trigger/issues/152)
because of a `NullPointerException` trying to assign a unique name
to the new cue.
- The binding of `midi-output` in Phrase Expressions was incorrectly
expecting `show` to be already bound for it, which caused
expressions that used `midi-output` to fail to compile.
- Phrase Expression bindings which relied on calling
`.getDeviceNumber` did not work for expressions that receive
beat-tpu tuples.
- The variable `locals` was being bound even in expressions which have
no locals, such as the Global Setup Expression. This caused the
expression to seem to compile fine, allowing the editor to close,
but would lead to a `NullPointerException` if any code tried to use
`locals`.
- The variable `locals` was being bound [even in expressions which
have no
locals](https://github.com/Deep-Symmetry/beat-link-trigger/issues/147),
such as the Global Setup Expression. This caused the expression to
seem to compile fine, allowing the editor to close, but would lead
to a `NullPointerException` if any code tried to use `locals`.
- The implementation of the expression convenience variable
`players-inside` was broken when phrase triggers were implemented,
leading to a crash when attempting to use it. This release restores
its intended value.
`players-inside` [was
broken](https://github.com/Deep-Symmetry/beat-link-trigger/issues/150)
when phrase triggers were implemented, leading to a crash when
attempting to use it. This release restores its intended value.
- It seems that Java under Windows sometimes sees its own broadcast
packets come back from an IPv6 address, which has led to quirky
networking problems. The upgrade to Java 17 made this even worse, so
the Windows installer now runs Java in a way that disables IPv6.
- Trying to duplicate a cue with a blank name would result in a
`NullPointerException` rather than a new cue.

### Added

Expand Down
6 changes: 3 additions & 3 deletions src/beat_link_trigger/show.clj
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@
(doseq [uuid (set/intersection entered old-entered)]
(when-let [cue (find-cue track uuid)] ; Make sure it wasn't deleted.
(let [is-playing (seq (cues/players-playing-cue track cue))
was-playing (seq (cues/players-playing-cue old-track cue))
was-playing (seq (cues/players-playing-cue (:last show) old-track old-track cue))
event (if is-playing
(if (and beat (= (:start cue) (.beatNumber position)))
:started-on-beat
Expand Down Expand Up @@ -554,7 +554,7 @@
;; Report cues we have newly exited, which we might also have previously been playing.
(doseq [uuid (set/difference old-entered entered)]
(when-let [cue (find-cue track uuid)]
(when (seq (cues/players-playing-cue old-track cue))
(when (seq (cues/players-playing-cue (:last show) old-track old-track cue))
#_(timbre/info "detected end..." (:uuid cue))
(cues/send-cue-messages old-track old-track cue :ended (or status beat)))
(cues/send-cue-messages old-track old-track cue :exited (or status beat))
Expand Down Expand Up @@ -646,7 +646,7 @@
(when (:tripped old-track) ; Otherwise we never reported entering/playing them, so nothing to do now.
(doseq [uuid (set/difference old-entered entered)]
(when-let [cue (find-cue track uuid)]
(when (seq (cues/players-playing-cue old-track cue))
(when (seq (cues/players-playing-cue (:last show) old-track old-track cue))
(cues/send-cue-messages track track cue :ended status))
(cues/send-cue-messages track track cue :exited status)
(cues/repaint-cue track cue)
Expand Down
26 changes: 15 additions & 11 deletions src/beat_link_trigger/show_cues.clj
Original file line number Diff line number Diff line change
Expand Up @@ -446,17 +446,21 @@

(defn players-playing-cue
"Returns the set of players that are currently playing the specified
cue."
[context cue]
(let [[show context runtime-info] (latest-show-and-context context)]
(reduce (fn [result player]
(if ((get-in runtime-info [:entered player]) (:uuid cue))
(conj result player)
result))
#{}
(if (track? context)
(util/players-signature-set (:playing show) (:signature context))
(util/players-phrase-uuid-set (:playing-phrases show) (:uuid context))))))
cue. Or, with the four-argument arity, reports the players that were
playing the cue at the time the show snapshot and runtime-info were
captured."
([context cue]
(let [[show context runtime-info] (latest-show-and-context context)]
(players-playing-cue show context runtime-info cue)))
([show-snapshot context runtime-info cue]
(reduce (fn [result player]
(if ((get-in runtime-info [:entered player]) (:uuid cue))
(conj result player)
result))
#{}
(if (track? context)
(util/players-signature-set (:playing show-snapshot) (:signature context))
(util/players-phrase-uuid-set (:playing-phrases show-snapshot) (:uuid context))))))

(defn entered?
"Checks whether any player has entered the cue.
Expand Down

0 comments on commit acbd4b2

Please sign in to comment.