我在录音的同时,将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[]数组,求各位高手指教啊
原来用于读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[]数组,求各位高手指教啊
解决方案 »
- 为什么下载的android源码目录下面只有一个.repo的隐藏文件?
- webview错误提示,在线等
- 自动登录,求思路
- 一般我们用的都是Activity,但是关于它的一些继承类是什么意思,有人了解吗?
- android sendTextMessage发送多条短信,广播接收到相同内容
- No activity specified! Getting the launcher activity.想在手机上运行时出现这个提示?
- android 获取不到手机扫描到的wifi信息,求大神。
- Android:怎么解析网上已知格式的json数据文件,并显示到界面上
- 从SVN 检出 输入 URL 后弹出 “无法验证” 验证位置时发生错误:org.apache.svbversion.javahl.ClientException
- opencv算法求助
- 安卓不同分辨率屏幕布局排版不同问题,求帮助。
- 真机测试出现的一个异常,肿么办呢?
http://blog.csdn.net/cboy017/article/details/8455629