我一直在研究一个基于带有cpp的wav文件的项目。但无论我放入什么,我总是得到的输出只是原始输入的1/2大小。我使用的算法如下: http://rogerchansdigitalworld.blogspot.com/2010/05/how-to-read-wav-format-file-in-c.html http://ltheory.com/blog/writeWav.txt
任何人都可以给出提示吗?
我的主要功能是:
int main()
{
string filename = "U:\\workspace\\ECE420\\psola.github\\aa.wav";
string directory;
const size_t last_slash_idx = filename.rfind('\\');
if (std::string::npos != last_slash_idx)
{
directory = filename.substr(0, last_slash_idx);
}
string filename1 = "U:\\workspace\\ECE420\\psola.github\\voiceprocessed.wav";
string directory1;
const size_t last_slash_idx1 = filename1.rfind('\\');
if (std::string::npos != last_slash_idx1)
{
directory1 = filename1.substr(0, last_slash_idx1);
}
WavData song;
int num = filename.size();
char file_char[100];
for (int a=0;a<=num;a++){
file_char[a]=filename[a];
}
WavData song1;//
int num1 = filename1.size();
char file_char1[100];
for (int a=0;a<=num1;a++){
file_char1[a]=filename1[a];
}
loadWaveFile(file_char,&song);
cout<<"there are "<<song.size/2<<" samples in this WAV file."<<endl;
writeWAVData(file_char1, song.data, song.size, 44100, 1);
cout<<"2,there are "<<song1.size/2<<" samples in this WAV file."<<endl;
cout<<"success"<<endl;
return 0;
}