sfprocess.c

来自「SIP 1.5.0源代码」· C语言 代码 · 共 52 行

C
52
字号
#include    <stdio.h>#include    <sndfile.h>#define BUFFER_LEN  1024voidprocess_data (double *data, int count, int channels){    /* Process the data here.     ** If the soundfile contains more then 1 channel    ** you need to take care of the interleaving.    */    } /* process_data */        int     main (void){   static double data [BUFFER_LEN] ;    char         *infilename, *outfilename ;    SNDFILE      *infile, *outfile ;    SF_INFO      sfinfo ;    int          readcount ;    infilename = "input.wav" ;    outfilename = "output.wav" ;            if (! (infile = sf_open_read (infilename, &sfinfo)))    {   printf ("Not able to open input file %s.\n", infilename) ;        sf_perror (NULL) ;        return  1 ;        } ;        if (! (outfile = sf_open_write (outfilename, &sfinfo)))    {   printf ("Not able to open output file %s.\n", outfilename) ;        sf_perror (NULL) ;        return  1 ;        } ;            while ((readcount = sf_read_double (infile, data, BUFFER_LEN, 0)))    {   process_data (data, readcount, sfinfo.channels) ;        sf_write_double (outfile, data, readcount, 0) ;        } ;    sf_close (infile) ;    sf_close (outfile) ;        return 0 ;} /* main */

⌨️ 快捷键说明

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