Kể từ ngày 27 tháng 3 năm 2025, bạn nên sử dụng android-latest-release thay vì aosp-main để xây dựng và đóng góp cho AOSP. Để biết thêm thông tin, hãy xem phần Thay đổi đối với AOSP.
Sử dụng bộ sưu tập để sắp xếp ngăn nắp các trang
Lưu và phân loại nội dung dựa trên lựa chọn ưu tiên của bạn.
Bản phát hành Android 10 bao gồm các yêu cầu sau đây để chụp bằng VOICE_COMMUNICATION.
Quá trình triển khai phải cung cấp bộ khử tiếng vọng âm thanh (AEC) trên đường dẫn chụp khi chụp bằng VOICE_COMMUNICATION.
Nếu cung cấp AEC, bạn phải có thể khám phá và kiểm soát AEC đó thông qua AcousticEchoCanceler của API SDK.
Nền tảng Android cung cấp hiệu ứng âm thanh trên các thiết bị được hỗ trợ trong gói audiofx mà nhà phát triển có thể truy cập.
Ví dụ: Nexus 10 hỗ trợ các hiệu ứng xử lý trước sau:
Hiệu ứng xử lý trước được ghép nối với chế độ trường hợp sử dụng mà trong đó yêu cầu xử lý trước. Trong quá trình phát triển ứng dụng Android, một trường hợp sử dụng được gọi là thực thể AudioSource; và nhà phát triển ứng dụng yêu cầu sử dụng tính năng trừu tượng AudioSource thay vì thiết bị phần cứng âm thanh thực tế. Trình quản lý chính sách âm thanh Android liên kết một thực thể AudioSource với một cấu hình đường dẫn chụp nhất định (bao gồm thiết bị, độ lợi và xử lý trước) theo các quy tắc dành riêng cho sản phẩm. Các nguồn sau đây được hiển thị cho nhà phát triển:
Các hiệu ứng xử lý trước mặc định được áp dụng cho mỗi thực thể AudioSource được chỉ định trong tệp /vendor/etc/audio_effects.xml. Để chỉ định hiệu ứng mặc định của riêng bạn cho mọi thực thể AudioSource, hãy tạo một tệp /vendor/etc/audio_effects.xml và chỉ định hiệu ứng xử lý trước để bật. Ví dụ: hãy xem cách triển khai cho
Nexus 10 trong device/samsung/manta/audio_effects.xml.
Các thực thể AudioEffect thu nạp và phát hành một phiên khi được tạo và huỷ, cho phép các hiệu ứng (chẳng hạn như Tăng độ to) tồn tại trong suốt phiên.
Ví dụ sau đây bật tính năng xử lý trước cho các thực thể AudioSource VoIP và AudioSource Máy quay video. Bằng cách khai báo cấu hình AudioSource theo cách này, khung sẽ tự động yêu cầu sử dụng các hiệu ứng đó từ HAL.
Tính năng điều chỉnh AudioSource không có yêu cầu rõ ràng về độ lợi âm thanh hoặc xử lý âm thanh, ngoại trừ tính năng nhận dạng giọng nói (VOICE_RECOGNITION). Các yêu cầu đối với tính năng nhận dạng giọng nói bao gồm:
Độ đáp ứng tần số phẳng (+/- 3 dB) từ 100 Hz đến 4 kHz
Cấu hình đàm thoại gần: 90 dB SPL đọc RMS là 2500 (mẫu 16 bit)
Cấp độ theo dõi tuyến tính từ -18 dB đến +12 dB so với 90 dB SPL
THD < 1% (90 dB SPL trong phạm vi 100 đến 4000 Hz)
Tệp /device/google/crosshatch/audio_effects.xml cho Pixel 3
Nội dung và mã mẫu trên trang này phải tuân thủ các giấy phép như mô tả trong phần Giấy phép nội dung. Java và OpenJDK là nhãn hiệu hoặc nhãn hiệu đã đăng ký của Oracle và/hoặc đơn vị liên kết của Oracle.
Cập nhật lần gần đây nhất: 2025-06-12 UTC.
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-06-12 UTC."],[],[],null,["# Configure preprocessing effects\n\nThe Android 10 release includes the following\nrequirements for capture with `VOICE_COMMUNICATION`.\n\n- Implementations should provide an acoustic echo canceler (AEC) on the capture path when capturing with `VOICE_COMMUNICATION`.\n- If providing an AEC, it must be discoverable and controllable through the SDK API's `AcousticEchoCanceler`.\n\nThe Android platform provides audio effects on supported devices in the\n[`audiofx`](http://developer.android.com/reference/android/media/audiofx/package-summary.html) package, which is available for developers to access.\nFor example, the Nexus 10 supports the following preprocessing effects:\n\n- [Acoustic\n Echo Cancellation](http://developer.android.com/reference/android/media/audiofx/AcousticEchoCanceler.html)\n- [Automatic Gain Control](http://developer.android.com/reference/android/media/audiofx/AutomaticGainControl.html)\n- [Noise\n Suppression](http://developer.android.com/reference/android/media/audiofx/NoiseSuppressor.html)\n\nPair with AudioSource instances\n-------------------------------\n\nPreprocessing effects are paired with the use case mode in which the\npreprocessing is requested. In Android app development, a use case is referred\nto as an `AudioSource` instance; and app developers request to use the\n`AudioSource` abstraction instead of the actual audio hardware\ndevice. The Android Audio Policy Manager maps an `AudioSource` instance to a\ngiven capture path configuration (including device, gain, and pre processing) according\nto product-specific rules. The following sources are exposed to developers:\n\n- `android.media.MediaRecorder.AudioSource.CAMCORDER`\n- `android.media.MediaRecorder.AudioSource.VOICE_COMMUNICATION`\n- `android.media.MediaRecorder.AudioSource.VOICE_CALL`\n- `android.media.MediaRecorder.AudioSource.VOICE_DOWNLINK`\n- `android.media.MediaRecorder.AudioSource.VOICE_UPLINK`\n- `android.media.MediaRecorder.AudioSource.VOICE_RECOGNITION`\n- `android.media.MediaRecorder.AudioSource.MIC`\n- `android.media.MediaRecorder.AudioSource.DEFAULT`\n\nThe default preprocessing effects applied for each `AudioSource` instance\nare specified in the `/vendor/etc/audio_effects.xml` file. To\nspecify your own default effects for every `AudioSource` instance, create a\n`/vendor/etc/audio_effects.xml` file and specify the\npreprocessing effects to turn on. For an example, see the implementation for\nthe Nexus 10 in `device/samsung/manta/audio_effects.xml`.\n`AudioEffect` instances acquire and release a session when created and destroyed,\nenabling the effects (such as the Loudness Enhancer) to persist throughout the\nsession.\n| **Warning:** For the `VOICE_RECOGNITION` use case, don't enable the noise suppression preprocessing effect. It shouldn't be turned on by default when recording from this audio source, and you shouldn't enable it in your own `audio_effects.xml` file. Turning on the effect by default causes the device to fail the [compatibility requirement](/docs/compatibility) regardless of whether this was on by default due to the configuration file, or the audio HAL implementation's default behavior.\n\nThe following example enables preprocessing for the VoIP\n`AudioSource` and Camcorder `AudioSource` instances. By declaring\nthe `AudioSource` configuration in this manner, the framework\nautomatically requests the use of those effects from the HAL. \n\n```carbon\n\u003cpreprocess\u003e\n \u003cstream type=\"voice_communication\"\u003e\n \u003capply effect=\"aec\"/\u003e\n \u003capply effect=\"ns\"/\u003e\n \u003c/stream\u003e\n \u003cstream type=\"camcorder\"\u003e\n \u003capply effect=\"agc\"/\u003e\n \u003c/stream\u003e\n \u003c/preprocess\u003e\n```\n\nSource tuning\n-------------\n\n`AudioSource` tuning doesn't have explicit requirements on audio\ngain or audio processing with the exception of voice recognition\n(`VOICE_RECOGNITION`). Requirements for voice recognition include:\n\n- Flat frequency response (+/- 3 dB) from 100 Hz to 4 kHz\n- Close-talk config: 90 dB SPL reads RMS of 2500 (16 bit samples)\n- Level tracks linearly from -18 dB to +12 dB relative to 90 dB SPL\n- THD \\\u003c 1% (90 dB SPL in 100 to 4000 Hz range)\n- Near-ultrasound requirements (for testing, see [Near Ultrasound\n Tests](/docs/compatibility/cts/near-ultrasound)):\n - Support for `SUPPORT_PROPERTY_MIC_NEAR_ULTRASOUND` as defined in section 7.8.3 of the CDD.\n - Support for one or both of 44100 or 48000 sampling rates with no band-pass or antialiasing filters.\n- Effects/preprocessing disabled by default\n\nExamples of tuning different effects for different sources are:\n\n- Noise Suppressor\n - Tuned for wind noise suppressor for `CAMCORDER`\n - Tuned for stationary noise suppressor for `VOICE_COMMUNICATION`\n- Automatic Gain Control\n - Tuned for close-talk for `VOICE_COMMUNICATION` and main phone mic\n - Tuned for far-talk for `CAMCORDER`\n\nResources\n---------\n\nFor more information, refer to the following resources:\n\n- Android documentation for [audiofx\n package](http://developer.android.com/reference/android/media/audiofx/package-summary.html)\n- Android documentation for [Noise\n Suppression audio effect](http://developer.android.com/reference/android/media/audiofx/NoiseSuppressor.html)\n- `/device/google/crosshatch/audio_effects.xml` file for the Pixel 3"]]