Why use AMR format instead of MP3 or AAC?
Why use AMR format instead of MP3 or AAC?
AMR (Adaptive Multi-Rate) is specifically designed for speech encoding and offers several advantages:
- Small file size: AMR produces significantly smaller files than MP3 or AAC for voice recordings, typically 5-10 times smaller
- Optimized for speech: The codec is specifically tuned for human voice, making it ideal for voice notes, interviews, and phone calls
- Native Android support: AMR-NB is natively supported by Android’s MediaRecorder without additional codecs
- Low bandwidth: Perfect for applications that need to transmit audio over limited bandwidth connections
AMR-NB (Narrowband) uses a sample rate of 8 kHz, which is sufficient for speech but not suitable for music recording.
How does pause and resume work internally?
How does pause and resume work internally?
Android’s MediaRecorder doesn’t natively support pause and resume for AMR recording. AMRAudioRecorder implements this functionality by:
- Creating multiple files: When you pause and resume, the library stops the current recorder and creates a new one for each recording segment
- Tracking file segments: Each recording segment is saved as a separate temporary file in an ArrayList
- Merging on stop: When you call
stop(), the library merges all segments into a single AMR file - Skipping headers: During merge, the library skips the 6-byte AMR header from all files except the first one to ensure a valid AMR file
- Cleanup: Temporary segment files are automatically deleted after merging
Can I change the audio format to MP3 or AAC?
Can I change the audio format to MP3 or AAC?
No, AMRAudioRecorder is specifically designed for AMR-NB format. The pause/resume implementation relies on the AMR file structure (specifically the 6-byte header) for merging segments.If you need other formats:
- For formats without pause/resume: Use Android’s MediaRecorder directly with
OutputFormat.MPEG_4andAudioEncoder.AAC - For MP3/AAC with pause/resume: You’ll need to implement your own merging logic or use a different library that supports those formats
- Convert after recording: Record with AMRAudioRecorder and convert to your desired format using FFmpeg or similar tools
What are the file size implications?
What are the file size implications?
AMR-NB produces very small file sizes compared to other formats:Typical file sizes for 1 minute of audio:
- AMR-NB: ~60-80 KB (12.2 kbps bitrate)
- MP3 (64 kbps): ~480 KB
- AAC (64 kbps): ~480 KB
- WAV (uncompressed): ~5-10 MB
- A 10-minute voice memo: ~600-800 KB
- A 1-hour interview: ~3.6-4.8 MB
- 100 hours of recordings: ~360-480 MB
What is the minimum Android version required?
What is the minimum Android version required?
The library requires API level 14 (Android 4.0 Ice Cream Sandwich) as specified in the build configuration.Permissions requirements by version:
- MediaRecorder: Available since API level 1
- AMR-NB codec: Supported since API level 1
- Minimum SDK: API level 14
- Target SDK: API level 28
While the library supports API level 14+, you should target modern Android versions for security and performance reasons.
- API 14-22: Manifest permissions only
- API 23+: Runtime permissions required for
RECORD_AUDIOand storage - API 29+: Scoped storage considerations for file access
Can I use this library for music recording?
Can I use this library for music recording?
No, AMRAudioRecorder is not suitable for music recording because:
- Low sample rate: AMR-NB uses 8 kHz sampling, which only captures frequencies up to 4 kHz (telephone quality)
- Speech optimization: The codec is optimized for speech patterns and will produce poor quality for music
- No stereo support: AMR-NB is mono only
- AAC codec with 44.1 kHz or 48 kHz sample rate
- Stereo channels
- Higher bitrates (128 kbps or higher)
What happens if the app crashes during recording?
What happens if the app crashes during recording?
If your app crashes while recording:
- Temporary files remain: Segment files created before the crash stay on disk
- No automatic cleanup: The library doesn’t automatically clean up orphaned files
- Manual cleanup needed: You’ll need to implement your own cleanup logic
Is the library thread-safe?
Is the library thread-safe?
No, AMRAudioRecorder is not thread-safe. All methods should be called from the same thread, preferably the main UI thread.If you need to use the recorder from multiple threads:
How do I get the recording duration?
How do I get the recording duration?
The library doesn’t provide a built-in duration tracking feature. You need to implement this yourself:Option 1: Track time manuallyOption 2: Get duration from file after recording