我在录音的同时,将pcm码流实时的传给MP3转码器,但是转码后的MP3声音变快了,且有杂音我只改动了一个函数,原来的MP3转码器是将一个wav文件转为MP3文件,现在改成了从MIC实时提供数据上来
原来用于读wav文件的函数是:/*
 * wave_get:
 * ---------
 * Reads samples from the file in longs. A long can
 * hold one stereo or two mono samples.
 * Returns the address of the start of the next frame or NULL if there are no
 * more. The last frame will be padded with zero's.
 */
unsigned long int *wave_get(void) {
 int n,p;
 static char buff[samp_per_frame*4];//samp_per_frame的大小为1152,在types.h中定义的宏
 n = config.mpeg.samples_per_frame >> (2 - config.wave.channels);//  >>为右移运算
 //在input文件中读取n个long型的数据,返回值:读取的元素的个数
 p = fread(buff,sizeof(unsigned long),(short)n,config.wave.file);  if(!p)
 return 0;
 else
 {
 for(; p<n; p++)
 buff[p]=0;
 unsigned long * ll=(unsigned long*)buff;
 return ll;
 }
}
现在我改成了:
unsigned long int *wave_get(char * b) {
unsigned long * ll = (unsigned long *) b;
if (!b) {
LOGD("-------------null-------------");
return 0;
} else {
return ll;
}
}
从jni传来的数据是byte[]数组,求各位高手指教啊