Package uk.ac.qmul.eecs.depic.daw
Class Clip
- java.lang.Object
-
- uk.ac.qmul.eecs.depic.patterns.Range<java.lang.Integer>
-
- uk.ac.qmul.eecs.depic.daw.Clip
-
- All Implemented Interfaces:
- java.lang.Comparable<Clip>
public class Clip extends Range<java.lang.Integer> implements java.lang.Comparable<Clip>
A Clip is a piece of audio Sample. Clips representing different parts of the same audio sample all share a reference to the same Sample. This way manipulating clips doesn't involve manipulating all the samples but just references to them.
-
-
Field Summary
-
Fields inherited from class uk.ac.qmul.eecs.depic.patterns.Range
end, NORMALIZED_RANGE_D, NORMALIZED_RANGE_F, start
-
-
Constructor Summary
Constructors Constructor and Description Clip(int start, int end, Sample sample, int sampleStart, float millisecPerChunk)
Clip(Clip c)
Copy constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description int
compareTo(Clip s)
boolean
contains(int pos)
Checks whetherp
is contained in the selection, that is greater thangetStart()
and lower thangetEnd()
.boolean
containsTime(float time)
float
getEndTimeMs()
float
getMillisecPerChunk()
Sample
getSample()
int
getSampleStart()
Returns the chunks index where this selection starts relative to the start of the sample.float
getSampleStartMs()
float
getStartTimeMs()
static Clip
join(Clip clip1, Clip clip2)
void
setStartAt(int position)
void
shift(int amount)
Shifts the clips of the amount given as argumentClip[]
split(int pos)
Splits the selection around the given position.java.lang.String
toString()
-
-
-
Constructor Detail
-
Clip
public Clip(int start, int end, Sample sample, int sampleStart, float millisecPerChunk)
-
Clip
public Clip(Clip c)
Copy constructor- Parameters:
c
- another instance ofClip
-
-
Method Detail
-
shift
public void shift(int amount)
Shifts the clips of the amount given as argument- Parameters:
amount
-
-
setStartAt
public void setStartAt(int position)
-
getSample
public Sample getSample()
-
getSampleStart
public int getSampleStart()
Returns the chunks index where this selection starts relative to the start of the sample. This is different fromgetStart()
, asgetStart()
returns the absolute position (a.k.a. chunk index) of the selection start- Returns:
-
getSampleStartMs
public float getSampleStartMs()
-
getStartTimeMs
public float getStartTimeMs()
-
getEndTimeMs
public float getEndTimeMs()
-
getMillisecPerChunk
public float getMillisecPerChunk()
-
contains
public boolean contains(int pos)
Checks whetherp
is contained in the selection, that is greater thangetStart()
and lower thangetEnd()
.- Parameters:
p
- the integer value to check for- Returns:
true
ifpos
is contained in the selection,false
otherwise
-
containsTime
public boolean containsTime(float time)
-
split
public Clip[] split(int pos)
Splits the selection around the given position. Ifpos
is less than the clip start or greater than the clip end, then the array will have size 1 and will contain this Clip. Conversely ifpos
is contained in this clip an array with two new instances ofClip
is returned. The clip at index 0, will range fromgeStart()
topos-1
, whereas the clip at index 1 will range frompos
togetEnd()
- Parameters:
pos
- the split position- Returns:
- an array of one or two clips, resulted from a split at position
pos
-
compareTo
public int compareTo(Clip s)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Clip>
-
-