com.groovemanager.sampled.nondestructive
Class ConcatSource

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

public class ConcatSource
extends AbstractSource

This class represents a CutListSource that is created out of some given CutListSources by concatenating them

Author:
Manu Robledo

Field Summary
private  CutListSource[] sources
          The sources to concatenate
 
Constructor Summary
ConcatSource(CutListSource[] sources)
          Create a new ConcatSource out of the given sources
 
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
protected  int getIndex(int pos)
          Get the index in the source Array for the CutListSource at the given frame position
 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

sources

private CutListSource[] sources
The sources to concatenate

Constructor Detail

ConcatSource

public ConcatSource(CutListSource[] sources)
Create a new ConcatSource out of the given sources

Parameters:
sources - The CutListSources to concatenate
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)

getIndex

protected int getIndex(int pos)
Get the index in the source Array for the CutListSource at the given frame position

Parameters:
pos - The frame position in question
Returns:
The index inside the source Array of the CutListSource to which the given frame position belongs

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)