📄 ftrf_05.cc
字号:
// file: $isip/class/mmedia/FeatureFile/ftrf_05.cc// version: $Id: ftrf_05.cc,v 1.6 2002/12/31 16:16:11 parihar Exp $//// isip include files//#include "FeatureFile.h"// method: writeFeatureData//// arguments:// Vector<AlgorithmData>& data: (input) the feature data// long channel_tag: (input) the channel tag//// return: number of feature data read//// this is currently the only way to output data. it writes the// entire input vector at the current location.//long FeatureFile::writeFeatureData(Vector<AlgorithmData>& data_a, long channel_tag_a) { // branch on file format // if (file_format_d == RAW) return writeRawData(data_a, channel_tag_a); else if (file_format_d == SOF) return writeSofData(data_a, channel_tag_a); else return 0;}// method: writeFeatureData//// arguments:// Vector<VectorFloat>& data: (input) the feature data// long channel_tag: (input) the channel tag//// return: number of feature data read//// this is currently the only way to output data. it writes the// entire input vector at the current location.//long FeatureFile::writeFeatureData(Vector<VectorFloat>& data_a, long channel_tag_a) { // branch on file format // if (file_format_d == RAW) return writeRawData(data_a, channel_tag_a); else if (file_format_d == SOF) return writeSofData(data_a, channel_tag_a); else return 0;}// method: readFeatureData //// arguments:// Vector<AlgorithmData>& data: (input) the feature data to read// long start_pos: (input) the start position of the feature data// long num_elem: (input) the number of the feature data read// // return: the number of elements read//// this method reads the feature data from a file.//long FeatureFile::readFeatureData(Vector<AlgorithmData>& data_a, long start_pos_a, long num_elem_a) { // branch on file format // if (file_format_d == RAW) return readRawData(data_a, start_pos_a, num_elem_a); else if (file_format_d == SOF) return readSofData(data_a, start_pos_a, num_elem_a); else return 0;}// method: readPartialData//// arguments:// long start_pos: (input) first entry to read// long num_elem: (input) number of elements to read//// return: the number of elements read//// this method has the object read itself from an Sof file. it assumes// that the Sof file is already positioned correctly.//boolean FeatureFile::readPartialData(long start_pos_a, long num_elem_a) { // create a temporary buffer // Vector<VectorFloat> temp; temp.readPartialData(in_sof_d, start_pos_a, num_elem_a, String::EMPTY, 0, false, false); // loop over all elements // long len = temp.length(); v_d.setLength(len); for (long i = 0; i < len; i++) { // transfer the data // v_d(i).makeVectorFloat() = temp(i); } // exit gracefully // return true; }// method: writePartialData//// arguments:// long start_pos: (input) the index of the Vector to start to write// long num_elem: (input) the number of elements to write//// return: a boolean value indicating status//// this method writes a portion of a feature stream to a file.//boolean FeatureFile::writePartialData(long start_pos_a, long num_elem_a) { // create a temporary buffer // Vector<VectorFloat> temp; // loop over all elements // long len = v_d.length(); temp.setLength(len); for (long i = 0; i < len; i++) { // transfer the data // temp(i).setLength(v_d(i).getVectorFloat().length()); temp(i) = v_d(i).getVectorFloat(); } // write the data // if (!temp.writePartialData(in_sof_d, start_pos_a, num_elem_a)) { return Error::handle(name(), L"writePartialData", Error::IO, __FILE__, __LINE__); } // exit gracefully // return true;}// method: getBufferedData //// arguments:// Vector<AlgorithmData>& data: (input) the feature data to read// long start_pos: (input) the start position of the feature data// long num_elem: (input) the number of the feature data read// // return: the number of elements read//// this method reads feature data from a file.//long FeatureFile::getBufferedData(Vector<AlgorithmData>& data_a, long start_pos_a, long num_elem_a) { // branch on file format // if (file_format_d == RAW) return readRawData(data_a, start_pos_a, num_elem_a); else if (file_format_d == SOF) return readSofData(data_a, start_pos_a, num_elem_a); else return 0;}// method: setBufferSize//// arguments:// long nblocks: (input) number of blocks per buffer//// return: a boolean value indicating status//// this method sets capacity of the buffer.//boolean FeatureFile::setBufferSize(long nblocks_a) { // save the value to class data // long block_num_samp = block_size_d; for (long i = 0; i < num_channels_d; i++) { buffers_d(i).setCapacity(nblocks_a * block_num_samp); } // exit gracefully // return true;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -