Reputation: 2792
I am recording audio using AudioRecord
. Currently I am using 44100 as sample rate and 16bit as AudioFormat
.
Can I use 48000 as sample rate and 24bit as AudioFormat
?
Below is the code with sample rate 44100 and audio format as 16bit.
int SAMPLE_RATE = 44100;
int mBufferSize = AudioRecord.getMinBufferSize(SAMPLE_RATE, AudioFormat.CHANNEL_IN_MONO,
AudioFormat.ENCODING_PCM_16BIT);
AudioRecord mRecorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, SAMPLE_RATE ,
AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, mBufferSize);
if (AudioRecord.STATE_INITIALIZED == mRecorder.getState()) {
mRecorder.startRecording();
}
As per Developer site, 44100Hz is the highest sample rate available. My question is, can i use 48000Hz with 24bit Audio format.
Thanks
As per this link we can record audio using 24 bits per sample. 24 Bits Per Sample With Android L, the sample resolution will be increased from 16bit PCM to 24bit for better results. Even though many smartphones released in 2013 supported 24bit 96khz DAC, the Android OS was never capable of using it.
Upvotes: 1
Views: 2320
Reputation: 106
Surely it depends on the device you are trying to record from? The Hardware manufacturer has to configure a lot of this stuff in the HAL.
The audio_policy.confshould indicate the compatible sampling rates and formats, on the device you are on. You can examine the file- it's usually found on your android device, probably under system/etc/
Example:
audio_hw_modules {
primary {
outputs {
primary {
sampling_rates 44100|48000
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_AUX_DIGITAL
flags AUDIO_OUTPUT_FLAG_PRIMARY
}
}
inputs {
primary {
sampling_rates 8000|11025|16000|22050|32000|44100|48000
channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_WIRED_HEADSET
}
}
}
In this particular case I would not be able to use 24-Bit Audio at 48 KHz, but 16 Bit would be fine.
Upvotes: 1
Reputation: 4245
Simple answer - For majority of app developers - No, you cannot.
Longish answer -
If you are building an application using the Android SDK then you cannot since the SDK doesn't define any constants for the same.
If you have access to the underlying source code to Android, the entire source build. Then you can check whether they support that sampling frequency and audio format and then you can expose them through the entire android stack and use it in your application.
The problem in with this approach is you cannot publish your application to any device, the device needs to be running the exact same image built from the same source. This method typically applies to OEM companies developing apps in their own tree..
Upvotes: 1