// file: $isip/class/algo/Output/out_06.cc // version: $Id: out_06.cc 10633 2006-10-02 18:48:26Z ss754 $ // // isip include files // #include "Output.h" // method: computeFeatures // // arguments: // Vector& output: (output) output data // const Vector< CircularBuffer >& input: (input) input data // // return: a bool8 value indicating status // // this method write out features data // bool8 Output::computeFeatures(Vector& output_a, const Vector< CircularBuffer >& input_a) { if (implementation_d != FEATURES) { return Error::handle(name(), L"computeFeatures", ERR_UNKIMP, __FILE__, __LINE__); } // determine the number of input channels and force the output to be // that number // int32 len = input_a.length(); output_a.setLength(len); // loop over the channels and call the compute method // for (int32 c = 0; c < len; c++) { // display the channel number // displayChannel(c); // copy the data // output_a(c).assign(input_a(c)(0)); // possibly display the data // display(output_a(c), input_a(c)(0), name()); } // write the data // feature_output_d.writeFeatureData(output_a); // possibly display the data // display(output_a, input_a, name()); // exit gracefully // return true; } // method: computeSampledData // // arguments: // Vector& output: (output) output data // const Vector< CircularBuffer >& input: (input) input data // // return: a bool8 value indicating status // // this method write out the sampled data // bool8 Output::computeSampledData(Vector& output_a, const Vector< CircularBuffer >& input_a) { if (implementation_d != SAMPLED_DATA) { return Error::handle(name(), L"computeSampledData", ERR_UNKIMP, __FILE__, __LINE__); } // determine the number of input channels and force the output to be // that number // int32 len = input_a.length(); output_a.setLength(len); // loop over the channels and call the compute method // for (int32 c = 0; c < len; c++) { // display the channel number // displayChannel(c); // copy the data // output_a(c).assign(input_a(c)(0)); // possibly display the data // display(output_a(c), input_a(c)(0), name()); } AlgorithmData::DATA_TYPE dtype = input_a(0)(0).getDataType() ; // calculate the whole frames needed to process // float64 num_frames = signal_duration_d / frame_dur_d; int32 frame = (int32)Integral::round(num_frames); if (dtype == AlgorithmData::VECTOR_FLOAT) { // write the data // Vector temp; temp.setLength(output_a.length()); for (int32 i = 0; i < output_a.length(); i++) { temp(i).assign(output_a(i).getVectorFloat()); if (leftover_samps_d == 0) { } else if (leftover_samps_d < output_a(i).getVectorFloat().length() && dmode_d == SAMPLE_BASED && frame_index_d == frame - 1) { temp(i).setLength(leftover_samps_d); } } audio_output_d.writeAudioData(temp); } else { return Error::handle(name(), L"computeSampledData", ERR_UNKIMP, __FILE__, __LINE__); } // possibly display the data // display(output_a, input_a, name()); // exit gracefully // return true; }