quick start:g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_mmedia.a #include <FeatureFile.h> FeatureFile(); long getBufferedData(Vector<AlgorithmData>& data, long start_pos = DEF_START_POS, long num_elem = DEF_NUM_ELEM); long getBufferedData(VectorFloat& data, long channel_tag, long start_pos, long num_elem); boolean setFileType(FILE_TYPE file_type);
description:FeatureFile src; src.open(L"/tmp/input.sof"); Vector <VectorFloat> data(1); src.getBufferedData(data(0), 0, 50, 10); Filename output(L"/tmp/output.sof"); FeatureFile dst; dst.open(output, File::WRITE_ONLY); dst.writeFeatureData(data, 0);
static const String CLASS_NAME = L"FeatureFile";
enum FILE_TYPE { TEXT = 0, BINARY, DEF_FILE_TYPE = TEXT };
enum FILE_FORMAT { SOF = 0, RAW, DEF_FILE_FORMAT = SOF };
enum COMP_TYPE { LINEAR = 0, ULAW, ALAW, DEF_COMP_TYPE = LINEAR };
enum SAMPLE_PRECISION { NONE = 0, USE_SIZE, EIGHT_BITS, TWELVE_BITS, SIXTEEN_BITS, TWENTY_BITS, TWENTY_FOUR_BITS, THIRTY_TWO_BITS, DEF_SAMPLE_PRECISION = NONE };
enum DATA_TYPE { VECTOR_FLOAT = 0, DEF_DATA_TYPE = VECTOR_FLOAT };
static NameMap FILE_TYPE_MAP;
static NameMap FILE_FORMAT_MAP;
static NameMap COMP_TYPE_MAP;
static NameMap SAMPLE_PRECISION_MAP;
static NameMap DATA_TYPE_MAP;
static const String PARAM_NAME = L"name";
static const String PARAM_FILE_TYPE = L"file_type";
static const String PARAM_FILE_FORMAT = L"file_format";
static const String PARAM_COMP_TYPE = L"compression_type";
static const String PARAM_RANGE = L"amplitude_range";
static const String PARAM_NUM_CHANNELS = L"num_channels";
static const String PARAM_ID = L"id";
static const String PARAM_NUM_FEATURES = L"num_features";
static const String PARAM_DATA_TYPE = L"data_type";
static const String PARAM_COEF_TYPE = L"coef_type";
static const String PARAM_TAG = L"tag";
static const String PARAM_BLOCK_SIZE = L"block_size";
static const String PARAM_BUF_SIZE = L"buf_size";
static const String PARAM_FRAME_DURATION = L"frame_duration";
static const String PARAM_SAMPLE_FREQUENCY = L"sample_frequency";
static const String PARAM_DATA = L"values";
static const long CHANNEL_TAG_RIGHT = 1;
static const long CHANNEL_TAG_LEFT = 0;
static const long CHANNEL_TAG_ALL = -2;
static const long DEF_CHANNEL_TAG = CHANNEL_TAG_ALL;
static const long DEF_BLOCK_SIZE = 8192;
static const long DEF_BUF_SIZE = 4;
static const long DEF_NUMBER_OF_FEATURES = 39;
static const long DEF_START_POS = 0;
static const long DEF_NUM_ELEM = 4000;
static const long DEF_TAG = 0;
static const String DEF_FEATURE_NAME = L"FEATURES";
static const long DEF_NUM_CHANNELS = 1;
static const double DEF_FRAME_DURATION = 0.01;
static const double DEF_SAMPLE_FREQ = 8000.0;
static const double DEF_AMPLITUDE_RANGE = 1.0;
static const long DEF_SAMPLE_NUM_BYTES = 2;
static const double DEF_START_TIME = 0.0;
static const double DEF_CENTER_TIME = 0.25;
static const double DEF_DURATION = 0.5;
static const long ERR = 50400;
FILE_TYPE file_type_d;
FILE_FORMAT file_format_d;
COMP_TYPE compression_type_d;
Double amplitude_range__d;
Double amplitude_range_d;
Long num_channels_d;
String id_d;
Long num_features_d;
DATA_TYPE data_type_d;
AlgorithmData::COEF_TYPE coef_type_d;
Long tag_d;
Sof in_sof_d;
Long block_size_d;
Long buf_size_d;
Float frame_duration_d;
Float sample_frequency_d;
Vectorv_d;
File raw_features_d;
Vector<CircularBuffer<VectorFloat> > buffers_d;
Vectorbuf_end_ftr_d;
boolean no_data_d;
boolean end_of_file_d;
long sof_length_pos_d;
static Integral::DEBUG debug_level_d;
static MemoryManager mgr_d;
inline static const String& name();
static boolean diagnose(Integral::DEBUG debug_level);
boolean debug(const unichar* message) const;
inline boolean setDebug(Integral::DEBUG debug_level);
~FeatureFile();
FeatureFile(FILE_TYPE ftype = DEF_FILE_TYPE, FILE_FORMAT fformat = DEF_FILE_FORMAT, DATA_TYPE dtype = DEF_DATA_TYPE);
FeatureFile(const FeatureFile& copy_feature_file);
boolean assign(const FeatureFile& copy_ftrf);
inline FeatureFile& operator= (const FeatureFile& arg);
long sofSize() const;
boolean read(Sof& sof, long tag, const String& name);
boolean write(Sof& sof, long tag, const String& name) const;
boolean readData(Sof& sof, const String& pname = String::getEmptyString(), long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);
boolean writeData(Sof& sof, const String& pname = String::getEmptyString()) const;
boolean eq(const FeatureFile& arg) const;
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();
boolean open(const Filename& filename, MODE mode = READ_ONLY);
boolean open(const unichar* filename, MODE mode = READ_ONLY);
boolean close();
boolean isOpen() const;
long getBufferedData(Vector<AlgorithmData>& data, long start_pos = DEF_START_POS, long num_elem = DEF_NUM_ELEM);
long getBufferedData(Vector<VectorFloat>& data, long start_pos = DEF_START_POS);
long getBufferedData(VectorFloat& data, long channel_tag, long start_pos = DEF_START_POS, long num_elem = DEF_NUM_ELEM);
long readFeatureData(Vector<VectorFloat>& data, long ctag, long start_pos, long num_elem);
long writeFeatureData(Vector<AlgorithmData>& data, long channel_tag = DEF_CHANNEL_TAG);
long writeFeatureData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG);
AlgorithmData& operator()(long index);
AlgorithmData& operator()(long index) const;
AlgorithmData& operator()(long ctag, long frame);
AlgorithmData& operator()(long ctag, long frame) const;
boolean setName(const String& arg);
boolean setFileType(FILE_TYPE file_type);
boolean setFileFormat(FILE_FORMAT file_format);
boolean setCompType(COMP_TYPE comp_type);
boolean setAmplitudeRange(double range_threshold);
boolean setNumChannels(long num_channels);
boolean setID(const String& arg);
boolean setNumFeatures(long arg);
boolean setDataType(DATA_TYPE dtype);
boolean setCoefType(AlgorithmData::COEF_TYPE type);
boolean setFrameDuration(float arg);
boolean setSampleFrequency(float arg);
boolean setLength(long arg);
boolean setBufferSize(long nblocks);
const String& getName() const;
FILE_TYPE getFileType() const;
FILE_FORMAT getFileFormat() const;
COMP_TYPE getCompType() const;
double getAmplitudeRange() const;
long getNumChannels() const;
String& getID() const;
long getNumFeatures() const;
DMODE getDataType() const;
AlgorithmData::COEF_TYPE getCoefType() const;
float getFrameDuration() const;
float getSampleFrequency() const;
long getNumFrames(const Sof& sof) const;
long getNumFrames() const;
boolean readStart(const String& pname = String::EMPTY, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = true);
boolean readTerminate() const;
boolean readPartialData(long start_pos, long num_elem);
boolean writeStart(const String& pname = String::EMPTY) const;
boolean writeTerminate(const String& pname = String::EMPTY) const;
boolean writePartialData(long start_pos, long num_elem);
long getStartFeature(long channel_tag = DEF_CHANNEL_TAG) const;
long getEndFeature(long channel_tag = DEF_CHANNEL_TAG) const;
boolean appendData();
boolean readConfig(Sof& sof, SofParser& parser);
boolean writeConfig(Sof& sof) const;
long readFeatureData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_pos = DEF_START_POS, long num_elem = DEF_NUM_ELEM);
long readRawData(Vector<AlgorithmData>& data, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP);
long readRawData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP);
long writeRawData(Vector<AlgorithmData>& data, long channel_tag = DEF_CHANNEL_TAG);
long writeRawData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG);
long readSofData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG, long start_samp = DEF_START_SAMP, long num_samp = DEF_NUM_SAMP);
long readSofData(Vector<AlgorithmData>& data, long start_pos = DEF_START_POS, long num_elem = DEF_NUM_ELEM);
long writeSofData(Vector<AlgorithmData>& data, long channel_tag = DEF_CHANNEL_TAG);
long writeSofData(Vector<VectorFloat>& data, long channel_tag = DEF_CHANNEL_TAG);
boolean readSofStart();
boolean writeSofStart();
boolean readStart(Sof& sof, const String& pname = String::EMPTY, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = true);
boolean writeStart(Sof& sof, const String& pname = String::EMPTY) const;
boolean writeTerminate(Sof& sof, const String& pname = String::EMPTY) const;
boolean resetBuffer(long channel_tag);
// isip include files // #include <FeatureFile.h> // main program starts here // int main() { // declare FeatureFile objects for read and write // FeatureFile ftr_in; FeatureFile ftr_out; // define local variable to hold data // Vector<AlgorithmData> data; // define input and output file name // Filename ftr_filename(L"$ISIP_DEVEL/doc/examples/data/features/AD.sof");; Filename ftr_text(L"AD_text.sof");; // prepare parameters for input file // ftr_in.setNumChannels(1); // set number of channel ftr_in.setFileType(FeatureFile::BINARY); // set file type ftr_in.setFileFormat(FeatureFile::SOF); // set file format ftr_in.setID(L"AD"); // set id ftr_in.setName(L"FEATURES"); // set feature name // prepare parameters for output file ftr_out.setNumChannels(1); // set number of channel ftr_out.setFileType(FeatureFile::TEXT); // set file type ftr_out.setFileFormat(FeatureFile::SOF); // set file format ftr_out.setID(L"AD"); // set id ftr_out.setName(L"FEATURES"); // set feature name // open input and output file // ftr_in.open(ftr_filename); ftr_out.open(ftr_text, File::WRITE_ONLY); // define local variable // long num_input=0; data.setLength(1); // get number of frames stored in file // long len = ftr_in.getNumFrames(); // loop for read data from a input file and write data out to a file // for(long i=0; i<(long)len; i++) { // get feature data from the input file // num_input = ftr_in.getBufferedData(data, i, (long)1); // write feature data to the output file // ftr_out.writeFeatureData(data); } // close input and output file // ftr_in.close(); ftr_out.close(); // exit gracefully // Integral::exit(); }