public class SignatureFinder extends LifecycleParticipant
Watches for new metadata to become available for tracks loaded on players, and when enough elements have been loaded, calculates a signature string that uniquely identifies the track, based on its title, artist, duration, waveform, and beat grid. Reports the signatures to any registered listeners once they have been identified. This supports the efficient triggering of cues based on the recognition of specific tracks, regardless of the media from which they have been loaded.
| Modifier and Type | Method and Description |
|---|---|
void |
addSignatureListener(SignatureListener listener)
Adds the specified signature listener to receive updates when the track signature for a player changes.
|
String |
computeTrackSignature(String title,
String artist,
int duration,
WaveformDetail waveformDetail,
BeatGrid beatGrid)
Calculate the signature by which we can reliably recognize a loaded track.
|
static SignatureFinder |
getInstance()
Get the singleton instance of this class.
|
String |
getLatestSignatureFor(DeviceUpdate update)
Look up the signature we have calculated for the track loaded in a player, identified by a status update
received from that player.
|
String |
getLatestSignatureFor(int player)
Look up the signature we have calculated for the track loaded in the specified player.
|
Set<SignatureListener> |
getSignatureListeners()
Get the set of currently-registered signature listeners.
|
Map<Integer,String> |
getSignatures()
Get the signatures that have been computed for all tracks currently loaded in any player for which we have
been able to obtain all necessary metadata.
|
boolean |
isRunning()
Check whether we are currently running.
|
void |
removeSignatureListener(SignatureListener listener)
Removes the specified signature listener so that it no longer receives updates when the
track signature for a player changes.
|
void |
start()
Start finding waveforms for all active players.
|
void |
stop()
Stop finding signatures for all active players.
|
String |
toString() |
addLifecycleListener, deliverLifecycleAnnouncement, ensureRunning, getLifecycleListeners, removeLifecycleListenerpublic boolean isRunning()
isRunning in class LifecycleParticipantMetadataFinder.isPassive()public Map<Integer,String> getSignatures()
IllegalStateException - if the SignatureFinder is not runningpublic String getLatestSignatureFor(int player)
player - the player whose track signature is desiredIllegalStateException - if the SignatureFinder is not runningpublic String getLatestSignatureFor(DeviceUpdate update)
update - a status update from the player for which a track signature is desiredIllegalStateException - if the SignatureFinder is not runningpublic void addSignatureListener(SignatureListener listener)
Adds the specified signature listener to receive updates when the track signature for a player changes.
If listener is null or already present in the set of registered listeners, no exception is
thrown and no action is performed.
Updates are delivered to listeners on the Swing Event Dispatch thread, so it is safe to interact with user interface elements within the event handler. Even so, any code in the listener method must finish quickly, or it will freeze the user interface, add latency for other listeners, and updates will back up. If you want to perform lengthy processing of any sort, do so on another thread.
listener - the track signature update listener to addpublic void removeSignatureListener(SignatureListener listener)
listener is null or not present
in the set of registered listeners, no exception is thrown and no action is performed.listener - the track signature update listener to removepublic Set<SignatureListener> getSignatureListeners()
public String computeTrackSignature(String title, String artist, int duration, WaveformDetail waveformDetail, BeatGrid beatGrid)
title - the track titleartist - the track artistduration - the duration of the track in secondswaveformDetail - the monochrome waveform detail of the trackbeatGrid - the beat grid of the tracknull if any arguments were nullpublic void start()
throws Exception
Start finding waveforms for all active players. Starts the MetadataFinder if it is not already
running, because we need it to send us metadata updates to notice when new tracks are loaded. This in turn
starts the DeviceFinder, so we can keep track of the comings and goings of players themselves.
We also start the WaveformFinder and BeatGridFinder in order get the other pieces of information
we need for computing track signatures.
Exception - if there is a problem starting the required componentspublic void stop()
public static SignatureFinder getInstance()
Copyright © 2016–2019 Deep Symmetry, LLC. All rights reserved.