2025년 3월 27일부터 AOSP를 빌드하고 기여하려면 aosp-main
대신 android-latest-release
를 사용하는 것이 좋습니다. 자세한 내용은 AOSP 변경사항을 참고하세요.
마이크 입력
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
오디오를 캡처할 때 오디오 HAL은 openInputStream
호출을 수신합니다. 이 호출에는 마이크 입력의 처리 방법을 나타내는 AudioSource
인수가 포함되어 있습니다.
VOICE_RECOGNITION
소스에는 에코 취소 효과(사용 가능한 경우)가 있지만 다른 처리가 적용되지 않은 스테레오 마이크 스트림이 필요합니다.
채널이 3개 이상인 기기에서 오디오(스테레오)를 캡처하려면 위치 색인 마스크 대신 채널 색인 마스크(예: CHANNEL_IN_LEFT
)를 사용합니다. 예를 들면 다음과 같습니다.
final AudioFormat audioFormat = new AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setSampleRate(44100)
.setChannelIndexMask(0xf /* 4 channels, 0..3 */)
.build();
final AudioRecord audioRecord = new AudioRecord.Builder()
.setAudioFormat(audioFormat)
.build();
audioRecord.setPreferredDevice(someAudioDeviceInfo);
setChannelMask
와 setChannelIndexMask
가 모두 설정된 경우 AudioRecord
는 setChannelMask
에 의해 설정한 값만(최대 채널 2개) 사용합니다.
동시 캡처
Android 10부터 Android 프레임워크는 입력 동시 캡처를 지원하지만 사용자 개인 정보 보호를 위한 제한사항이 있습니다. 이러한 제한사항의 일환으로 AUDIO_SOURCE_FM_TUNER
와 같은 가상 소스가 무시되며 일반 입력(예: 마이크)과 함께 동시에 캡처될 수 있습니다.
HwAudioSource
는 동시 캡처 제한사항의 일부로 간주되지 않습니다.
AUDIO_DEVICE_IN_BUS
기기 또는 보조 AUDIO_DEVICE_IN_FM_TUNER
기기에서 작동하도록 설계된 앱은 Android 기본 소스 선택 로직을 우회하려면 명시적으로 이러한 기기를 식별하고 AudioRecord.setPreferredDevice()
를 사용해야 합니다.
이 페이지에 나와 있는 콘텐츠와 코드 샘플에는 콘텐츠 라이선스에서 설명하는 라이선스가 적용됩니다. 자바 및 OpenJDK는 Oracle 및 Oracle 계열사의 상표 또는 등록 상표입니다.
최종 업데이트: 2025-07-09(UTC)
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-07-09(UTC)"],[],[],null,["# Microphone input\n\nWhen capturing audio, the Audio HAL receives an `openInputStream` call that\nincludes an `AudioSource` argument to indicate how microphone input should be\nprocessed.\n\nThe `VOICE_RECOGNITION` source expects a stereo microphone stream that has an\necho cancellation effect (if available) but no other processing applied to it.\n\nMulti-channel microphone input\n------------------------------\n\nTo capture audio from a device with more than two channels (stereo), use a\nchannel index mask instead of positional index mask (such as `CHANNEL_IN_LEFT`).\nFor example: \n\n final AudioFormat audioFormat = new AudioFormat.Builder()\n .setEncoding(AudioFormat.ENCODING_PCM_16BIT)\n .setSampleRate(44100)\n .setChannelIndexMask(0xf /* 4 channels, 0..3 */)\n .build();\n final AudioRecord audioRecord = new AudioRecord.Builder()\n .setAudioFormat(audioFormat)\n .build();\n audioRecord.setPreferredDevice(someAudioDeviceInfo);\n\nWhen both `setChannelMask` and `setChannelIndexMask` are set, `AudioRecord` uses\nonly the value set by `setChannelMask` (maximum of two channels).\n\nConcurrent capture\n------------------\n\nAs of Android 10, the Android framework supports\n[Concurrent capture](/docs/core/audio/concurrent) of inputs, but with\nrestrictions to protect the user's privacy. As part of these restrictions,\nvirtual sources such as `AUDIO_SOURCE_FM_TUNER` are ignored, and are allowed to\nbe captured concurrently along with a regular input (such as the microphone).\n`HwAudioSource` is not considered part of the concurrent capture restrictions.\n\nApps designed to work with `AUDIO_DEVICE_IN_BUS` devices or with secondary\n`AUDIO_DEVICE_IN_FM_TUNER` devices must rely on explicitly identifying those\ndevices and using `AudioRecord.setPreferredDevice()` to bypass the Android\ndefault source selection logic."]]