com.groovemanager.sampled.nondestructive
Class ReplaceElement

java.lang.Object
  extended by com.groovemanager.sampled.nondestructive.AbstractElement
      extended by com.groovemanager.sampled.nondestructive.ReplaceElement
All Implemented Interfaces:
CutListElement

public class ReplaceElement
extends AbstractElement

A ReplaceElement replaces a specified part of the CutListSource with another CutListSource. It also takes care of format conversion so that the inserted element has the same AudioFormat as the replaced element

Author:
Manu Robledo

Field Summary
private  int length
          Start position of the part to replace in sample frames
private  CutListSource newSource
          The source to replace the part with
private  int start
          Start position of the part to replace in sample frames
private  javax.sound.sampled.AudioFormat targetFormat
          The format into which the resulting AudioInputStreams should all be converted
 
Constructor Summary
ReplaceElement(java.lang.String name, CutListSource newSource, int start, int length, javax.sound.sampled.AudioFormat targetFormat)
          Construct a new ReplaceElement
 
Method Summary
 CutListElement duplicate()
          Create a new CutListElement out of this one that is independent of any changes made to this one.
 CutListSource getResult(CutListSource source)
          Create a new CutListSource out of the given source including this CutListElementīs modification.
 void replaceFile(java.io.File from, java.io.File to)
          Replace all references to the given source file inside this CutListElement with references to the given target file.
 boolean usesFile(java.io.File f)
          Ask this CutListElement whether it relies on the contents of the given file.
 
Methods inherited from class com.groovemanager.sampled.nondestructive.AbstractElement
addModificationListener, getName, 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 of the part to replace in sample frames


newSource

private CutListSource newSource
The source to replace the part with


start

private int start
Start position of the part to replace in sample frames


targetFormat

private javax.sound.sampled.AudioFormat targetFormat
The format into which the resulting AudioInputStreams should all be converted

Constructor Detail

ReplaceElement

public ReplaceElement(java.lang.String name,
                      CutListSource newSource,
                      int start,
                      int length,
                      javax.sound.sampled.AudioFormat targetFormat)
Construct a new ReplaceElement

Parameters:
name - The ReplaceElementīs name. May be the name of an applied Effect for example
newSource - The new CutListSource to replace the specified part with
start - Start position of the part to replace in sample frames
length - Length of the part to replace in sample frames
targetFormat - The AudioFormat into which all resulting AudioInputStreams should be converted
Method Detail

duplicate

public CutListElement duplicate()
Description copied from interface: CutListElement
Create a new CutListElement out of this one that is independent of any changes made to this one.

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

getResult

public CutListSource getResult(CutListSource source)
Description copied from interface: CutListElement
Create a new CutListSource out of the given source including this CutListElementīs modification.

Parameters:
source - The CutListSource to modify
Returns:
A modified CutListSource
See Also:
CutListElement.getResult(com.groovemanager.sampled.nondestructive.CutListSource)

replaceFile

public void replaceFile(java.io.File from,
                        java.io.File to)
Description copied from interface: CutListElement
Replace all references to the given source file inside this CutListElement 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 CutListElement, the call can be ignored.

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

usesFile

public boolean usesFile(java.io.File f)
Description copied from interface: CutListElement
Ask this CutListElement 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 element, false otherwise
See Also:
CutListElement.usesFile(java.io.File)