tapeutils.impl.zx81
Class ZX81WaveProcessor

java.lang.Object
  extended bytapeutils.impl.zx81.ZX81WaveProcessor
All Implemented Interfaces:
WaveProcessor

public class ZX81WaveProcessor
extends java.lang.Object
implements WaveProcessor

This class provides a processor for wave information that is specific to a ZX81 sound sample.

The timings for waves, groups, and gaps is set it this class, along with the fact that '0' is four waves and '1' is nine waves.

Author:
hldswrth

Constructor Summary
ZX81WaveProcessor(Sample sample, SampleAnalyzer analyzer, int minGap, int maxGap, BitProcessor processor)
          Construct the wave processor, given the sample to be processed, the object controlling analysis, and the bit processor.
 
Method Summary
 int checkGroupGap(int lastEnd, int nextStart)
          Check the gap between the given groups.
 int getActualMaxGroupGap()
          Get the actual maximum group gap.
 int getActualMaxOneLength()
          Get the actual maximum one length.
 int getActualMaxZeroLength()
          Get the actual maximum zero length.
 int getActualMinGroupGap()
          Get the actual minimum group gap.
 int getActualMinOneLength()
          Get the actual minimum one length.
 int getActualMinZeroLength()
          Get the actual minimum zero length.
 void initialize()
          Initialize this object ready for processing a sample.
 int processWave(int waveStart, int waveEnd, int amplitude, int minLength, int maxLength, int currentPos)
          Process a wave within the sample.
 void setWaveIdentifier(WaveIdentifier identifier)
          Set the object to be used to identify waves.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZX81WaveProcessor

public ZX81WaveProcessor(Sample sample,
                         SampleAnalyzer analyzer,
                         int minGap,
                         int maxGap,
                         BitProcessor processor)
Construct the wave processor, given the sample to be processed, the object controlling analysis, and the bit processor.

Parameters:
sample - The sample.
analyzer - The sample analyzer.
minGap - The minimum gap between bits.
maxGap - The maximum gap between bits.
processor - The bit processor.
Method Detail

setWaveIdentifier

public void setWaveIdentifier(WaveIdentifier identifier)
Set the object to be used to identify waves.

Specified by:
setWaveIdentifier in interface WaveProcessor
Parameters:
identifier - The wave identifier.

initialize

public void initialize()
Initialize this object ready for processing a sample.

Specified by:
initialize in interface WaveProcessor

processWave

public int processWave(int waveStart,
                       int waveEnd,
                       int amplitude,
                       int minLength,
                       int maxLength,
                       int currentPos)
Process a wave within the sample.

Specified by:
processWave in interface WaveProcessor
Parameters:
waveStart - The start of the wave.
waveEnd - The end of the wave.
amplitude - The amplitude of the wave.
minLength - The minimum allowed wavelength.
maxLength - The maximum allowed wavelength.
currentPos - The current sample position.
Returns:
The position in the sample at which processing should continue.

checkGroupGap

public int checkGroupGap(int lastEnd,
                         int nextStart)
Check the gap between the given groups.

Specified by:
checkGroupGap in interface WaveProcessor
Parameters:
lastEnd - The last group end.
nextStart - The next group start.
Returns:
The suggested gap, or 0 if its OK.

getActualMinGroupGap

public int getActualMinGroupGap()
Get the actual minimum group gap.

Specified by:
getActualMinGroupGap in interface WaveProcessor
Returns:
The actual minimum group gap.

getActualMaxGroupGap

public int getActualMaxGroupGap()
Get the actual maximum group gap.

Specified by:
getActualMaxGroupGap in interface WaveProcessor
Returns:
The actual maximum group gap.

getActualMinZeroLength

public int getActualMinZeroLength()
Get the actual minimum zero length.

Specified by:
getActualMinZeroLength in interface WaveProcessor
Returns:
The actual minimum zero length.

getActualMaxZeroLength

public int getActualMaxZeroLength()
Get the actual maximum zero length.

Specified by:
getActualMaxZeroLength in interface WaveProcessor
Returns:
The actual maximum zero length.

getActualMinOneLength

public int getActualMinOneLength()
Get the actual minimum one length.

Specified by:
getActualMinOneLength in interface WaveProcessor
Returns:
The actual minimum one length.

getActualMaxOneLength

public int getActualMaxOneLength()
Get the actual maximum one length.

Specified by:
getActualMaxOneLength in interface WaveProcessor
Returns:
The actual maximum one length.