[
    {
        "role": "user",
        "content": "explane%20the%20types%20of%20Android%20microphone%20record%20selections.%20default%2C%20microphone%2C%20voice%20recognition%2C%20voice%20communication%2C%20unprocessed%2C%20and%20voice%20performance"
    },
    {
        "role": "assistant",
        "content": "Here\u2019s a breakdown of Android\u2019s main microphone/ audio source *types* (\u201caudio sources\u201d or \u201caudio recording selections\u201d) such as `DEFAULT`, `MIC`, `VOICE_RECOGNITION`, `VOICE_COMMUNICATION`, `UNPROCESSED`, `VOICE_PERFORMANCE`. These are defined in `android.media.MediaRecorder.AudioSource` (and used by `AudioRecord`) and are intended for different use cases.([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource?utm_source=openai))\n\n---\n\n## What an Audio Source Is\n\nAn *audio source* controls both **which physical microphone or input** is used, and often how Android processes the audio: whether it\u2019s cleaned up (noise suppression, echo cancellation, automatic gain control, etc.) or left raw; whether optimized for latency; etc.([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html?utm_source=openai))\n\n---\n\n## Key Types & What They Mean\n\nHere are the most common audio source constants you asked about, what they do, and when they\u2019re best to use.\n\n| Audio Source | API Level | Behavior & Processing | Typical Use Cases |\n|--------------|-----------|------------------------|---------------------|\n| **DEFAULT** | API 1 | The system picks a default source and includes typical processing (like noise suppression, echo cancellation, etc.), depending on device and other settings. It\u2019s a \u201csafe\u201d fallback. | Simple voice recording, background audio, when you don\u2019t care about special optimization.([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource?utm_source=openai)) |\n| **MIC** | API 1 | Direct microphone input. May include system processing depending on settings and device. Not as \u201cflat\u201d or raw as specialized sources. | Voice memos, general sound capture where you don\u2019t need zero latency or ultra-raw. |\n| **VOICE_RECOGNITION** | API 7 | Tuned explicitly for recognizing speech. Must disable noise reduction and AGC (automatic gain control) by default. Offers relatively flat frequency response, especially from ~100Hz to 4000Hz.([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html?utm_source=openai)) | Speech-to-text, virtual assistants, voice commands, voice input where clarity of words matters. |\n| **VOICE_COMMUNICATION** | API 11 | Optimized for two-way communications (VoIP, calls). Uses system effects like echo cancellation and AGC. Latency might be lower compared to general record but processing is present.([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html?utm_source=openai)) | Voice calls over internet, video chat, messaging apps. |\n| **UNPROCESSED** | API 24 | Aimed at delivering raw microphone data *without* effects or processing. If device doesn't support truly unprocessed, behaves like `DEFAULT`. Always check availability first.([developer.android.com](https://developer.android.com/media/platform/mediarecorder?utm_source=openai)) | Audio analysis (e.g. research, forensics), high fidelity audio capture, machine learning work where any preprocessing biases matter. |\n| **VOICE_PERFORMANCE** | API 29 | Designed for live performance, karaoke, or scenarios where audio is captured and played back with minimal delay. The capture path is optimized for low latency and reduced coupling to playback path.([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html?utm_source=openai)) | Sing-along apps, digital musical instrument input, live loopers, karaoke. |\n\n---\n\n## Extras & Related Sources\n\nThese are a few other audio sources you might encounter:\n\n- **CAMCORDER**: optimized for video recording (audio aligned with video)([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html?utm_source=openai))  \n- **VOICE_CALL**, **VOICE_UPLINK**, **VOICE_DOWNLINK**: used for capturing actual phone call audio (both sides)([developer.android.com](https://developer.android.com/reference/android/media/MediaRecorder.AudioSource.html?utm_source=openai))\n\n---\n\n## Choosing the Right Source\n\nHere are some guidelines to help pick one:\n\n1. **Need raw vs processed audio?**  \n   - Use `UNPROCESSED` if you need raw, unfiltered audio.  \n   - If not supported, `DEFAULT` or `VOICE_RECOGNITION` (which disables many effects) are alternatives.([developer.android.com](https://developer.android.com/media/platform/mediarecorder?utm_source=openai))\n\n2. **Latency matters?**  \n   - For real-time audio (like singing/karaoke), use `VOICE_PERFORMANCE`.  \n\n3. **Voice clarity vs ambient sound?**  \n   - `VOICE_RECOGNITION` gives clearer voice, dampens background noise.  \n   - `DEFAULT` or `MIC` might preserve more ambient detail but also noise and distortion.\n\n4. **Communication contexts (calls, streaming)?**  \n   - `VOICE_COMMUNICATION` is tuned for two-way, interactive usage.  \n\n---\n\nIf you want, I can also show you how available audio sources differ between Android versions or device models\u2014and how to programmatically check whether options like `UNPROCESSED` are supported on a given device."
    },
    {
        "role": "user",
        "content": "what%20about%20unprocessed"
    },
    {
        "role": "assistant",
        "content": "Here\u2019s a deep dive into Android\u2019s **UNPROCESSED** audio source: what it is, what it requires, what devices support it, how to use it\u2014and its trade-offs.\n\n---\n\n## What Does \u201cUNPROCESSED\u201d Mean\n\nThe `UNPROCESSED` audio source tells Android: \u201cGive me the raw microphone input with *no signal processing*.\u201d That means:\n\n- No automatic gain control (AGC)  \n- No echo cancellation  \n- No noise suppression, high-pass or low-pass filters  \n- No effects\u2014so the audio path should be as direct as possible.  \n\nAndroid documents: some processing (a level multiplier to bring volume into usable range) *is allowed*, but only if it doesn\u2019t introduce delay or modify the signal beyond linear scaling. ([android.googlesource.com](https://android.googlesource.com/platform/compatibility/cdd/%2B/ad3d038/5_multimedia/5_11_unprocessed-audio.md?utm_source=openai))\n\n---\n\n## Android\u2019s Requirements (Compatibility Definition)\n\nFor a device to *legally claim* support for `UNPROCESSED`, it must meet certain hardware and signal path criteria (defined in the Android Compatibility Definition Document, or CDD) starting from Android 7.0. Some of the key requirements:\n\n- Report support via the property `AudioManager.PROPERTY_SUPPORT_AUDIO_SOURCE_UNPROCESSED`. Apps can check this at runtime. ([android.googlesource.com](https://android.googlesource.com/platform/compatibility/cdd/%2B/ad3d038/5_multimedia/5_11_unprocessed-audio.md?utm_source=openai))  \n- Flat frequency response over mid-frequencies (100 Hz to 7000 Hz: \u00b110 dB variation) ([android.googlesource.com](https://android.googlesource.com/platform/compatibility/cdd/%2B/ad3d038/5_multimedia/5_11_unprocessed-audio.md?utm_source=openai))  \n- Acceptable response in low frequencies (5-100 Hz) and high frequencies (above 7000 Hz up to 22 kHz) with looser tolerances. ([android.googlesource.com](https://android.googlesource.com/platform/compatibility/cdd/%2B/ad3d038/5_multimedia/5_11_unprocessed-audio.md?utm_source=openai))  \n- Sensitivity calibration: a 94 dB SPL tone at 1 kHz should map to an RMS value of \u201c520\u201d for 16-bit. ([android.googlesource.com](https://android.googlesource.com/platform/compatibility/cdd/%2B/ad3d038/5_multimedia/5_11_unprocessed-audio.md?utm_source=openai))  \n- Signal-to-Noise Ratio of 60 dB or better (A-weighted) ([android.googlesource.com](https://android.googlesource.com/platform/compatibility/cdd/%2B/ad3d038/5_multimedia/5_11_unprocessed-audio.md?utm_source=openai))  \n- Total Harmonic Distortion (THD) < 1% for a 1 kHz input at 90 dB SPL. ([android.googlesource.com](https://android.googlesource.com/platform/compatibility/cdd/%2B/ad3d038/5_multimedia/5_11_unprocessed-audio.md?utm_source=openai))  \n- Absolutely no DSP or other filtering (like AGC, high-pass etc.), except for that multiplier, which must not introduce delay. ([source.android.com](https://source.android.com/docs/compatibility/9/android-9-cdd.pdf?utm_source=openai))  \n\n---\n\n## Device Support & Reality Check\n\nEven though `UNPROCESSED` was introduced in API level 24 (Android 7.0), *not all devices support it fully*. Some devices name it but don\u2019t meet all the CDD requirements, or they may ignore it entirely, returning silence, or still apply some processing. ([github.com](https://github.com/google/oboe/discussions/982?utm_source=openai))\n\nKey things to know:\n\n- Use `AudioManager.getProperty(AudioManager.PROPERTY_SUPPORT_AUDIO_SOURCE_UNPROCESSED)` to check if your device reports it properly. If it returns `null` or \u201cfalse\u201d, the device doesn\u2019t claim to support true unprocessed audio. ([developer.android.com](https://developer.android.com/media/platform/mediarecorder?utm_source=openai))  \n- Even when it *does* claim support, actual performance may still vary: useful metrics like background noise, THD, frequency response may differ across manufacturers. Testing or reviewing device specifications is often required. ([source.android.com](https://source.android.com/docs/compatibility/9/android-9-cdd.pdf?utm_source=openai))  \n\n---\n\n## When & Why Use UNPROCESSED\n\nBenefits:\n\n- For high-fidelity recording, audio analysis, machine learning tasks, voice biometrics, forensics, etc.\u2014basically anywhere you want the *cleanest signal possible*.  \n- Capturing subtle ambient or low-frequency content that other sources might filter out.  \n- Avoiding compression or processing artifacts\u2014e.g. for measurement tools, or when writing your own DSP pipeline.  \n\nTrade-offs:\n\n- Often lower gain: because AGC is disabled, recordings may be quieter, especially if the source sound level is low. You\u2019ll need to set gain appropriately or post-amplify.  \n- More background noise: since there\u2019s no noise suppression.  \n- Possibly higher latency in some paths or hardware where the \u201clevel multiplier\u201d or other pieces aren\u2019t optimized.  \n- Inconsistent hardware support means you need to detect and handle fallback scenarios.  \n\n---\n\n## How to Use UNPROCESSED in Code (Safely)\n\nHere\u2019s a typical flow:\n\n1. **Check support**  \n   ```java\n   String prop = AudioManager.getProperty(AudioManager.PROPERTY_SUPPORT_AUDIO_SOURCE_UNPROCESSED);\n   boolean supportsUnprocessed = (prop != null && prop.equalsIgnoreCase(\"true\"));\n   ```\n   If `false`/`null`, you may need to choose something else (e.g. `VOICE_RECOGNITION`). ([developer.android.com](https://developer.android.com/media/platform/mediarecorder?utm_source=openai))\n\n2. **Set audio source**  \n   ```java\n   mediaRecorder.setAudioSource(MediaRecorder.AudioSource.UNPROCESSED);\n   ```\n\n3. **Configure format, encoder, file path**, etc. As usual with `MediaRecorder` or `AudioRecord`.\n\n4. **Test on multiple devices**, especially ones you expect your users to use\u2014to verify gain, noise, signal quality.\n\n5. **Fallback logic**: when not supported, app should switch to alternative source (e.g. `VOICE_RECOGNITION`) and possibly notify user.  \n\n---\n\n## Summary: The Bottom Line\n\n- `UNPROCESSED` is Android\u2019s way of giving you raw mic input without system DSP\u2014intended for precision, accuracy, and fidelity.  \n- It\u2019s officially required to meet tight specs for devices that claim support; but real-world behavior varies.  \n- Always check `PROPERTY_SUPPORT_AUDIO_SOURCE_UNPROCESSED` and test results.  \n- Best fit for pro-audio, scientific/ML tasks, or any scenario where system processing would ruin your data.  \n\nIf you want, I can pull up a list of phones that reliably support UNPROCESSED (with measurements), so you can choose compatible hardware\u2014or test yours."
    },
    {
        "role": "user",
        "content": "what%20about%20voice%20performance"
    },
    {
        "role": "assistant",
        "content": "Here\u2019s a detailed exploration of the Android `VOICE_PERFORMANCE` audio source (also called *InputPreset: VoicePerformance*), including what it is, why it was introduced, how it behaves, and when to use it.\n\n---\n\n## What is `VOICE_PERFORMANCE`?\n\n- `VOICE_PERFORMANCE` is a constant in `android.media.MediaRecorder.AudioSource` introduced in Android **API level 29** (Android 10 / \u201cQ\u201d) ([developer.android.com](https://developer.android.com/sdk/api_diff/29/changes/android.media.MediaRecorder.AudioSource?utm_source=openai)).\n- It corresponds to the AAudio input preset **\u201cVoicePerformance\u201d**, or *InputPreset:VoicePerformance*, which was added to provide *low-latency, pro-audio \u201cfast-path\u201d* microphone input ([chromium.googlesource.com](https://chromium.googlesource.com/external/github.com/google/oboe/%2B/refs/heads/1.3-stable/docs/AndroidAudioHistory.md?utm_source=openai)).\n\n---\n\n## What It Does \u2014 Behavior & Characteristics\n\nThe `VOICE_PERFORMANCE` source is optimized for scenarios demanding:\n\n- **Low latency capture**: minimized delay from microphone capture to when samples are delivered to the app. Especially useful when input and output are closely coupled (e.g. monitoring, interactive singing, or musical keyboard apps) ([chromium.googlesource.com](https://chromium.googlesource.com/external/github.com/google/oboe/%2B/refs/heads/1.3-stable/docs/AndroidAudioHistory.md?utm_source=openai)).\n- **High throughput / fast path**: on compatible devices, it uses audio paths designed to skip or minimize processing, enabling higher sample rates, smaller buffer sizes, or more direct access from hardware to the app. In the Android audio input history, it\u2019s noted that adding `InputPreset:VoicePerformance` supports low-latency recording via these fast paths ([chromium.googlesource.com](https://chromium.googlesource.com/external/github.com/google/oboe/%2B/refs/heads/1.3-stable/docs/AndroidAudioHistory.md?utm_source=openai)).\n- **Reduced signal processing**: because extra effects (echo cancellation, noise suppression, etc.) tend to introduce delay, `VOICE_PERFORMANCE` HPW aims to avoid or bypass them as much as possible, though behavior may vary depending on the hardware/driver implementation.\n\n---\n\n## Device Support & Practical Reality\n\nWhile `VOICE_PERFORMANCE` is part of the API, real-life support depends on several factors:\n\n- The hardware must have an input path that supports the \u201cfast path\u201d or low-latency input feature. Not all devices implement this. Even when the constant is available, using `VOICE_PERFORMANCE` may fallback to a more generic path or have buffer sizes large enough to introduce noticeable latency ([chromium.googlesource.com](https://chromium.googlesource.com/external/github.com/google/oboe/%2B/refs/heads/1.3-stable/docs/AndroidAudioHistory.md?utm_source=openai)).\n- In AAudio (Android\u2019s native audio API), selecting this input preset can influence which driver path the system uses, but it's not a guarantee of a fixed latency. Device architecture, driver support, and Android version all matter ([chromium.googlesource.com](https://chromium.googlesource.com/external/github.com/google/oboe/%2B/refs/heads/1.3-stable/docs/AndroidAudioHistory.md?utm_source=openai)).\n\n---\n\n## When to Use `VOICE_PERFORMANCE`\n\nHere are cases where `VOICE_PERFORMANCE` makes sense:\n\n- Live performance apps (e.g. karaoke, looping, monitoring) where the user expects near-instant feedback.\n- Interactive tools: musical instruments (digital synths), DJ apps, real-time voice effects.\n- Vocal recording where monitoring latency (hearing your voice along with backing track) matters.\n- Any situation where high fidelity plus low latency are both required, and you can test or assume device support.\n\n---\n\n## Limitations, Trade-offs & Fallbacks\n\nThings to watch out for:\n\n- **Availability**: Some devices do **not** support VoicePerformance paths; you\u2019ll need fallback options.\n- **Signal quality**: Because processing (e.g. noise suppression, AGC) is reduced or eliminated, audio may have more background noise or unbalanced gain.\n- **Cost in power and CPU**: Low-latency paths often need higher sample rates or continuous resource usage, which can increase power consumption.\n- **Device variability**: Latency can still vary widely\u2013\u2013just because you requested `VOICE_PERFORMANCE` doesn\u2019t mean you\u2019ll get <10 ms latency. On some devices it could still be significantly higher, depending on hardware and OS build.\n\n---\n\n## How to Use It in Code\n\nHere\u2019s how you might use `VOICE_PERFORMANCE` safely:\n\n```java\nMediaRecorder recorder = new MediaRecorder();\nrecorder.setAudioSource(MediaRecorder.AudioSource.VOICE_PERFORMANCE);\n// then set other settings\u2014output format, encoder, file path, etc.\n```\n\nOr using `AudioRecord` and AAudio / OpenSL ES:\n\n- Check whether a \u201cfast input path\u201d is supported (varies by API).\n- Set sample rate, buffer size, performance mode to \u201clow latency\u201d or equivalent.\n- Test behavior: measure latency in your app, record monitoring feedback.\n\nAlso, have fallback logic:\n\n```java\nint source = MediaRecorder.AudioSource.VOICE_PERFORMANCE;\nif (!deviceSupportsVoicePerformance()) {\n    source = MediaRecorder.AudioSource.UNPROCESSED; // or DEFAULT, MIC, etc.\n}\n```\n\nDevice support might be checked via manufacturer documentation, or by detecting low latency input paths or features.\n\n---\n\n## Summary\n\n`VOICE_PERFORMANCE` is Android\u2019s attempt at *professional, low-latency voice input*. When supported, it can provide very fast, high-quality mic input suitable for interactive or real-time apps. But just having the API doesn\u2019t guarantee ideal results\u2014device compatibility, buffer sizes, driver behavior, and signal quality all factor heavily. Always test and provide fallback options.\n\nIf you like, I can compare latency measurements for `VOICE_PERFORMANCE` across popular devices, so you know how it performs in practice on phones like Google Pixel, Samsung Galaxy, etc."
    }
]