This example will generate a sine wave audio, pass it through a simple filter chain, and then compute the MD5 checksum of the output data.The filter chain it uses is: (input) -> abuffer -> volume -> aformat -> abuffersink -> (output)
abuffer: This provides the endpoint where you can feed the decoded samples. volume: In this example we hardcode it to 0.90. aformat: This converts the samples to the samplefreq, channel layout, and sample format required by the audio device. abuffersink: This provides the endpoint where you can read the samples after they have passed through the filter chain.
#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define INPUT_SAMPLERATE     48000
#define INPUT_FORMAT         AV_SAMPLE_FMT_FLTP
#define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
#define VOLUME_VAL 0.90
{
    int err;
    
    if (!filter_graph) {
        fprintf(stderr, "Unable to create filter graph.\n");
    }
    
    if (!abuffer) {
        fprintf(stderr, "Could not find the abuffer filter.\n");
    }
    if (!abuffer_ctx) {
        fprintf(stderr, "Could not allocate the abuffer instance.\n");
    }
    
    
    if (err < 0) {
        fprintf(stderr, "Could not initialize the abuffer filter.\n");
        return err;
    }
    
    if (!volume) {
        fprintf(stderr, "Could not find the volume filter.\n");
    }
    if (!volume_ctx) {
        fprintf(stderr, "Could not allocate the volume instance.\n");
    }
    
    if (err < 0) {
        fprintf(stderr, "Could not initialize the volume filter.\n");
        return err;
    }
    
    if (!aformat) {
        fprintf(stderr, "Could not find the aformat filter.\n");
    }
    if (!aformat_ctx) {
        fprintf(stderr, "Could not allocate the aformat instance.\n");
    }
    
    snprintf(options_str, 
sizeof(options_str),
 
             "sample_fmts=%s:sample_rates=%d:channel_layouts=0x%"PRIx64,
    if (err < 0) {
        return err;
    }
    
    if (!abuffersink) {
        fprintf(stderr, "Could not find the abuffersink filter.\n");
    }
    if (!abuffersink_ctx) {
        fprintf(stderr, "Could not allocate the abuffersink instance.\n");
    }
    
    if (err < 0) {
        fprintf(stderr, "Could not initialize the abuffersink instance.\n");
        return err;
    }
    
    if (err >= 0)
    if (err >= 0)
    if (err < 0) {
        fprintf(stderr, "Error connecting filters\n");
        return err;
    }
    
    if (err < 0) {
        return err;
    }
    *src   = abuffer_ctx;
    *sink  = abuffersink_ctx;
    return 0;
}
{
    int planes     = planar ? channels : 1;
    int plane_size = bps * frame->
nb_samples * (planar ? 1 : channels);
 
    int i, j;
    for (i = 0; i < planes; i++) {
        fprintf(stdout, "plane %d: 0x", i);
            fprintf(stdout, "%02X", checksum[j]);
        fprintf(stdout, "\n");
    }
    fprintf(stdout, "\n");
    return 0;
}
{
    int err, i, j;
#define FRAME_SIZE 1024
    
    if (err < 0)
        return err;
    
    for (i = 0; i < 5; i++) {
            data[j] = sin(2 * 
M_PI * (frame_num + j) * (i + 1) / FRAME_SIZE);
    }
    return 0;
}
int main(
int argc, 
char *argv[])
 
{
    int err, nb_frames, i;
    if (argc < 2) {
        fprintf(stderr, "Usage: %s <duration>\n", argv[0]);
        return 1;
    }
    duration  = atof(argv[1]);
    if (nb_frames <= 0) {
        fprintf(stderr, "Invalid duration: %s\n", argv[1]);
        return 1;
    }
    
    if (!frame) {
        fprintf(stderr, "Error allocating the frame\n");
        return 1;
    }
    if (!md5) {
        fprintf(stderr, "Error allocating the MD5 context\n");
        return 1;
    }
    
    if (err < 0) {
        fprintf(stderr, "Unable to init filter graph:");
    }
    
    for (i = 0; i < nb_frames; i++) {
        
        if (err < 0) {
            fprintf(stderr, "Error generating input frame:");
        }
        
        if (err < 0) {
            fprintf(stderr, "Error submitting the frame to the filtergraph:");
        }
        
            
            if (err < 0) {
                fprintf(stderr, "Error processing the filtered frame:");
            }
        }
            
            continue;
            
            break;
        } else if (err < 0) {
            
            fprintf(stderr, "Error filtering the data:");
        }
    }
    return 0;
    fprintf(stderr, "%s\n", errstr);
    return 1;
}