Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## tapeutils.impl.zx81
Class ZX81SampleAnalyzer

    java.lang.Object
      tapeutils.impl.zx81.ZX81SampleAnalyzer

All Implemented Interfaces:
  SampleAnalyzer

public class ZX81SampleAnalyzer
extends java.lang.Object
implements SampleAnalyzer

This class analyzes a sampled sound to extract data.

It provides a ZX81-specific implementation.

Author:
  hldswrth

Constructor Summary
`ZX81SampleAnalyzer(Sample sample, ZX81SampleAnalyzerParameters params)` Construct the sample analyzer from a sample.

Method Summary
`void` | `addAnalysisListener(AnalysisListener l)` Register the given listener for analysis events.
`int` | `analyze(int beginIndex, boolean printMessages)` Analyze the sample to extract the data within it.
`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 position, 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 byteNumber)` Get the byte value at the given index.
`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 position of a message.
`Message[]` | `getMessages()` Get the error and warning messages.
`int` | `getNoiseThreshold(int index)` Get the noise threshold.
`int` | `getNumBytes()` Get the number of bytes.
`java.lang.String` | `getProgramName()` Get the name of the program.
`byte[]` | `getProgramNameBytes()` Get the name of the program as 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 of the 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.
`void` | `setDebugLevels(DebugLevels levels)` Set debug levels.
`void` | `setProgramName(java.lang.String name)` Set the name of the program.
`void` | `setProgramNameBytes(byte[] bytes, int length)` Set the name of the program as bytes.
`int` | `undo(boolean printMessages)` Undo the last change to the sample.
`void` | `warning(int position, 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.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### ZX81SampleAnalyzer

    public ZX81SampleAnalyzer(Sample sample,
                              ZX81SampleAnalyzerParameters params)

  Construct the sample analyzer from a sample.

Parameters:
  `sample` - The sample.
  `params` - The parameters.

Method Detail

### analyze

    public int analyze(int beginIndex,
                       boolean printMessages)

  Analyze the sample to extract the data within it.

  Specified by:
    `analyze` in interface `SampleAnalyzer`
  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.

  Specified by:
    `isLoadComplete` in interface `SampleAnalyzer`
  Returns:
    Indicates whether loading is complete.

### loadCompleted

    public void loadCompleted()

  Indicates that loading is complete.

  Specified by:
    `loadCompleted` in interface `SampleAnalyzer`

### 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.

  Specified by:
    `write` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getWaveValue` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getFitValue` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getBitValue` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getBitNumber` in interface `SampleAnalyzer`
  Parameters:
    `index` - The index of the position in the sample.
    `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.

  Specified by:
    `getBitStartIndex` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getBitEndIndex` in interface `SampleAnalyzer`
  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.

  Specified by:
    `setBitValue` in interface `SampleAnalyzer`
  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.

  Specified by:
    `undo` in interface `SampleAnalyzer`
  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.

  Specified by:
    `redo` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getByteValue` in interface `SampleAnalyzer`
  Parameters:
    `index` - The index.
  Returns:
    The byte value, -1 for no value.

### getBytes

    public byte[] getBytes()

  Get all the bytes.

  Specified by:
    `getBytes` in interface `SampleAnalyzer`
  Returns:
    The byte values.

### getByteNumber

    public int getByteNumber(int index)

  Get the byte number at the given position in the sample.

  Specified by:
    `getByteNumber` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getByteNumber` in interface `SampleAnalyzer`
  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 byteNumber)

  Get the byte value at the given index.

  Specified by:
    `getByte` in interface `SampleAnalyzer`
  Parameters:
    `byteNumber` - The index.
  Returns:
    The byte value.

### getNumBytes

    public int getNumBytes()

  Get the number of bytes.

  Specified by:
    `getNumBytes` in interface `SampleAnalyzer`
  Returns:
    The number of bytes.

### getByteIndex

    public int getByteIndex(int number)

  Get the position in the sample of the given byte.

  Specified by:
    `getByteIndex` in interface `SampleAnalyzer`
  Parameters:
    `number` - The byte number.
  Returns:
    The index in the sample.

### getNoiseThreshold

    public int getNoiseThreshold(int index)

  Get the noise threshold.

  Specified by:
    `getNoiseThreshold` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getFirstBitStartIndex` in interface `SampleAnalyzer`
  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.

  Specified by:
    `getLastBitEndIndex` in interface `SampleAnalyzer`
  Returns:
    The index of the end of the last bit.

### warning

    public void warning(int position,
                        java.lang.String message)

  Record a warning during analysis.

  Specified by:
    `warning` in interface `SampleAnalyzer`
  Parameters:
    `position` - The position of the warning.
    `message` - The warning message.

### numMessages

    public int numMessages()

  Return the total number of messages generated during analysis.

  Specified by:
    `numMessages` in interface `SampleAnalyzer`
  Returns:
    The number of messages.

### numWarnings

    public int numWarnings()

  Return the number of warnings.

  Specified by:
    `numWarnings` in interface `SampleAnalyzer`
  Returns:
    The number of warnings.

### error

    public void error(int position,
                      java.lang.String message)

  Record an error during analysis.

  Specified by:
    `error` in interface `SampleAnalyzer`
  Parameters:
    `position` - The position of the warning.
    `message` - The error message.

### clearMessages

    public void clearMessages(int index)

  Clear errors during analysis.

  Specified by:
    `clearMessages` in interface `SampleAnalyzer`
  Parameters:
    `index` - The index from which to clear errors/warnings.

### numErrors

    public int numErrors()

  Return the number of errors.

  Specified by:
    `numErrors` in interface `SampleAnalyzer`
  Returns:
    The number of errors.

### getMessageIndex

    public int getMessageIndex(int messageNumber)

  Get the position of a message.

  Specified by:
    `getMessageIndex` in interface `SampleAnalyzer`
  Parameters:
    `messageNumber` - The message number.
  Returns:
    The position.

### isMessageError

    public boolean isMessageError(int messageNumber)

  Identifies whether a message is an error or warning

  Specified by:
    `isMessageError` in interface `SampleAnalyzer`
  Parameters:
    `messageNumber` - The message number.
  Returns:
    true if the message is an

### printMessages

    public void printMessages()

  Print out all of the messages.

  Specified by:
    `printMessages` in interface `SampleAnalyzer`

### getMessages

    public Message[] getMessages()

  Get the error and warning messages.

  Specified by:
    `getMessages` in interface `SampleAnalyzer`
  Returns:
    An array containing the messages.

### setProgramName

    public void setProgramName(java.lang.String name)

  Set the name of the program.

  Parameters:
    `name` - The program name.

### getProgramName

    public java.lang.String getProgramName()

  Get the name of the program.

  Returns:
    The program name.

### setProgramNameBytes

    public void setProgramNameBytes(byte[] bytes,
                                    int length)

  Set the name of the program as bytes.

  Parameters:
    `bytes` - The program name bytes.
    `length` - The program name bytes length.

### getProgramNameBytes

    public byte[] getProgramNameBytes()

  Get the name of the program as bytes.

  Returns:
    The program name bytes.

### cleanUp

    public void cleanUp()

  Clean up the state of the sample analyzer.

  Specified by:
    `cleanUp` in interface `SampleAnalyzer`

### addAnalysisListener

    public void addAnalysisListener(AnalysisListener l)

  Register the given listener for analysis events.

  Specified by:
    `addAnalysisListener` in interface `SampleAnalyzer`
  Parameters:
    `l` - The listener.

### setDebugLevels

    public void setDebugLevels(DebugLevels levels)

  Set debug levels.

  Parameters:
    `levels` -

### debugWaveMessage

    public void debugWaveMessage(int index,
                                 java.lang.String message)

  Record the message if debugging wave processing.

  Specified by:
    `debugWaveMessage` in interface `SampleAnalyzer`
  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.

  Specified by:
    `debugBitMessage` in interface `SampleAnalyzer`
  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.

  Specified by:
    `debugByteMessage` in interface `SampleAnalyzer`
  Parameters:
    `index` - The index in the sample to which the message applies.
    `message` -

### debuggingWave

    public final boolean debuggingWave(int index)

  Determine whether the given level of debugging is enabled at the index.

  Specified by:
    `debuggingWave` in interface `SampleAnalyzer`
  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 final boolean debuggingBit(int index)

  Determine whether the given level of debugging is enabled at the index.

  Specified by:
    `debuggingBit` in interface `SampleAnalyzer`
  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 final boolean debuggingByte(int index)

  Determine whether the given level of debugging is enabled at the index.

  Specified by:
    `debuggingByte` in interface `SampleAnalyzer`
  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.

Overview | Package | Class | Use | Tree | Serialized | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD