Audiorecord를 이용해서 녹음을 하였습니다.

그런데 재생을 해보니 시간이 잘못나오며 재생속도가 빨라져서 음성 변조 한것 같은 느낌의 소리가 나왔습니다.

혹시 아시는분 있으면 답변좀 부탁드립니다. ㅠㅠ

 *** 재생은 루트익스플로러를 통한 기본재생기에서 하였습니다.


public class AudioRecording {

private static final int RECORDER_BPP = 16;

private final String FILE_EXT_WAV = ".wav";

private final String FOLDER = "acrofon/AudioRecorder";

private final String TEMP_FILE = "record_temp.raw";

// private final int FREQUENCY = 8000;

// private final int FREQUENCY = 44100;

private final int FREQUENCY = 22050;

private final int CHANNELCONFIG = AudioFormat.CHANNEL_CONFIGURATION_MONO;

private final int AUDIOENCODING = AudioFormat.ENCODING_PCM_16BIT;

private int bufferSize = 0;

AudioRecord audioRecord;

Thread recordingThread;


public AudioRecording() {

Calling.isRecord = false;

}


public void startRecording() {

bufferSize = AudioRecord.getMinBufferSize(FREQUENCY, CHANNELCONFIG,

AUDIOENCODING);

audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, FREQUENCY,

CHANNELCONFIG, AUDIOENCODING, bufferSize);

try {

audioRecord.startRecording();

} catch (Exception e) {

e.printStackTrace();

}


Calling.isRecord = true;


// 녹음에 필요한 쓰레드를 생성합니다

recordingThread = new Thread(new Runnable() {

public void run() {

writeAudioDataToFile();

}

}, "AudioRecorder Thread");


recordingThread.start(); // 쓰레드시작

}


private String getTempFilename() {

String filepath = Environment.getExternalStorageDirectory().getPath();

File file = new File(filepath, FOLDER);


if (!file.exists()) {

file.mkdirs();

}


File tempFile = new File(filepath, TEMP_FILE);


if (tempFile.exists())

tempFile.delete();


return (file.getAbsolutePath() + "/" + TEMP_FILE);

}


private void writeAudioDataToFile() {

byte data[] = new byte[bufferSize]; // buffersize만큼 크기를 지정

String filename = getTempFilename();

FileOutputStream os = null; // 파일입출력 드디어 시작합니다!


try {

os = new FileOutputStream(filename);

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}


BufferedOutputStream bos = new BufferedOutputStream(os);

DataOutputStream dos = new DataOutputStream(bos);

audioRecord.startRecording();

int read = 0;

// 이부분이 실시간으로 파일 생성해서 소리데이터를 담는 부분입니다.

if (null != os) {

while (Calling.isRecord) {

read = audioRecord.read(data, 0, bufferSize);


if (AudioRecord.ERROR_INVALID_OPERATION != read) {

try {

dos.write(data);

// os.write(data);

} catch (IOException e) {

e.printStackTrace();

}

}

}

stopRecording();


try {

os.close();

} catch (IOException e) {

e.printStackTrace();

}

}

}


소리가 저장되는 핵심부분만 추출하여 올렸습니다.