Sample Rate In Android Audio Record Class And Mediarecord Class
Solution 1:
AS of android sdk documentation, MediaRecord is used to record audio and video. The recording control is based on a simple state machine. You will always use MediaRecord to record sounds unless you need to access the raw audio data and process them(eg, apply your own DSP effects).In this scenario you will use AudioRecord
.setAudioSamplingRate
of MediaRecord
does the same as passing SampleRateInHz
to the AudioRecord
, setting the desired sampling rate.The higher the sampling rate the better sound quality and frequency range you will get.An ideal uman ear can hear sound from 20 to 20000 hz.If you set your sampling rate to 4100hz then your frequency response will equal to 4100/2 which is almost 20000hz.However the supported freq range by devices are different. you should always check if the device supports your desired frequency.
In order to check if a specific freq works, you may use the following piece of code:
int bufferSize = AudioRecord.getMinBufferSize(rate[i],AudioFormat.CHANNEL_IN_MONO,AudioFormat.ENCODING_PCM_16BIT);
if bufferSize value is bigger than 0 then you the requency you provided is supported by device.
Post a Comment for "Sample Rate In Android Audio Record Class And Mediarecord Class"