Interface RhythmDatabase
- All Known Implementing Classes:
DefaultRhythmDatabase
RhythmInfo instances are used to describe the available rhythms. Use getRhythmInstance(RhythmInfo) to get the Rhythm instance from a RhythmInfo instance.
-
Method Summary
Modifier and TypeMethodDescriptionvoidListeners are notified when the rhythm database has changed.booleanaddRhythm(RhythmProvider rp, RhythmInfo rInfo) Add one RhythmInfo to the database for the specified RhythmProvider.booleanAdd one Rhythm instance to the database for the specified RhythmProvider.default RhythmInfofindRhythm(String text, Predicate<RhythmInfo> tester) Find the RhythmInfo which "best matches" text.default RhythmInfofindRhythm(RhythmFeatures rf, Predicate<RhythmInfo> tester) Find the RhythmInfo which "best matches" rf.Try to provide the rhythm instance which is an adapted version of r for a different time signature.static RhythmDatabaseA helper method which just calls RhythmDatabaseFactory.getDefault().get().Get the default Rhythm for TimeSignature ts.default RhythmGet the default stub rhythm for the specified TimeSignature.Get the RhythmInfo instance from the specified rhythm unique id.getRhythmInstance(String rId) Get a rhythm instance from its id.getRhythmInstance(RhythmInfo rhythmInfo) Get a rhythm instance from a RhythmInfo.getRhythmProvider(Rhythm rhythm) Get the RhythmProvider for specified RhythmInfo.The RhythmProviders used by this database.default List<RhythmInfo> getRhythms(Predicate<RhythmInfo> tester) Get the rhythms which are tested OK.default List<RhythmInfo> Get the rhythms which match the specified time signature.The rhythms associated to the specified RhythmProviderdefault Set<TimeSignature> voidvoidsetDefaultRhythm(TimeSignature ts, RhythmInfo ri) Set the default rhythm for this TimeSignature.intsize()default StringReturn a string with the contents of the database.default StringA string showing statistics about the specified database.
-
Method Details
-
getDefault
A helper method which just calls RhythmDatabaseFactory.getDefault().get().- Returns:
-
getRhythmInstance
Get a rhythm instance from its id.If rId contains 2 instances of the AdaptedRhythm.RHYTHM_ID_DELIMITER, then this id represents an AdaptedRhythm which is created on demand, see AdaptedRhythm.getUniqueId().In that case, the rhythm provider, the original rhythm and the time signature are obtained from rId, and the returned rhythm instance is obtained by calling RhythmProvider.getAdaptedRhythmInstance(Rhythm, TimeSignature).
Rhythm instances can be cached.
- Parameters:
rId- Unique rhythm id- Returns:
- The rhythm whose uniqueId matches rId
- Throws:
UnavailableRhythmException- See Also:
-
getRhythmInstance
Get a rhythm instance from a RhythmInfo.This might result in a lengthy operation (e.g. because of file reading). Rhythm instances are cached.
- Parameters:
rhythmInfo-- Returns:
- Throws:
UnavailableRhythmException
-
getRhythm
Get the RhythmInfo instance from the specified rhythm unique id.RhyhmtInfo instances are cached.
- Parameters:
rhythmId-- Returns:
- Can be null if not found.
-
getAdaptedRhythmInstance
Try to provide the rhythm instance which is an adapted version of r for a different time signature.If the adapted rhythm could be obtained it is added in the database. AdaptedRhythm instances are cached.
- Parameters:
r-ts-- Returns:
- Can be null if no adapted rhythm is available.
- Throws:
IllegalArgumentException- If ts is the time signature of r, or if r is not a rhythm of this database.
-
getRhythms
Get the rhythms which are tested OK.- Parameters:
tester-- Returns:
-
getRhythms
Get the rhythms which match the specified time signature.- Parameters:
ts- TimeSignature- Returns:
- All rhythms corresponding to TimeSignature ts.
-
getRhythms
The rhythms associated to the specified RhythmProvider- Parameters:
rp-- Returns:
- Throws:
IllegalArgumentException- If rp is not a RhythmProvider available.
-
getRhythms
- Returns:
- All rhythms stored in the database.
-
findRhythm
Find the RhythmInfo which "best matches" rf.Default implementation relies on RhythmFeatures.getMatchingScore().
- Parameters:
rf-tester- Limit the search to RhythmInfo instances which match this tester.- Returns:
- Can be null if can't match genre
- See Also:
-
findRhythm
Find the RhythmInfo which "best matches" text.Default implementation returns the first RhythmInfo for which one of the tags is contained in text. Or whose name or description contains text (ignoring case).
- Parameters:
text-tester- Limit the search to RhythmInfo instances which match this tester.- Returns:
- Can be null
-
getRhythmProvider
- Parameters:
rhythm-- Returns:
- The RhythmProvider of the specified rhythm. Null if not found.
-
getRhythmProvider
Get the RhythmProvider for specified RhythmInfo.- Parameters:
ri-- Returns:
- The RhythmProvider of the specified RhythmInfo. Can be null.
-
getRhythmProviders
-
getTimeSignatures
- Returns:
- The list of TimeSignature for which we have at least 1 rhythm in the database
-
getDefaultRhythm
Get the default Rhythm for TimeSignature ts.- Parameters:
ts- TimeSignature- Returns:
- Can not be null, but there is no guarantee that getRhythmInstance() on the returned value will work (e.g. if this RhythmInfo depends on a file which is no more available).
-
getDefaultStubRhythmInstance
Get the default stub rhythm for the specified TimeSignature.- Parameters:
ts-- Returns:
- Can't be null.
-
setDefaultRhythm
Set the default rhythm for this TimeSignature.- Parameters:
ts- TimeSignatureri-- Throws:
IllegalArgumentException- If rhythm is not part of this database or if ri is an AdaptedRhythm
-
size
int size()- Returns:
- The number of rhythms in the database.
-
addRhythm
Add one RhythmInfo to the database for the specified RhythmProvider.Fire a state changed event if RhythmInfo is actually added.
- Parameters:
rp-rInfo-- Returns:
- True if rInfo was actually added.
-
addRhythmInstance
Add one Rhythm instance to the database for the specified RhythmProvider.Fire a state changed event if Rhythm is actually added.
- Parameters:
rp-r-- Returns:
- True if r was actually added.
-
addChangeListener
Listeners are notified when the rhythm database has changed.Note that listeners might be notified out of the Event Dispatch Thread.
- Parameters:
l-
-
removeChangeListener
-
toContentString
-
toStatsString
-