我想從麥克風錄音,添加一些效果,而這個保存到一個文件保存錄制的音頻文件 - 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
問題是將音頻保存到一個文件中,我不知道如何去做這個 –