Audio Recording in Stereo giving same data in Left and Right channels

前端 未结 3 632
一个人的身影
一个人的身影 2021-01-03 09:57

I am trying to record and process audio data based on differences in what gets recorded in the left and right channel. For this I am using Audio Record class, with MIC as in

3条回答
  •  無奈伤痛
    2021-01-03 10:17

    Here is a working example for capturing audio in stereo (tested with Samsung Galaxy S3 4.4.2 SlimKat):

    private void startRecording() {
        String filename = Environment.getExternalStorageDirectory().getPath()+"/SoundRecords/"+System.currentTimeMillis()+".aac";
        File record = new File(filename);
        recorder = new MediaRecorder();
        recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
        recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
        recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
        recorder.setAudioEncodingBitRate(128000);
        recorder.setAudioSamplingRate(96000);
        recorder.setAudioChannels(2);
        recorder.setOutputFile(filename);
        t_filename.setText(record.getName());
        try {
            recorder.prepare();
            recorder.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    

    If your phone supports stereo capturing, then this should work :)

提交回复
热议问题