Matching Tracks
Configure your triggers to respond only when particular tracks are being played.
Overview
As described in the Player Status Summary discussion, the most convenient way to match a track is using metadata obtained from the players, so Beat Link Trigger asks the player hosting the track for details like its title, artist, and so on. You can use this information to automatically write out a playlist during a performance, as described below.
In earlier releases of Beat Link Trigger, automatically matching tracks was not nearly so easy or reliable, and required more tricky and elaborate efforts. This section describes them, for historical reference, and in case you want to understand more about what BLT is doing for you automatically.
Rather than using the low-level approaches described in this section, you will almost always want to use the new, convenient Show interface introduced in version 0.5. It gives you an incredibly powerful graphical interface for matching tracks and defining cues on beat ranges within those tracks. |
If, for some reason, you don’t want to use the Show interface, and you are unable to get metadata (although as of version 0.5.0 we can’t think of any situations where this might apply), you can prepare ahead of time by hard-coding the rekordbox ID numbers in your triggers, or you can set up a Metadata Cache.
Manual Track Matching
The simplest approach is to configure your triggers to Watch Any Player, and use a custom Enabled Filter expression to activate them when any player has loaded the track that the trigger cares about. For example, in the following screen shot we have two triggers watching for two specific tracks:
The Enabled Filter expression for the first trigger is as follows:
(and
(= track-title "Ember (Original Mix)")
(= track-artist "Camo & Krooked"))
This activates the trigger whenever a player has loaded a track with
the specified exact title and artist. The values available for
matching are listed in the expression documentation you can scroll
through in the bottom half of the expression editor window, and other
metadata-based values include track-comment
, track-genre
,
track-key
, and track-length
. The entire
TrackMetadata
object is available as track-metadata
, if you want to use
Clojure Java Interop to
work with it.
In addition to using =
to match entire strings, you can use
re-matches
with
regular expressions for more flexible, loose matching. In addition to
the basic Clojure
documentation, the Java
Pattern
documentation provides details of how you can construct your regular
expressions. For example, to match any track whose title begins with
"Ember" you would use an expression like this:
(re-matches #"Ember.*" track-title)
Of course, you might also want the trigger to activate only when playback reaches a particular beat. You can combine as many different kinds of rules and logic as you need in your Enabled expression to achieve your goals:
(and
(= track-title "Sunset Lover")
(= track-artist "Petit Biscuit")
(>= beat-number 17))
To have the trigger active within a specific range of beats, you can express that in a single expression like so:
(and
(re-matches #"Ember.*" track-title)
(= track-artist "Camo & Krooked")
(<= 65 beat-number 192))
Including that within the trigger will enable it when a player that has loaded that specific track, and playback is positioned anywhere from beat 65 to 192, inclusive.
Writing a Playlist
Another way to take advantage of metadata support is to write out a file that logs all the tracks that were played during a DJ set. Here is a simple example of how to do that, although you can certainly get fancier in terms of how you format the timestamps and what information you log.
Starting with version 0.4.0, Beat Link Trigger has a built-in Playlist Writer window that does all this for you, and more. This discussion has been left in as an example of the kinds of things you can do with your expression code. |
Set up a Trigger that is configured to watch the Master Player, and install the following Tracked Update Expression:
(when trigger-active? (1)
(when (not= track-metadata (:last-track @locals)) (2)
(swap! locals assoc :last-track track-metadata) (3)
(when (some? track-metadata) (4)
(let [log-entry (with-out-str (5)
(println "Timestamp:" (str (java.time.LocalDateTime/now)))
(println " Artist:" track-artist)
(println " Title:" track-title)
(println))]
(spit "/Users/james/Desktop/playlist.txt" log-entry :append true))))) (6)
1 | Only proceed into the expression when there is a Master Player, and it is currently playing a track (because we configured the Trigger to Watch the Master Player). |
2 | Only proceed deeper into the expression if we have not yet written a playlist entry for this track metadata value (see step 3 for how this works). |
3 | Make a note of the metadata for the current track, because we are about to write a playlist entry for it, and only want to do it once. |
4 | Only proceed deeper into the expression if we actually have metadata, because otherwise we can’t create a meaningful playlist entry. |
5 | Format the lines of the playlist entry. |
6 | Append the formatted lines to the specified file. |
This version creates a file called playlist.txt on my desktop;
change the file path in the spit call to match where you want the
file created.
|
Whenever this trigger is enabled, as soon as a new track is being played by whatever player is currently the tempo master, a new entry will be written to the playlist log. The file content will look like this:
Timestamp: 2017-03-18T18:21:43.705
Artist: Exige & EJR
Title: Escape ft. Zoë Phillips (Bazarro Remix)
Timestamp: 2017-03-18T18:21:56.170
Artist: Imogen Heap
Title: Hide and Seek (Tiësto In Search of Summer mix)
Timestamp: 2017-03-18T18:22:07.713
Artist: Faithless
Title: insomnia 2008 (a1 electro mix)
License
Copyright © 2016–2019 Deep Symmetry, LLC
Distributed under the Eclipse Public License 1.0, the same as Clojure. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software. A copy of the license can be found in LICENSE within this project.
Library Licenses
Remote Tea, used for communicating with the NFSv2 servers on players, is licensed under the GNU Library General Public License, version 2.
The Kaitai Struct Java runtime, used for parsing rekordbox exports and media analysis files, is licensed under the MIT License.