转载请标明出处:http://blog.csdn.net/sctu_vroy/article/details/45871823
功能:加载本地SD卡中moveDsp文件夹中的音频文件(包括录音获取文件和MP3文件),播放实时FFT,绘制出信号的时域和频域波形。
设计步骤:
第一步:页面布局,编写录音工具类URecorder(设置录音属性)和接口IVoiceManager
public class URecorder implements IVoiceManager{
private static final String TAG = "URecorder";
private Context context = null;
private String path = null;
private MediaRecorder mRecorder = null;
public URecorder(Context context, String path) {
this.context = context;
this.path = path;
mRecorder = new MediaRecorder();
}
@Override
public boolean start() {
//设置音源为Micphone
mRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
//设置封装格式
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
mRecorder.setOutputFile(path);
//设置编码格式
mRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
try {
mRecorder.prepare();
} catch (IOException e) {
Log.e(TAG, "prepare() failed");
}
//录音
mRecorder.start();
return false;
}
@Override
public boolean stop() {
mRecorder.stop();
mRecorder.release();
mRecorder = null;
return false;
}
}
public interface IVoiceManager {
public boolean start();
public boolean stop();
}<