tapeutils
Interface SampleAnalyzer

All Known Implementing Classes:
MultiSampleAnalyzer, ZX81SampleAnalyzer

public interface SampleAnalyzer

This class analyzes a sampled sound.

Author:
hldswrth

Method Summary
 void addAnalysisListener(AnalysisListener l)
          Register the given listener for analysis events.
 int analyze(int beginIndex, boolean printMessages)
          Analyze the sample to generate a set of peaks.
 void cleanUp()
          Clean up the state of the sample analyzer.
 void clearMessages(int index)
          Clear errors during analysis.
 void debugBitMessage(int index, java.lang.String message)
          Record the message if debugging bit processing.
 void debugByteMessage(int index, java.lang.String message)
          Record the message if debugging byte processing.
 boolean debuggingBit(int index)
          Determine whether the given level of debugging is enabled at the index.
 boolean debuggingByte(int index)
          Determine whether the given level of debugging is enabled at the index.
 boolean debuggingWave(int index)
          Determine whether the given level of debugging is enabled at the index.
 void debugWaveMessage(int index, java.lang.String message)
          Record the message if debugging wave processing.
 void error(int index, java.lang.String message)
          Record an error during analysis.
 int getBitEndIndex(int number)
          Get the index of the end of the given bit number.
 void getBitNumber(int index, int[] pos)
          Get the bit number at the given position in the sample.
 int getBitStartIndex(int number)
          Get the index of the start of the given bit number.
 int getBitValue(int index)
          Get the bit value at the given position in the sample.
 int getByte(int bytePosition)
          Get the byte value at the given byte position.
 int getByteIndex(int number)
          Get the position in the sample of the given byte.
 int getByteNumber(int index)
          Get the byte number at the given position in the sample.
 void getByteNumber(int index, int[] pos)
          Get the byte number at the given position in the sample.
 byte[] getBytes()
          Get all the bytes.
 java.lang.String getByteValue(int index)
          Get the byte value at the given position in the sample.
 int getFirstBitStartIndex()
          Get the index of the start of the first bit found in the sample.
 int getFitValue(int index)
          Get the fit value at the given position in the sample.
 int getLastBitEndIndex()
          Get the index of the end of the last bit extracted from the sample.
 int getMessageIndex(int messageNumber)
          Get the index of an message.
 Message[] getMessages()
          Get the error and warning messages.
 int getNoiseThreshold(int index)
          Get the noise threshold.
 int getNumBytes()
          Get the number of bytes.
 int getWaveValue(int index)
          Get the wave value at the given position in the sample.
 boolean isLoadComplete()
          Checks whether loading is complete.
 boolean isMessageError(int messageNumber)
          Identifies whether a message is an error or warning
 void loadCompleted()
          Indicates that loading is complete.
 int numErrors()
          Return the number of errors.
 int numMessages()
          Return the total number of messages generated during analysis.
 int numWarnings()
          Return the number of warnings.
 void printMessages()
          Print out all error and warning messages.
 int redo(boolean printMessages)
          Redo the last change to the sample.
 int setBitValue(int index, int value, boolean printMessages)
          Set the bit value at the given position in the sample.
 int undo(boolean printMessages)
          Undo the last change to the sample.
 void warning(int index, java.lang.String message)
          Record a warning during analysis.
 void write(java.io.OutputStream output)
          Write the bytes that have been extraced from the sample to the output stream.
 

Method Detail

analyze

public int analyze(int beginIndex,
                   boolean printMessages)
Analyze the sample to generate a set of peaks.

Parameters:
beginIndex - The index within the sample to begin processing.
printMessages - Indicates whether to print messages after analysis.
Returns:
The index at which analysis ended, -1 indicates an error.

isLoadComplete

public boolean isLoadComplete()
Checks whether loading is complete.

Returns:
Indicates whether loading is complete.

loadCompleted

public void loadCompleted()
Indicates that loading is complete.


write

public void write(java.io.OutputStream output)
           throws java.io.IOException
Write the bytes that have been extraced from the sample to the output stream.

Parameters:
output - The output stream.
Throws:
java.io.IOException - An error occurred writing to the stream.

getWaveValue

public int getWaveValue(int index)
Get the wave value at the given position in the sample.

Parameters:
index - The index of the sample.
Returns:
The wave value.

getFitValue

public int getFitValue(int index)
Get the fit value at the given position in the sample.

Parameters:
index - The index of the sample.
Returns:
The fit value.

getBitValue

public int getBitValue(int index)
Get the bit value at the given position in the sample.

Parameters:
index - The index.
Returns:
The bit value, as 0 or 1, or -1 for no value.

getBitNumber

public void getBitNumber(int index,
                         int[] pos)
Get the bit number at the given position in the sample.

Parameters:
index - The index.
pos - An array which will contain the bit number and offset from the start of the bit.

getBitStartIndex

public int getBitStartIndex(int number)
Get the index of the start of the given bit number.

Parameters:
number - The bit number.
Returns:
The index.

getBitEndIndex

public int getBitEndIndex(int number)
Get the index of the end of the given bit number.

Parameters:
number - The bit number.
Returns:
The index.

setBitValue

public int setBitValue(int index,
                       int value,
                       boolean printMessages)
Set the bit value at the given position in the sample.

Causes re-analysis of the sample.

Parameters:
index - The index.
value - The new bit value.
printMessages - Indicates whether to print messages after analysis.
Returns:
Returns the new end of the sample.

undo

public int undo(boolean printMessages)
Undo the last change to the sample.

Parameters:
printMessages - Indicates whether to print messages after analysis.
Returns:
The index in the sample where the undo operation occurred.

redo

public int redo(boolean printMessages)
Redo the last change to the sample.

Parameters:
printMessages - Indicates whether to print messages after analysis.
Returns:
The index in the sample where the undo operation occurred.

getByteValue

public java.lang.String getByteValue(int index)
Get the byte value at the given position in the sample.

Parameters:
index - The index.
Returns:
The description of the byte value, null for no value.

getByteNumber

public int getByteNumber(int index)
Get the byte number at the given position in the sample.

Parameters:
index - The index.
Returns:
The byte number.

getByteNumber

public void getByteNumber(int index,
                          int[] pos)
Get the byte number at the given position in the sample.

Parameters:
index - The index.
pos - An array which will contain the byte number and offset from the start of the byte.

getByte

public int getByte(int bytePosition)
Get the byte value at the given byte position.

Parameters:
bytePosition - The index.
Returns:
The byte value.

getBytes

public byte[] getBytes()
Get all the bytes.

Returns:
The byte values.

getNumBytes

public int getNumBytes()
Get the number of bytes.

Returns:
The number of bytes.

getByteIndex

public int getByteIndex(int number)
Get the position in the sample of the given byte.

Parameters:
number - The byte number.
Returns:
The index in the sample.

getNoiseThreshold

public int getNoiseThreshold(int index)
Get the noise threshold.

Parameters:
index - The index in the sample of the noise threshold value.
Returns:
The noise threshold.

getFirstBitStartIndex

public int getFirstBitStartIndex()
Get the index of the start of the first bit found in the sample.

Returns:
The index of the start of the first bit.

getLastBitEndIndex

public int getLastBitEndIndex()
Get the index of the end of the last bit extracted from the sample.

Returns:
The index of the end of the last bit.

warning

public void warning(int index,
                    java.lang.String message)
Record a warning during analysis.

Parameters:
index - The index of the error.
message - The warning message.

error

public void error(int index,
                  java.lang.String message)
Record an error during analysis.

Parameters:
index - The index of the warning.
message - The error message.

clearMessages

public void clearMessages(int index)
Clear errors during analysis.

Parameters:
index - The index from which to clear errors.

numErrors

public int numErrors()
Return the number of errors.

Returns:
The number of errors.

getMessageIndex

public int getMessageIndex(int messageNumber)
Get the index of an message.

Parameters:
messageNumber - The message number.
Returns:
The index.

isMessageError

public boolean isMessageError(int messageNumber)
Identifies whether a message is an error or warning

Parameters:
messageNumber - The message number.
Returns:
true if the message is an

numMessages

public int numMessages()
Return the total number of messages generated during analysis.

Returns:
The number of messages.

numWarnings

public int numWarnings()
Return the number of warnings.

Returns:
The number of warnings.

printMessages

public void printMessages()
Print out all error and warning messages.


getMessages

public Message[] getMessages()
Get the error and warning messages.

Returns:
An array containing the messages.

cleanUp

public void cleanUp()
Clean up the state of the sample analyzer.


addAnalysisListener

public void addAnalysisListener(AnalysisListener l)
Register the given listener for analysis events.

Parameters:
l - The listener.

debugWaveMessage

public void debugWaveMessage(int index,
                             java.lang.String message)
Record the message if debugging wave processing.

Parameters:
index - The index in the sample to which the message applies.
message -

debugBitMessage

public void debugBitMessage(int index,
                            java.lang.String message)
Record the message if debugging bit processing.

Parameters:
index - The index in the sample to which the message applies.
message -

debugByteMessage

public void debugByteMessage(int index,
                             java.lang.String message)
Record the message if debugging byte processing.

Parameters:
index - The index in the sample to which the message applies.
message -

debuggingWave

public boolean debuggingWave(int index)
Determine whether the given level of debugging is enabled at the index.

Parameters:
index - The index in the sample to which the message applies.
Returns:
Indicates whether the given level of debugging is enabled at the index.

debuggingBit

public boolean debuggingBit(int index)
Determine whether the given level of debugging is enabled at the index.

Parameters:
index - The index in the sample to which the message applies.
Returns:
Indicates whether the given level of debugging is enabled at the index.

debuggingByte

public boolean debuggingByte(int index)
Determine whether the given level of debugging is enabled at the index.

Parameters:
index - The index in the sample to which the message applies.
Returns:
Indicates whether the given level of debugging is enabled at the index.