Skip to content

Commit

Permalink
Set audio recorder sample rate
Browse files Browse the repository at this point in the history
  • Loading branch information
avazirna committed Jul 26, 2023
1 parent a287cf2 commit d58180b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/src/org/commcare/views/widgets/RecordingFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class RecordingFragment extends DialogFragment {

private static final String MIMETYPE_AUDIO_AAC = "audio/mp4a-latm";

private static final int HEAAC_SAMPLE_RATE = 44100;
private static final int AMRNB_SAMPLE_RATE = 8000;

private String fileName;
private static final String FILE_EXT = ".mp3";

Expand Down Expand Up @@ -192,10 +195,13 @@ private void setupRecorder() {
recorder = new MediaRecorder();
}

boolean isHeAacSupported = isHeAacEncoderSupported();

recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setAudioSamplingRate(isHeAacSupported ? HEAAC_SAMPLE_RATE : AMRNB_SAMPLE_RATE);
recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
recorder.setOutputFile(fileName);
if (isHeAacEncoderSupported()) {
if (isHeAacSupported) {
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.HE_AAC);
} else {
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
Expand Down

0 comments on commit d58180b

Please sign in to comment.