com.groovemanager.sampled.nondestructive
Class SubSource

java.lang.Object
  extended by com.groovemanager.sampled.nondestructive.AbstractSource
      extended by com.groovemanager.sampled.nondestructive.SubSource
All Implemented Interfaces:
CutListSource

public class SubSource
extends AbstractSource

A SubSource represents a part of another source

Author:
Manu Robledo

Field Summary
private  int length
          Start position in sample frames of the resulting source
private  CutListSource source
          The original source
private  int start
          Start position in sample frames of the resulting source
 
Constructor Summary
SubSource(CutListSource source, int start, int length)
          Construct a new SubSource out of the given source
 
Method Summary
 CutListSource duplicate()
          Create a new CutListSource that represents the same data, but is independent of changes made to this source
 javax.sound.sampled.AudioInputStream getAudioInputStream(int start, int length)
          Get an AudioInputStream from this source
 int getLength()
          Get the total length of this source in sample frames
 WaveForm getWaveForm(int start, int length, int width)
          Get a WaveForm from this source
 boolean isReady()
          Ask this source, if it is ready for providing audio data
 void replaceFile(java.io.File from, java.io.File to)
          Replace all references to the given source file inside this CutListSource with references to the given target file.
 boolean usesFile(java.io.File f)
          Ask this CutListSource whether it relies on the contents of the given file.
 
Methods inherited from class com.groovemanager.sampled.nondestructive.AbstractSource
addModificationListener, notifyListeners, removeModificationListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

private int length
Start position in sample frames of the resulting source


source

private CutListSource source
The original source


start

private int start
Start position in sample frames of the resulting source

Constructor Detail

SubSource

public SubSource(CutListSource source,
                 int start,
                 int length)
Construct a new SubSource out of the given source

Parameters:
source - The original source
start - Start position of the resulting source in sample frames
length - Length of the resulting source in sample frames
Method Detail

duplicate

public CutListSource duplicate()
Description copied from interface: CutListSource
Create a new CutListSource that represents the same data, but is independent of changes made to this source

Returns:
An independent copy of this source
See Also:
CutListSource.duplicate()

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(int start,
                                                                int length)
                                                         throws NotReadyException
Description copied from interface: CutListSource
Get an AudioInputStream from this source

Parameters:
start - The start position of the stream in sample frames
length - The length of the stream in sample frames
Returns:
An AudioInputStream starting at position start of this source with the length of length sample frames.
Throws:
NotReadyException - If the audio data can not be provided
See Also:
CutListSource.getAudioInputStream(int, int)

getLength

public int getLength()
Description copied from interface: CutListSource
Get the total length of this source in sample frames

Returns:
The length of this source in sample frames
See Also:
CutListSource.getLength()

getWaveForm

public WaveForm getWaveForm(int start,
                            int length,
                            int width)
Description copied from interface: CutListSource
Get a WaveForm from this source

Parameters:
start - The start position of the WaveForm in sample frames
length - The length of the audio data represented by the WaveForm in sample frames
width - The width in which the WaveForm should be displayed
Returns:
A WaveForm starting at position start of this source representing length sample frames with the width of width.
See Also:
CutListSource.getWaveForm(int, int, int)

isReady

public boolean isReady()
Description copied from interface: CutListSource
Ask this source, if it is ready for providing audio data

Returns:
true, if this source can provide data, false otherwise
See Also:
CutListSource.isReady()

replaceFile

public void replaceFile(java.io.File from,
                        java.io.File to)
Description copied from interface: CutListSource
Replace all references to the given source file inside this CutListSource with references to the given target file. This may be because the source file is about to change and to avoid inconsistencies. If the given source file is not used by this CutListSource, the call can be ignored.

Parameters:
from - The source file to replace
to - The target file to replace with
See Also:
CutListSource.replaceFile(java.io.File, java.io.File)

usesFile

public boolean usesFile(java.io.File f)
Description copied from interface: CutListSource
Ask this CutListSource whether it relies on the contents of the given file. This is needed, if a file should be overwritten and it must be checked that this doesn´t cause any inconsistencies

Parameters:
f - The file to ask for
Returns:
true, if a change to the given file´s content would also mean a change to this source, false otherwise
See Also:
CutListSource.usesFile(java.io.File)