Anyone use libsamplerate here?

Since it’s a bit difficult for me to post to libsamplerate’s maillist, I’m sorry that I post it here.
I just wrote a program using libsamplerate’s simple api, but there’s really a lot of noise in the output file.
Would anyone who knows about the api help please?
Thanks in advance.
In the program, I’ll change a file with sample rate 16000Hz to sample rate 8000Hz.
So the src_ratio parameter is set to 0.5.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <samplerate.h>

#define BUFFLEN 320
#define ARRAY_LEN(x) ((int)(sizeof(x)/sizeof(x[0])))

int main()
{
int error;
short src_buf[320];
short dst_buf[160];
float fsrc_buf[320];
float fdst_buf[160];
FILE *test_wave = fopen(“dachangjing.wav”, “rb”);
FILE *wav_8000 = fopen(“800016.wav”, “wb+”);
SRC_DATA src_data;
memset (&src_data, 0, sizeof (src_data));
while(!feof(test_wave))
{
if(fread(src_buf, sizeof(short), BUFFLEN, test_wave) != BUFFLEN)
break;
src_short_to_float_array(src_buf, fsrc_buf, BUFFLEN);
src_data.end_of_input = 0;
src_data.data_in = fsrc_buf;
src_data.input_frames = BUFFLEN;
src_data.src_ratio = 0.5;
src_data.data_out = fdst_buf;
src_data.output_frames = BUFFLEN >> 1;
if ((error = src_simple (&src_data, SRC_LINEAR, 1)))
{
printf (“nnLine %d : %snn”, LINE, src_strerror (error)) ;
exit (1) ;
}
src_float_to_short_array(fdst_buf, dst_buf, BUFFLEN >> 1);
fwrite(dst_buf, sizeof(short), BUFFLEN >> 1, wav_8000);
}
fclose(test_wave);
fclose(wav_8000);
}

How long are short integers on your platform? If they are 8-bits, you will get a lot of noise.

For how audacity uses libsamplerate, see src/Resample.cpp