Запись звуков на андроид с помощью MediaRecorder - PullRequest
0 голосов
/ 01 апреля 2012

Я занимаюсь разработкой приложения для Android, которое записывает звук с использованием класса AudioRecorder. Следующее из моего кода:

  public void start() throws IOException {
    String state = android.os.Environment.getExternalStorageState();
    if(!state.equals(android.os.Environment.MEDIA_MOUNTED))  {
        throw new IOException("SD Card is not mounted.  It is " + state + ".");
    }

    // make sure the directory we plan to store the recording in exists
    File directory = new File(path).getParentFile();
    if (!directory.exists() && !directory.mkdirs()) {
      throw new IOException("Path to file could not be created.");
    }
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
System.out.println("mashi");
recorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
recorder.setAudioEncodingBitRate(16);
recorder.setAudioSamplingRate(44100);
try {
    recorder.setOutputFile(path);
    System.out.println("ooutput");
} catch (IllegalStateException e) {
    e.printStackTrace();
}
recorder.prepare();
recorder.start();

}

Записанный голос очень медленный и густой !!в чем проблема?

1 Ответ

1 голос
/ 11 августа 2012

изменить рекордер.setAudioSamplingRate (44100) на рекордер.setAudioSamplingRate (8000);ведь в эмуляторе требуется 8000 частота дискретизации не больше, чем эта ..

...