Class 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.
    • 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 of Clip
    • 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 from getStart(), as getStart() 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 whether p is contained in the selection, that is greater than getStart() and lower than getEnd().
        Parameters:
        p - the integer value to check for
        Returns:
        true if pos 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. If pos 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 if pos is contained in this clip an array with two new instances of Clip is returned. The clip at index 0, will range from geStart() to pos-1, whereas the clip at index 1 will range from pos to getEnd()
        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 interface java.lang.Comparable<Clip>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Range<java.lang.Integer>