2

これは私のコードです

Thread Rthread = null;
AudioRecord record = null;
int freq = 8000;
AudioManager am;
AudioTrack play;
int minbuff=20000;
AudioRecord m_record;
AudioTrack m_track;
byte[] buffer = new byte[freq];

protected void Start() {
    Rthread = new Thread(new Runnable() {
        public void run() {
            loopback();
        }
    });
    Rthread.start();
}

protected void loopback() {
    android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
    minbuff = AudioRecord.getMinBufferSize(freq,
    AudioFormat.CHANNEL_CONFIGURATION_MONO,
    AudioFormat.ENCODING_PCM_16BIT);
    if (minbuff <= freq) {
        minbuff = freq;
    }
    am.setParameters("noise_suppression=on");
    m_record = new AudioRecord(MediaRecorder.AudioSource.MIC, freq,
    AudioFormat.CHANNEL_CONFIGURATION_MONO,
    MediaRecorder.AudioEncoder.AMR_NB, minbuff);
    m_track = new AudioTrack(AudioManager.ROUTE_HEADSET, freq,
    AudioFormat.CHANNEL_CONFIGURATION_MONO,
    MediaRecorder.AudioEncoder.AMR_NB, minbuff,
    AudioTrack.MODE_STREAM);
    m_track.setPlaybackRate(freq);
    byte[] buffer = new byte[minbuff];
    m_record.startRecording();
    Log.i(LOG_TAG, "Audio Recording started");
    m_track.play();
    Log.i(LOG_TAG, "Audio Playing started");
    while (true) {
        try {
            m_record.read(buffer, 0, minbuff);
            for (int i = 1; i < buffer.length; i++) {
                buffer[i] *=amp;
            }
            m_track.write(buffer, 0, buffer.length);
            } catch (Throwable t) {
            Log.e("Error", "Read write failed");
            t.printStackTrace();
        }
    }
}

では、バックグラウンドノイズを減らし、録音されたオーディオの周波数を増幅する方法を教えてください。

4

0 に答える 0