name: Output : public AlgorithmBase
synopsis:

>     g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_algo.a

>     #include <Output.h>

>     Output(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);
>     Output(const Output& arg);
>     boolean assign(const Output& arg);
>     boolean setAlgorithm(ALGORITHM type);

quick start:

>     Output out;
>     Vector<CircularBuffer<AlgorithmData>> in;
>     Vector<AlgorithmData> out;
>     out.apply(output, input);

description:
The Output class is another class whose primary purpose is to facilitate recipe processing. This class is embedded in a recipe to output data, typically features, to a file. The Output class supports all data types defined in the AlgorithmData class.
The table below is provided for reference purposes, and defines the options available for this class:
Most programmers will not need to use this class since data can be output to files directly using standard class I/O methods. Users indirectly interact with this class when defining the output format and filenames for the output of their algorithm recipes.
dependencies:

- AlgorithmBase
- AudioFile
- FeatureFile
- Filename
- String

public constants:

- define the class name:

      static const String CLASS_NAME = L"Output";

- define algorithm choices:

      enum ALGORITHM { DATA = 0, DEF_ALGORITHM = DATA };

- define the implementation choices:

      enum IMPLEMENTATION { FEATURES = 0, SAMPLED_DATA DEF_IMPLEMENTATION = FEATURES };

- define the static NameMap objects

      static const NameMap ALGO_MAP(L"DATA");

      static const NameMap IMPL_MAP(L"SAMPLED_DATA, FEATURES");

- define i/o related variables:

      static const String DEF_PARAM = L"";

      static const String PARAM_ALGORITHM = L"algorithm";

      static const String PARAM_IMPLEMENTATION = L"implementation";

      static const String PARAM_BASENAME = L"basename";

      static const String PARAM_AUDIO_OUTPUT = L"audio_output";

      static const String PARAM_FEATURE_OUTPUT = L"feature_output";

      static const String PARAM_DMODE = L"data_mode";

- define default value(s) of the class data:

      static const String DEF_FILENAME = L"diagnose_file.sof";

      static const String DEF_TMP_FILE = L"";

error codes:

- general error codes:

      static const long ERR = 71400;

protected data:

- data common to all algorithms and implementations:
  - algorithm name:

        ALGORITHM algorithm_d;

  - implementation name:

        IMPLEMENTATION implementation_d;

  - variables that are used to hold filename information:

        Filename input_filename_d;

        Filename output_filename_d;

        String output_basename_d;

        String output_directory_d;

        String output_extension_d;

        Long output_preserve_d;

        String output_suffix_d;

  - output audio file to write out data:

        AudioFile audio_file_d;

  - output feature file to write out data:

        FeatureFile feature_output_d;

  - static memory manager:

        static MemoryManager mgr_d;

required public methods:

- static methods:

      static const String& name();

      static boolean diagnose(Integral::DEBUG debug_level);

- debug methods: setDebug method is inherited from base class

      boolean debug(const unichar* message) const;

- destructor/constructor(s):

      ~Output();

      Output(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);

      Output(const Output& arg);

- assign methods:

      boolean assign(const Output& arg);

- operator= methods:

      Output& operator= (const Output& arg);

- i/o methods:

      long sofSize() const;

      boolean read(Sof& sof, long tag, const String& name = CLASS_NAME);

      boolean write(Sof& sof, long tag, const String& name = CLASS_NAME) const;

      boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean readData(Sof& sof, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);

      boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;

      boolean writeData(Sof& sof) const;

- equality methods:

      boolean eq(const Output& arg) const;

- memory management methods:

      static void* operator new(size_t size);

      static void* operator new[](size_t size);

      static void operator delete(void* ptr);

      static void operator delete[](void* ptr);

      static boolean setGrowSize(long grow_size);

      boolean clear();

class-specific public methods:

- set methods:

      boolean setAlgorithm(ALGORITHM algorithm);

      boolean setImplementation(IMPLEMENTATION implementation);

      boolean setInputFilename(String& inputfilename);

      boolean setOutputFilename(String& filename);

      boolean setOutputBasename(String& basename);

      boolean setOutputDirectory(String& directory);

      boolean setOutputBasename(String& basename);

      boolean setOutputExtension(String& extension);

      boolean setOutputPreserve(long preserve);

      boolean setOutputSuffix(String& suffix);

      boolean setOutputType(File:TYPE type);

      boolean setFileType(AudioFile::FILE_TYPE type);

      boolean setFileType(FeatureFile::FILE_TYPE type);

      boolean setFileFormat(FeatureFile::FILE_FORMAT format);

      boolean setFileFormat(AudioFile::FILE_FORMAT format);

      boolean set(ALGORITHM algorithm = DEF_ALGORITHM, IMPLEMENTATION implementation = DEF_IMPLEMENTATION);

- get methods:

      ALGORITHM getAlgorithm() const;

      IMPLEMENTATION getImplementation() const;

      boolean getInputFilename(String& filename) const;

      boolean getOutputFilename(String& filename) const;

      boolean getOutputDirectory(String& filename) const;

      boolean getOutputBasename(String& basename) const;

      boolean getOutputExtension(String& extension) const;

      long getOutputPreserve() const;

      boolean getOutputSuffix(String& suffix) const;

      boolean get (ALGORITHM& algorithm, IMPLEMENTATION& implementationconst) const;

- AlgorithmBase interface contract methods:

      boolean assign(const AlgorithmBase& arg);

      boolean eq(const AlgorithmBase& arg) const;

      boolean apply(Vector<AlgorithmData>& output, const Vector<CircularBuffer<AlgorithmData> >& input);

      const String& className() const;

      boolean init();

      boolean setParser(SofParser* parser);

private methods:

- algorithm-specific i/o methods: DATA

      boolean readDataData(Sof& sof, const String& pname, long size, boolean param, boolean nested);

      boolean writeDataData(Sof& sof, const String& pname);

- implementation specific compute methods: FEATURES

      boolean computeFeatures(Vector<AlgorithmData>& output_a, const Vector< CircularBuffer<AlgorithmData> >& input_a);

      boolean computeSampledData(Vector<AlgorithmData>& output_a, const Vector< CircularBuffer<AlgorithmData> >& input_a);

      boolean transformName();

examples:

- This example shows how to write data to a file:

      // isip include files
      //
      #include <Output.h>

      // main program starts here
      //
      int main() {

        // testing writing out a SOF TEXT FEATURES file..
        //
        // declare local variable
        //
        Output c1;

        // set signal duration
        //
        c1.setSignalDuration(0.04);

        // set input file name
        //
        c1.setBasename(L"diagnose");

        // set output file extension
        //
        c1.setExtension(L"_ftr_text.sof");

        // set fie format
        //
        c1.setFileFormat(FeatureFile::SOF);

        // set implementation
        //
        c1.setImplementation(Output::FEATURES);

        // prepare some data
        //
        Vector < CircularBuffer < AlgorithmData> > in;
        Vector < AlgorithmData> out;

        Vector<VectorFloat> result;
        result.setLength(4);
        result(0).assign(L"1, 3, 5, 7, 9");
        result(1).assign(L"10, 30, 50, 70, 90");
        result(2).assign(L"100, 300, 500, 700, 900");
        result(3).assign(L"1000, 3000, 5000, 7000, 9000");

        long N = 1;
        in.setLength(1);

        // loop for all data
        //
        for (long j = 0; j < 4; j++) {
          in.clear();
          in.setLength(N);
          in(0)(0).makeVectorFloat();
          in(0)(0).getVectorFloat().assign(result(j));
          in(0)(0).setCoefType(AlgorithmData::SIGNAL);

          // call the main apply method
          //
          c1.apply(out, in);
        }

        // exit gracefully
        //
        Integral::exit();
      }

notes:

- None.