我需要删除 wav 文件中的暂停(暂停 - 幅度<16且长度>N个样本的区域)。不太了解如何使用示例,以及如何从文件中逐个读取示例。下面是我的代码:
#include <stdio.h>
#include <stdlib.h>
#define BUFSIZE 4000
typedef struct header {
char chunk_id[4];
int chunk_size;
char format[4];
char subchunk1_id[4];
int subchunk1_size;
short int audio_format;
short int num_channels;
int sample_rate;
int byte_rate;
short int block_align;
short int bits_per_sample;
short int extra_param_size;
char subchunk2_id[4];
int subchunk2_size;
} header;
typedef struct header* header_p;
void change_file(char * input, int N){
FILE * infile = fopen(input, "rb");
FILE * outfile = fopen("outfile.wav", "wb");
short int inbuff16[BUFSIZE];
header_p meta = (header_p)malloc(sizeof(header));
if (infile) {
fread(meta, 1, sizeof(header), infile);
fwrite(meta, 1, sizeof(header), outfile);
while (!feof(infile)) {
fread(inbuff16, 1, BUFSIZE, infile);
//delete pause here
fwrite(inbuff16, 1, BUFSIZE, outfile);
}
}
if (infile) { fclose(infile); }
if (outfile) { fclose(outfile); }
if (meta) { free(meta); }
}
int main (int argc, char const *argv[]){
char infile[] = "track.wav";
change_file(infile, 20);
return 0;
}
最佳答案
关于c - 从 C 中的 wav 文件中删除暂停,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30654808/