2015-12-01 98 views
0

我是使用OpenSL ES的Android Native音頻新手,我需要您的幫助。使用OpenSL ES替換默認MIC(Android中的Native-audio)

現在我想寫一個應用程序來做實時錄音和回放。在錄製部分,我們必須在創建錄音機時首先配置音頻源。喜歡這個。

SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE,SL_IODEVICE_AUDIOINPUT,SL_DEFAULTDEVICEID_AUDIOINPUT, NULL}; 
SLDataSource audioSrc = {&loc_dev, NULL}; 

SL_DEFAULTDEVICEID_AUDIOINPUT是默認麥克風的地址。我想在android手機上使用其他MIC(我使用Nexus 6有三種不同的MIC),但是我找不到其他MIC的地址。

感謝任何迴應!

+0

您是否設法找到解決方案? –

回答

0

OpenSLES.h我們有一些類型的IODevices這是..

/** IODevice-types */ 
#define SL_IODEVICE_AUDIOINPUT ((SLuint32) 0x00000001) 
#define SL_IODEVICE_LEDARRAY ((SLuint32) 0x00000002) 
#define SL_IODEVICE_VIBRA  ((SLuint32) 0x00000003) 
#define SL_IODEVICE_RESERVED4 ((SLuint32) 0x00000004) 
#define SL_IODEVICE_RESERVED5 ((SLuint32) 0x00000005) 

您可以嘗試每一種檢查,如果這些滿足您的需求。您可以在OpenSLES_AndroidConfiguration.h看看。在初始化您的AudioRecorder時,您在此處有一些Android配置來設置輸入類型。

/*---------------------------------------------------------------------------*/ 
/* Android AudioRecorder configuration          */ 
/*---------------------------------------------------------------------------*/ 

/** Audio recording preset */ 
/** Audio recording preset key */ 
#define SL_ANDROID_KEY_RECORDING_PRESET ((const SLchar*) "androidRecordingPreset") 
/** Audio recording preset values */ 
/** preset "none" cannot be set, it is used to indicate the current settings 
*  do not match any of the presets. */ 
#define SL_ANDROID_RECORDING_PRESET_NONE    ((SLuint32) 0x00000000) 
/** generic recording configuration on the platform */ 
#define SL_ANDROID_RECORDING_PRESET_GENERIC    ((SLuint32) 0x00000001) 
/** uses the microphone audio source with the same orientation as the camera 
*  if available, the main device microphone otherwise */ 
#define SL_ANDROID_RECORDING_PRESET_CAMCORDER   ((SLuint32) 0x00000002) 
/** uses the main microphone tuned for voice recognition */ 
#define SL_ANDROID_RECORDING_PRESET_VOICE_RECOGNITION ((SLuint32) 0x00000003) 
/** uses the main microphone tuned for audio communications */ 
#define SL_ANDROID_RECORDING_PRESET_VOICE_COMMUNICATION ((SLuint32) 0x00000004) 

這些主要是爲了試驗和錯誤。我沒有任何確切的解決方案。