我第一次用 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"); …Run Code Online (Sandbox Code Playgroud)