Package com.tagtraum.audiokern.segments
Class Similarity
- java.lang.Object
-
- com.tagtraum.audiokern.segments.Similarity
-
- All Implemented Interfaces:
Cloneable,Comparable<Similarity>,org.json.simple.JSONAware
public class Similarity extends Object implements Cloneable, org.json.simple.JSONAware, Comparable<Similarity>
Similarity describing two similar sounding segments in an audio signal. When compared usingComparablethe natural order of the similarity's length is used.- Author:
- Hendrik Schreiber
-
-
Constructor Summary
Constructors Constructor Description Similarity(long a, long b, long duration)Creates a similarity, describing two audio signal segments that have a high similarity.Similarity(org.json.simple.JSONObject jsonObject)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectclone()intcompareTo(Similarity that)booleancontains(long time)booleancontains(long time, TimeUnit timeUnit)booleanequals(Object o)longgetA()longgetA(TimeUnit timeUnit)longgetB()longgetB(TimeUnit timeUnit)longgetDuration()longgetDuration(TimeUnit timeUnit)inthashCode()booleanisDuringA(long time)booleanisDuringB(long time)booleanisRepeat()Indicates whether the two similar segments follow each other right away.booleanoverlaps(Similarity that)Indicates whether the two similarities overlap in any way.StringtoJSONString()StringtoString()longtranslate(long time)Translates a point in time to a similar point in time described by thisSimilarity.longtranslate(long time, TimeUnit timeUnit)Translates a point in time to a similar point in time described by thisSimilarity.
-
-
-
Constructor Detail
-
Similarity
public Similarity(long a, long b, long duration)Creates a similarity, describing two audio signal segments that have a high similarity.- Parameters:
a- start time in millisecondsb- start time in millisecondsduration- length in milliseconds
-
Similarity
public Similarity(org.json.simple.JSONObject jsonObject)
-
-
Method Detail
-
getA
public long getA()
-
getB
public long getB()
-
getDuration
public long getDuration()
-
compareTo
public int compareTo(Similarity that)
- Specified by:
compareToin interfaceComparable<Similarity>
-
translate
public long translate(long time)
Translates a point in time to a similar point in time described by thisSimilarity.- Parameters:
time- time in milliseconds- Returns:
- either a point in time or
-1, iftimeis not contained in either of the two audio segments described by this similarity
-
contains
public final boolean contains(long time)
-
isDuringB
public final boolean isDuringB(long time)
-
isDuringA
public final boolean isDuringA(long time)
-
overlaps
public boolean overlaps(Similarity that)
Indicates whether the two similarities overlap in any way.- Parameters:
that- other similarity- Returns:
- true, if there is some overlap
-
getA
public long getA(TimeUnit timeUnit)
-
getB
public long getB(TimeUnit timeUnit)
-
getDuration
public long getDuration(TimeUnit timeUnit)
-
translate
public long translate(long time, TimeUnit timeUnit)Translates a point in time to a similar point in time described by thisSimilarity.- Parameters:
time- timetimeUnit- time unit, time is in- Returns:
- either a point in time or
-1, iftimeis not contained in either of the two audio segments described by this similarity
-
contains
public boolean contains(long time, TimeUnit timeUnit)
-
isRepeat
public boolean isRepeat()
Indicates whether the two similar segments follow each other right away.- Returns:
- true or false
-
toJSONString
public String toJSONString()
- Specified by:
toJSONStringin interfaceorg.json.simple.JSONAware
-
clone
public Object clone() throws CloneNotSupportedException
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
-