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.zx81
Class TapeConverter

    java.lang.Object
      tapeutils.zx81.TapeConverter

All Implemented Interfaces:
  AnalysisListener

public class TapeConverter
extends java.lang.Object
implements AnalysisListener

This class provides a utility to convert from a sample file to a (ZX81) .P file.

Author:
  hldswrth

Field Summary
`static java.lang.String` | `APPLICATION_NAME` The application name.
`static java.lang.String` | `DEBUG_FILE` The debug file name.
`static java.lang.String` | `PREF_ANALYSIS_CONFIG_FILE` The key used to access the analysis config file name.
`static java.lang.String` | `PREF_DEBUG_BIT` The debug bit preference key.
`static java.lang.String` | `PREF_DEBUG_BYTE` The debug byte preference key.
`static java.lang.String` | `PREF_DEBUG_END` The debug end index preference key.
`static java.lang.String` | `PREF_DEBUG_FILE` The debug file preference key.
`static java.lang.String` | `PREF_DEBUG_START` The debug start index preference key.
`static java.lang.String` | `PREF_DEBUG_WAVE` The debug wave preference key.
`static java.lang.String` | `PREF_P_PROGRAM_NAME` The .P program name used when generating sample from .P.
`static java.lang.String` | `PREF_PFILE_DIRECTORY` The key used to access the .P file directory.
`static java.lang.String` | `PREF_SAMPLE_DIRECTORY` The key used to access the sample directory.
`static java.lang.String` | `PREF_SAMPLE_RATE` The key used to access the sample rate.
`static java.lang.String` | `PREF_SAVE_SAMPLE_AS_ZIP` The key used to access the save sample as zip file preference.
`static java.lang.String` | `PREF_SQUARE_WAVE` The square wave indicator.
`static java.lang.String` | `PREF_TZXFILE_DIRECTORY` The key used to access the .P file directory.

Constructor Summary
`TapeConverter(java.io.File sample1File, java.io.File sample2File, TapeConverterParameters sample1Params, TapeConverterParameters sample2Params, boolean showGUI)` Constructor.
`TapeConverter(java.io.File sampleFile, TapeConverterParameters sampleParams)` Constructor.

Method Summary
`void` | `addAnalysisListener(int sampleNumber, AnalysisListener l)` Register the given listener for analysis events.
`void` | `addMessageSelectionListener(int sampleNumber, MessageSelectionListener l)` Register the given listener for message selection events.
`void` | `analysisComplete(AnalysisEvent event)` Handle an analysis completion event.
`void` | `cleanUp()` Clean up the converter state.
`void` | `closeSample(int sampleNumber)` Close the given sample.
`void` | `convert()` Convert the loaded sample(s).
`void` | `fireMessageSelectionEvent(int sampleNumber, int messageNumber)` Fire a message selection event.
`ConversionFrame` | `getConversionFrame()` Returns the conversion frame.
`TapeConverterParameters` | `getParameters(int sampleNumber)` Get the ConvertParameters for the sample.
`PreferenceAccessor` | `getPreferences(java.lang.Object accessor)` Get the preferences object.
`Sample` | `getSample(int sampleNumber)` Get the Sample.
`SampleAnalyzer` | `getSampleAnalyzer(int sampleNumber)` Get the Sample Analyzer
`java.io.File` | `getSampleFile(int sampleNumber)` Returns the requested sample file.
`void` | `loadConfig(java.io.File configFile)` Load the given configuration file.
`void` | `loadSample(java.io.File sampleFile, int sampleNumber)` Load the given sample file as the first or second sample.
`static void` | `main(java.lang.String[] args)` Main routine.
`int` | `numErrors(int sampleNumber)` Returns the number of errors in conversion.
`int` | `numSamples()` Returns the number of samples being processed.
`int` | `redo(int sampleNumber)` Redo the last change for the given sample.
`void` | `samplePropertiesUpdated(int sampleNumber)` Inform the coverter that the sample properties have changed.
`void` | `saveConfig(java.io.File configFile)` Save to the given configuration file.
`void` | `saveSample(java.io.File sampleFile, int sampleNumber)` Save the given sample file as the first or second sample.
`int` | `undo(int sampleNumber)` Undo the last change for the given sample.
`void` | `writePFile(int sampleNumber, int index, java.io.File pFile)` Write the analyzed data to the .P file.
`void` | `writePFile(int sampleNumber, int index, java.io.OutputStream os)` Write the analyzed data to the output stream.
`void` | `writePFiles(int sampleNumber, boolean forceWrite)` Write the analyzed data to the .P files.
`void` | `writePFiles(int sampleNumber, boolean forceWrite, java.lang.String[] pFileNames)` Write the analyzed data to the .P files.
`int` | `writePFiles(int sampleNumber, java.io.File directory)` Write out the results of analysis as .P files.
`void` | `writeTZXFile(int sampleNumber, java.io.File tzxFile)` Write the files as a single .TZX file.

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

Field Detail

### APPLICATION_NAME

    public static final java.lang.String APPLICATION_NAME

  The application name.

  See Also:
    Constant Field Values

### DEBUG_FILE

    public static final java.lang.String DEBUG_FILE

  The debug file name.

  See Also:
    Constant Field Values

### PREF_SAMPLE_DIRECTORY

    public static final java.lang.String PREF_SAMPLE_DIRECTORY

  The key used to access the sample directory.

  See Also:
    Constant Field Values

### PREF_PFILE_DIRECTORY

    public static final java.lang.String PREF_PFILE_DIRECTORY

  The key used to access the .P file directory.

  See Also:
    Constant Field Values

### PREF_TZXFILE_DIRECTORY

    public static final java.lang.String PREF_TZXFILE_DIRECTORY

  The key used to access the .P file directory.

  See Also:
    Constant Field Values

### PREF_ANALYSIS_CONFIG_FILE

    public static final java.lang.String PREF_ANALYSIS_CONFIG_FILE

  The key used to access the analysis config file name.

  See Also:
    Constant Field Values

### PREF_SAMPLE_RATE

    public static final java.lang.String PREF_SAMPLE_RATE

  The key used to access the sample rate.

  See Also:
    Constant Field Values

### PREF_P_PROGRAM_NAME

    public static final java.lang.String PREF_P_PROGRAM_NAME

  The .P program name used when generating sample from .P.

  See Also:
    Constant Field Values

### PREF_SQUARE_WAVE

    public static final java.lang.String PREF_SQUARE_WAVE

  The square wave indicator.

  See Also:
    Constant Field Values

### PREF_SAVE_SAMPLE_AS_ZIP

    public static final java.lang.String PREF_SAVE_SAMPLE_AS_ZIP

  The key used to access the save sample as zip file preference.

  See Also:
    Constant Field Values

### PREF_DEBUG_WAVE

    public static final java.lang.String PREF_DEBUG_WAVE

  The debug wave preference key.

  See Also:
    Constant Field Values

### PREF_DEBUG_BIT

    public static final java.lang.String PREF_DEBUG_BIT

  The debug bit preference key.

  See Also:
    Constant Field Values

### PREF_DEBUG_BYTE

    public static final java.lang.String PREF_DEBUG_BYTE

  The debug byte preference key.

  See Also:
    Constant Field Values

### PREF_DEBUG_START

    public static final java.lang.String PREF_DEBUG_START

  The debug start index preference key.

  See Also:
    Constant Field Values

### PREF_DEBUG_END

    public static final java.lang.String PREF_DEBUG_END

  The debug end index preference key.

  See Also:
    Constant Field Values

### PREF_DEBUG_FILE

    public static final java.lang.String PREF_DEBUG_FILE

  The debug file preference key.

  See Also:
    Constant Field Values

Constructor Detail

### TapeConverter

    public TapeConverter(java.io.File sampleFile,
                         TapeConverterParameters sampleParams)
                  throws java.lang.Exception

  Constructor.

  This variant is used to convert a single sample with no GUI.

Parameters:
  `sampleFile` - The sample file.
  `sampleParams` - Conversion parameters.
Throws:
  `java.lang.Exception`

### TapeConverter

    public TapeConverter(java.io.File sample1File,
                         java.io.File sample2File,
                         TapeConverterParameters sample1Params,
                         TapeConverterParameters sample2Params,
                         boolean showGUI)
                  throws java.lang.Exception

  Constructor.

Parameters:
  `sample1File` - The sample file.
  `sample2File` - The second sample file.
  `sample1Params` - Conversion parameters for sample 1.
  `sample2Params` - Conversion parameters for sample 2.
  `showGUI` - Indicates whether to show the GUI.
Throws:
  `java.lang.Exception`

Method Detail

### main

    public static void main(java.lang.String[] args)
                     throws java.lang.Exception

  Main routine.

  Arguments:

       [{-sampleFile |-s} fileName]    The name of the sample file (.WAV, .AIFF, etc.)
       [{-sample2File|-2} fileName]    The name of the second sample file (.WAV, .AIFF, etc.)
       [{-pFile      |-p} fileName]    The name of the .p file to save to (only valid with -noGui/-g)
       [{-noGui      |-g}]             Don't display GUI.
       [{-invert     |-i}]             Invert sample.
       [{-noise      |-n} noiseLevel]  Noise threshold.
       [{-minGap     |-m} minGap]      Minimum gap between groups.
       [{-maxGap     |-x} maxGap]      Maximum gap between groups.
       [{-channel    |-h} channel]     Channel number.
       [{-data       |-d} numBytes]    Data only.  Don't interpret as a BASIC program.
       [{-forceWrite |-w}]             Force write of result after errors.
       [{-begin      |-b} index]       Index within sample to start processing.
       [{-configFile |-c} configFile]  Name of a properties file with convert parameters.

  Parameters:
    `args` - The arguments.
  Throws:
    `java.lang.Exception` - Something went wrong.

### convert

    public void convert()

  Convert the loaded sample(s).

### samplePropertiesUpdated

    public void samplePropertiesUpdated(int sampleNumber)
                                 throws java.io.IOException,
                                        javax.sound.sampled.UnsupportedAudioFileException

  Inform the coverter that the sample properties have changed.

  Parameters:
    `sampleNumber` - The sample number.
  Throws:
    `java.io.IOException`
    `javax.sound.sampled.UnsupportedAudioFileException`

### writePFiles

    public int writePFiles(int sampleNumber,
                           java.io.File directory)
                    throws java.io.IOException

  Write out the results of analysis as .P files.

  Parameters:
    `sampleNumber` - The sample number.
    `directory` - The directory in which to save the .P files.
  Returns:
    The number of files written.
  Throws:
    `java.io.IOException`

### writePFiles

    public void writePFiles(int sampleNumber,
                            boolean forceWrite,
                            java.lang.String[] pFileNames)
                     throws java.io.IOException

  Write the analyzed data to the .P files.

  Parameters:
    `sampleNumber` - The sample number.
    `forceWrite` - Force writing of data after errors.
    `pFileNames` - The .P file names that override the generated ones.
  Throws:
    `java.io.IOException`

### writePFiles

    public void writePFiles(int sampleNumber,
                            boolean forceWrite)
                     throws java.io.IOException

  Write the analyzed data to the .P files.

  Parameters:
    `sampleNumber` - The sample number.
    `forceWrite` - Force writing of data after errors.
  Throws:
    `java.io.IOException`

### writePFile

    public void writePFile(int sampleNumber,
                           int index,
                           java.io.File pFile)
                    throws java.io.IOException

  Write the analyzed data to the .P file.

  Parameters:
    `sampleNumber` - The sample number.
    `index` - The index of the data.
    `pFile` - The .P file.
  Throws:
    `java.io.IOException`

### writePFile

    public void writePFile(int sampleNumber,
                           int index,
                           java.io.OutputStream os)
                    throws java.io.IOException

  Write the analyzed data to the output stream.

  Parameters:
    `sampleNumber` - The sample number.
    `index` - The index of the data.
    `os` - The output stream.
  Throws:
    `java.io.IOException`

### writeTZXFile

    public void writeTZXFile(int sampleNumber,
                             java.io.File tzxFile)
                      throws java.io.IOException

  Write the files as a single .TZX file.

  Parameters:
    `sampleNumber` - The sample number.
    `tzxFile` - The .TZX file.
  Throws:
    `java.io.IOException`

### numErrors

    public int numErrors(int sampleNumber)

  Returns the number of errors in conversion.

  Parameters:
    `sampleNumber` - The sample number.
  Returns:
    The number of errors.

### cleanUp

    public void cleanUp()

  Clean up the converter state.

### getParameters

    public TapeConverterParameters getParameters(int sampleNumber)

  Get the ConvertParameters for the sample.

  Parameters:
    `sampleNumber` -
  Returns:
    The convert parameters.

### getSample

    public Sample getSample(int sampleNumber)

  Get the Sample.

  Parameters:
    `sampleNumber` - The sample number.
  Returns:
    The sample.

### getSampleAnalyzer

    public SampleAnalyzer getSampleAnalyzer(int sampleNumber)

  Get the Sample Analyzer

  Parameters:
    `sampleNumber` - The sample number.
  Returns:
    The sample analyzer.

### getSampleFile

    public java.io.File getSampleFile(int sampleNumber)

  Returns the requested sample file.

  Parameters:
    `sampleNumber` - The sample number.
  Returns:
    The sample file.

### numSamples

    public int numSamples()

  Returns the number of samples being processed.

  Returns:
    The number of samples.

### undo

    public int undo(int sampleNumber)

  Undo the last change for the given sample.

  Parameters:
    `sampleNumber` -
  Returns:
    The index of the last change.

### redo

    public int redo(int sampleNumber)

  Redo the last change for the given sample.

  Parameters:
    `sampleNumber` -
  Returns:
    The index of the last change.

### getConversionFrame

    public ConversionFrame getConversionFrame()

  Returns the conversion frame.

  Returns:
    The conversion frame.

### loadSample

    public void loadSample(java.io.File sampleFile,
                           int sampleNumber)
                    throws java.io.IOException,
                           javax.sound.sampled.UnsupportedAudioFileException

  Load the given sample file as the first or second sample.

  If the file is actually a .p or .tzx file its converted to a sample.

  Parameters:
    `sampleFile` - The sample file.
    `sampleNumber` - The sample number.
  Throws:
    `java.io.IOException` - The file could not be loaded.
    `javax.sound.sampled.UnsupportedAudioFileException`

### saveSample

    public void saveSample(java.io.File sampleFile,
                           int sampleNumber)
                    throws java.io.IOException

  Save the given sample file as the first or second sample.

  Parameters:
    `sampleFile` - The sample file.
    `sampleNumber` - The sample number.
  Throws:
    `java.io.IOException`

### closeSample

    public void closeSample(int sampleNumber)

  Close the given sample.

  Parameters:
    `sampleNumber` - The sample number.

### loadConfig

    public void loadConfig(java.io.File configFile)
                    throws java.io.IOException

  Load the given configuration file.

  Parameters:
    `configFile` - The configuration file.
  Throws:
    `java.io.IOException`

### saveConfig

    public void saveConfig(java.io.File configFile)
                    throws java.io.IOException

  Save to the given configuration file.

  Parameters:
    `configFile` - The configuration file.
  Throws:
    `java.io.IOException`

### getPreferences

    public PreferenceAccessor getPreferences(java.lang.Object accessor)

  Get the preferences object.

  Parameters:
    `accessor` - The object accessing the preferences object.
  Returns:
    The Preference accessor.

### addAnalysisListener

    public void addAnalysisListener(int sampleNumber,
                                    AnalysisListener l)

  Register the given listener for analysis events.

  Parameters:
    `sampleNumber` - The sample number.
    `l` - The listener.

### analysisComplete

    public void analysisComplete(AnalysisEvent event)

  Handle an analysis completion event.

  Cascade the event to the listeners registered with this object.

  Specified by:
    `analysisComplete` in interface `AnalysisListener`
  Parameters:
    `event` - An object representing the event.

### addMessageSelectionListener

    public void addMessageSelectionListener(int sampleNumber,
                                            MessageSelectionListener l)

  Register the given listener for message selection events.

  Parameters:
    `sampleNumber` - The sample number.
    `l` - The listener.

### fireMessageSelectionEvent

    public void fireMessageSelectionEvent(int sampleNumber,
                                          int messageNumber)

  Fire a message selection event.

  Parameters:
    `sampleNumber` - The sample number.
    `messageNumber` - The message number.

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