【发布时间】:2018-01-16 12:24:46
【问题描述】:
我第一次用 c 语言编写音频文件。我发现这个代码应该读取一个音频文件,然后编写一个包含几个信息的 csv 文件以分析音频波,以防万一是一个简单的声音:我对波的幅度感兴趣,在音色的声音及其高音和扩展。
main () {
// Create a 20 ms audio buffer (assuming Fs = 44.1 kHz)
int16_t buf[N] = {0}; // buffer
int n; // buffer index
// Open WAV file with FFmpeg and read raw samples via the pipe.
FILE *pipein;
pipein = popen("ffmpeg -i whistle.wav -f s16le -ac 1 -", "r");
fread(buf, 2, N, pipein);
pclose(pipein);
// Print the sample values in the buffer to a CSV file
FILE *csvfile;
csvfile = fopen("samples.csv", "w");
for (n=0 ; n<N ; ++n) fprintf(csvfile, "%d\n", buf[n]);
fclose(csvfile);
}
谁能详细解释我如何阅读音频文件以便从中提取我需要的信息?参考这段代码,有人可以解释一下第 8 行管道的含义
pipein = popen("ffmpeg -i whistle.wav -f s16le -ac 1 -", "r");
附言我已经知道如何读取音频文件的标题,其中包含很多有用的信息,但我也想逐个样本地分析整个音频文件。
【问题讨论】: