⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 adf_09.cc

📁 这是一个从音频信号里提取特征参量的程序
💻 CC
字号:
// file: $isip/class/mmedia/AudioFile/adf_09.cc// version: $Id: adf_09.cc,v 1.4 2002/03/08 17:37:52 gao Exp $//// isip include files//#include "AudioFile.h"#include <VectorByte.h>#include <VectorShort.h>#include <VectorLong.h>// method: writeAudioData//// arguments://  Vector<VectorFloat>& data: (input) the audio data to write//  long ctag: (input) channel tag//  // return: the number of elements written//// this method writes the audio data to raw audio file//long AudioFile::writeAudioData(Vector<VectorFloat>& data_a,			       long ctag_a) {    // make sure the file is open  //  if (!isOpen()) {    Error::handle(name(), L"writeAudioData", ERR_NOTOPN, __FILE__, __LINE__);    return -1;  }    // write to raw file  //  if (file_format_d == RAW) {    // call the raw method    //    return writeRawData(data_a, ctag_a);  }  // Sof file  //  else if (file_format_d == SOF) {    // call the sof method    //    return writeSofData(data_a, ctag_a);  }  // sphere not yet supported  //  else if (file_format_d == SPHERE) {    return Error::handle(name(), L"writeAudioData", Error::NOT_IMPLEM,			 __FILE__, __LINE__);  }    // file types not supported  //  else {    return Error::handle(name(), L"writeAudioData", Error::ENUM, __FILE__,			 __LINE__);  }    // exit gracefully  //  return true;}// method: revertData//// arguments://  VectorLong& whole_data: (output) the Vector to hold all channel data//  Vector<VectorFloat>& data: (input) the input multi-channel data//  long ctag: (input) the tag of channels to be processed //// return: a boolean value indicating status//// this method combines the data of multiple channels and put into a// VectorLong//boolean AudioFile::revertData(VectorLong& whole_data_a,			      Vector<VectorFloat>& data_a,			      long ctag_a) const {    // local variables  //  long num_channels = 0;  float sample_value;    // get the number of channels to write  //  if (ctag_a >= 0) {    num_channels = 1;  }  else if (ctag_a == CHANNEL_TAG_ALL) {    num_channels = num_channels_d;  }  else {    num_channels = 1;  }    // compute the total number of samples  //  long num_samples = data_a(0).length();  long num_write = num_samples * num_channels;  // set the output data  //  whole_data_a.setLength(num_write);    if (ctag_a >= 0) {        for (long i = 0; i < num_samples; i++) {      sample_value = (float)(data_a(ctag_a)(i)) * max_sample_val_d;      whole_data_a(i) = (long)sample_value;    }  }  else if (ctag_a == CHANNEL_TAG_ALL) {    //    return Error::handle(name(), L"revertData", ERR, __FILE__, __LINE__);        for (long i = 0; i < num_samples; i++) {            // loop each channel sample      //      for (long ctag = 0; ctag < num_channels; ctag++) {	sample_value = ((float)data_a(ctag)(i)) * max_sample_val_d;		whole_data_a((long)(i*num_channels + ctag)) = (long)sample_value;	      }    }  }    // exit gracefully  //  return true;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -