com.groovemanager.sampled.nondestructive
Class ConvertedSource

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

public class ConvertedSource
extends AbstractSource

This CutListSource is being constructed out of a given CutListSource and a target AudioFormat. When queried for an AudioInputStream, this source will try to provide a stream in this format out of the source´s stream by converting the stream if needed

Author:
Manu Robledo

Field Summary
(package private)  CutListSource source
          The source to get the unconverted stream from
(package private)  javax.sound.sampled.AudioFormat targetFormat
          The desired target AudioFormat
 
Constructor Summary
ConvertedSource(CutListSource source, javax.sound.sampled.AudioFormat targetFormat)
          Construct a new ConvertedSource out of the given CutListSource and AudioFormat
 
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

source

final CutListSource source
The source to get the unconverted stream from


targetFormat

final javax.sound.sampled.AudioFormat targetFormat
The desired target AudioFormat

Constructor Detail

ConvertedSource

public ConvertedSource(CutListSource source,
                       javax.sound.sampled.AudioFormat targetFormat)
Construct a new ConvertedSource out of the given CutListSource and AudioFormat

Parameters:
source - The CutListSource to get the unconverted stream from
targetFormat - The AudioFormat into which the stream will be converted
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)