我想从麦克风录音,添加一些效果,而这个保存到一个文件保存录制的音频文件 - OpenSL ES - Android电子
我已经开始与包括例如在纯音频Android NDK。 我设法添加一些混响并播放它,但我还没有找到任何示例或帮助如何完成此操作。
任何和所有的帮助是受欢迎的。
我想从麦克风录音,添加一些效果,而这个保存到一个文件保存录制的音频文件 - OpenSL ES - Android电子
我已经开始与包括例如在纯音频Android NDK。 我设法添加一些混响并播放它,但我还没有找到任何示例或帮助如何完成此操作。
任何和所有的帮助是受欢迎的。
OpenSL不是文件格式和访问的框架。如果你想要一个原始的PCM文件,只需打开它进行写入,并将OpenSL回调中的所有缓冲区放入该文件。但是如果你想编码音频,你需要你自己的编解码器和格式处理器。您可以使用ffmpeg库或内置stagefright。
更新写播放缓冲区以当地原料PCM文件
我们先从本机的音频jni.c
#include <stdio.h>
FILE* rawFile = NULL;
int bClosing = 0;
...
void bqPlayerCallback(SLAndroidSimpleBufferQueueItf bq, void *context)
{
assert(bq == bqPlayerBufferQueue);
assert(NULL == context);
// for streaming playback, replace this test by logic to find and fill the next buffer
if (--nextCount > 0 && NULL != nextBuffer && 0 != nextSize) {
SLresult result;
// enqueue another buffer
result = (*bqPlayerBufferQueue)->Enqueue(bqPlayerBufferQueue, nextBuffer, nextSize);
// the most likely other result is SL_RESULT_BUFFER_INSUFFICIENT,
// which for this code example would indicate a programming error
assert(SL_RESULT_SUCCESS == result);
(void)result;
// AlexC: here we write:
if (rawFile) {
fwrite(nextBuffer, nextSize, 1, rawFile);
}
}
if (bClosing) { // it is important to do this in a callback, to be on the correct thread
fclose(rawFile);
rawFile = NULL;
}
// AlexC: end of changes
}
.. 。
void Java_com_example_nativeaudio_NativeAudio_startRecording(JNIEnv* env, jclass clazz)
{
bClosing = 0;
rawFile = fopen("/sdcard/rawFile.pcm", "wb");
...
void Java_com_example_nativeaudio_NativeAudio_shutdown(JNIEnv* env, jclass clazz)
{
bClosing = 1;
...
是否有可能看到您提出的解决方案的例子? –
3+中的哪一个?请将 –
保存到文件中。 –
从C到Java将原始载体,并与mediaRecorder MP3编码它,我不知道你是否可以设置从音频源一个原始的矢量,但也许...
_“我'设法添加一些混响和播放它'_所以你已经得到它的工作..?你能否澄清实际问题是什么? – Michael
问题是将音频保存到一个文件中,我不知道如何去做这个 –