// file: $isip_ifc/class/sp/AudioFrontEnd/afnd_07.cc // version: $Id: afnd_07.cc 10598 2006-08-08 21:45:21Z ss754 $ // // isip include files // #include "AudioFrontEnd.h" #include // method: getVector // // arguments: // Vector& coeffs: (output) coefficients // int32 frame_index: (input) frame index // // return: a bool8 value indicating status // // this method retrieves data from the internal buffers. // bool8 AudioFrontEnd::getVector(Vector& coeffs_a, int32 frame_index_a) { coeffs_a.setLength(1); bool8 status = getVector(coeffs_a(0), 0, frame_index_a); int32 nchan = buf_d.getBuffer().length(); if (nchan > 1) { coeffs_a.setLength(nchan); for (int32 i = 1; i < nchan; i++) { status &= getVector(coeffs_a(i), i, frame_index_a); } } return status; } //MY // method: getVector // // arguments: // Vector& coeffs: (output) coefficients // int32 frame_index: (input) frame index // // return: a bool8 value indicating status // // this method retrieves data from the internal buffers. // bool8 AudioFrontEnd::getVector(Vector& coeffs_a, int32 frame_index_a) { coeffs_a.setLength(1); bool8 status = getVector(coeffs_a(0), 0, frame_index_a); int32 nchan = buf_d.getBuffer().length(); if (nchan > 1) { coeffs_a.setLength(nchan); for (int32 i = 1; i < nchan; i++) { status &= getVector(coeffs_a(i), i, frame_index_a); } } return status; } // method: isNameInput // // arguments: // const String& name: (input) needed coefficient name // // return: a bool8 value indicating status // // this method checks whether the specified coefficient name is // available among the inputs. // bool8 AudioFrontEnd::isNameInput(const String& name_a) const { // if input file do not exist, directly return true // if (!input_flag_d && name_a.eq(SAMPLED_DATA_NAME)) { return true; } // if audio data is available allow for that name // if (audio_input_d.isOpen() && name_a.eq(SAMPLED_DATA_NAME)) { return true; } // check the input coefficient hash // if (feature_input_d.isOpen()) { String str(Recipe::INPUT_PREFIX); str.concat(feature_input_d.getName()); if (str.eq(name_a)) { // name found // return true; } } // name not found // return false; } // method: getInputNames // // arguments: // Vector& name: (output) list of inputs // // return: a bool8 value indicating status // // this method returns a list of all inputs // bool8 AudioFrontEnd::getInputNames(Vector& name_a) { // clear the output // name_a.clear(); // if input file do not exist, directly copy a dummy starting point // if (!input_flag_d) { name_a.concat(SAMPLED_DATA_NAME); } // if audio data is available allow for that name // if (audio_input_d.isOpen()) { name_a.concat(SAMPLED_DATA_NAME); } // if feature data is available allow for that name // else if (feature_input_d.isOpen()) { name_a.concat(feature_input_d.getName()); } // exit gracefully // return true; } // method: configureComponents // // arguments: none // // return: a bool8 value indicating status // // this method passes information on this data into each process // bool8 AudioFrontEnd::configureComponents() { // get the signal length between users specify and real file // signal // int32 num_frames = getNumFrames(); signal_duration_d = frame_duration_d * (float32)num_frames; // if the input file exist, using input file's sample frequency // else get from Generator class // if (!input_flag_d) { // loop over all channels // for (int32 ctag = 0; ctag < num_channels_d; ctag++) { // loop over all lags // for (int32 i = 0; i < coef_components_d.length(); i++) { // loop over all processes in this list // for (bool8 more = coef_components_d(i).gotoFirst(); more; more = coef_components_d(i).gotoNext()) { Component* algo = coef_components_d(i).getCurr(); // get the sample frequency from Generator class if it is // exist // algo->getGenSampleFrequency(sample_frequency_d); } } } } // loop over all channels // for (int32 ctag = 0; ctag < num_channels_d; ctag++) { // loop over all lags // for (int32 i = 0; i < coef_components_d.length(); i++) { // loop over all processes in this list // for (bool8 more = coef_components_d(i).gotoFirst(); more; more = coef_components_d(i).gotoNext()) { Component* algo = coef_components_d(i).getCurr(); // set the sample frequency, freq, etc // algo->setFrameDuration(frame_duration_d); algo->setSampleFrequency(sample_frequency_d); algo->setSignalDuration(signal_duration_d); algo->setInputFilename(input_filename_d(0)); if (output_basename_d.length() > 0) algo->setOutputBasename(output_basename_d); if (output_extension_d.length() > 0) algo->setOutputExtension(output_extension_d); if (output_suffix_d.length() > 0) algo->setOutputSuffix(output_suffix_d); if (output_directory_d.length() > 0) algo->setOutputDirectory(output_directory_d); if ((int32)output_preserve_d > 0) algo->setOutputPreserve(output_preserve_d); if (output_type_flag_d) algo->setOutputType(output_type_d); String temp; algo->getOutputFilename(temp); if (temp.length() > 0) { output_filename_d.concat(temp); } temp.assign(String::NULL_STRING); algo->getInputFilename(temp); if (temp.length() > 0) { input_filename_d.concat(temp); } } } } // exit gracefully // return true; } // method: preConfigureComponents // // arguments: // SingleLinkedList& comps: (output) components to be preconfigured // // return: a bool8 value indicating status // // this method sets component information needed to calculate delays // between components // bool8 AudioFrontEnd::preconfigureComponents(SingleLinkedList& comps_a) { // get the signal length between users specify and real file // signal // int32 num_frames = getNumFrames(); signal_duration_d = frame_duration_d * (float32)num_frames; // if the input file exist, using input file's sample frequency // else get from Generator class // if (!input_flag_d) { // loop over all channels // for (int32 ctag = 0; ctag < num_channels_d; ctag++) { // loop over all processes in this list // for (bool8 more = comps_a.gotoFirst(); more; more = comps_a.gotoNext()) { Component* algo = comps_a.getCurr(); // get the sample frequency from Generator class if it is // exist // algo->getGenSampleFrequency(sample_frequency_d); } } } // loop over all channels // for (int32 ctag = 0; ctag < num_channels_d; ctag++) { // loop over all processes in this list // for (bool8 more = comps_a.gotoFirst(); more; more = comps_a.gotoNext()) { Component* algo = comps_a.getCurr(); // set the sample frequency, freq, etc // algo->setFrameDuration(frame_duration_d); algo->setSampleFrequency(sample_frequency_d); algo->setSignalDuration(signal_duration_d); algo->setInputFilename(input_filename_d(0)); if (output_basename_d.length() > 0) algo->setOutputBasename(output_basename_d); if (output_extension_d.length() > 0) algo->setOutputExtension(output_extension_d); if (output_suffix_d.length() > 0) algo->setOutputSuffix(output_suffix_d); if (output_directory_d.length() > 0) algo->setOutputDirectory(output_directory_d); if ((int32)output_preserve_d > 0) algo->setOutputPreserve(output_preserve_d); if (output_type_flag_d) algo->setOutputType(output_type_d); String temp; algo->getOutputFilename(temp); if (temp.length() > 0) { output_filename_d.concat(temp); } temp.assign(String::NULL_STRING); algo->getInputFilename(temp); if (temp.length() > 0) { input_filename_d.concat(temp); } } } // exit gracefully // return true; }