Skip to content

Instantly share code, notes, and snippets.

@spinitron
Last active September 12, 2018 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spinitron/02c7a9e476af43c1cc33df50a4e048df to your computer and use it in GitHub Desktop.
Save spinitron/02c7a9e476af43c1cc33df50a4e048df to your computer and use it in GitHub Desktop.
Metadata push: Default and Max Duration

Metadata push: Default and Max Duration

This article details Spinitron's timing of metadata push events and cancellation policy, in which the Default Duration and Max Duration configurations play their part.

Spinitron's metadata push feature sends now-playing song updates to things such as stream servers, RDS encoders and the like. We assume that the receiver of a push message updates its display to users when it receives the message. So the timing of when Spinitron sends the message is important.

If Spinitron has advance knowledge of a spin, it schedules to send its push messages at the spin's timestamp. But if is told about the spin late, which can easily happen with manual playlist entry, then it will either push the message immediately, if the information is not too old, or not at all.

Spinitron's rules for pushing spins

  • If the spin is in the future, push when it starts.
  • Push the spin immediately if it didn't start too long ago and it has not already ended. MAX DURATION seconds would be too long. Use DEFAULT DURATION to figure if the spin has ended if we don't have an explicit spin duration.
  • Otherwise cancel the push.

Choosing values

DEFAULT DURATION and MAX DURATION are configurations you assign on a per-channel basis. If you set them too small and a DJ is slow to enter spins into a manual playlist, they may not be pushed.

DEFAULT DURATION has no effect if the spin's duration is set.

MAX DURATION is like a cutoff meaning: Don't push if the spin is entered more than this many seconds late.

DEFAULT DURATION = 300 and MAX DURATION = 600 might be reasonable values.

Formal spec

In technical terms, with respect to a given spin, define

  • NOW is the moment Spinitron receives the spin
  • TIMESTAMP is the spin's explicit timestamp.
  • DURATION is the spin's explicit duration, if known, otherwise DEFAULT DURATION
  • AGE ≡ NOW - TIMESTAMP

Then, if AGE

  • ≤ 0 then schedule the push for TIMESTAMP,
  • ≥ DURATION then cancel the push,
  • ≥ MAX DURATION then cancel the push;

otherwise push immediately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment