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 usingComparable
the 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 Object
clone()
int
compareTo(Similarity that)
boolean
contains(long time)
boolean
contains(long time, TimeUnit timeUnit)
boolean
equals(Object o)
long
getA()
long
getA(TimeUnit timeUnit)
long
getB()
long
getB(TimeUnit timeUnit)
long
getDuration()
long
getDuration(TimeUnit timeUnit)
int
hashCode()
boolean
isDuringA(long time)
boolean
isDuringB(long time)
boolean
isRepeat()
Indicates whether the two similar segments follow each other right away.boolean
overlaps(Similarity that)
Indicates whether the two similarities overlap in any way.String
toJSONString()
String
toString()
long
translate(long time)
Translates a point in time to a similar point in time described by thisSimilarity
.long
translate(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:
compareTo
in 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
, iftime
is 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
, iftime
is 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:
toJSONString
in interfaceorg.json.simple.JSONAware
-
clone
public Object clone() throws CloneNotSupportedException
- Overrides:
clone
in classObject
- Throws:
CloneNotSupportedException
-
-