使用OpenSL ES(Android中的本机音频)替换默认麦克风

使用OpenSL ES(Android中的本机音频)替换默认麦克风,android,audio,java-native-interface,opensl,Android,Audio,Java Native Interface,Opensl,我是使用OpenSL ES的Android原生音频新手,我需要您的帮助 现在我想写一个应用程序来进行实时录制和播放。在录音部分,我们在创建录音机时首先要配置音频源。像这样 SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE,SL_IODEVICE_AUDIOINPUT,SL_DEFAULTDEVICEID_AUDIOINPUT, NULL}; SLDataSource audioSrc = {&loc_dev, NULL};

我是使用OpenSL ES的Android原生音频新手,我需要您的帮助

现在我想写一个应用程序来进行实时录制和播放。在录音部分,我们在创建录音机时首先要配置音频源。像这样

SLDataLocator_IODevice loc_dev = {SL_DATALOCATOR_IODEVICE,SL_IODEVICE_AUDIOINPUT,SL_DEFAULTDEVICEID_AUDIOINPUT, NULL};
SLDataSource audioSrc = {&loc_dev, NULL};
SL_DEFAULTDEVICEID_AUDIOINPUT是默认话筒的地址。我想在android手机上使用其他话筒(我使用的是Nexus 6,它有三个不同的话筒),但我找不到其他话筒的地址

感谢您的回复

从中我们得到了一些类型的碘设备,它们是

/** 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)
您可以尝试每一种方法,以检查它们是否满足您的需要

你也可以看看。在初始化您的录音机时,您在这里有一些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)

这些主要用于试验和错误。我没有确切的答案

你找到解决办法了吗?