分析:连接按钮,开启MIC线程,开始记录MIC传递来的数据
if (flag_MIC) {
// 如果MIC标志位未true,则操作MIC
if (flag_MIC_conn) {
try {
// 停止MIC线程
MicroPhoneThread.pause();
flag_MIC_conn = false;
bt_connect.setText("连接");
//断开连接之后,让波形不再显示
//how?
mWaveform.ch_disappear();
} catch (Exception e) {
// TODO Auto-generated catch block
Toast.makeText(getBaseContext(), "MIC未断开", 1).show();
}
} else {
try {
// 开启MIC线程
MicroPhoneThread = new myMICThread();
MicroPhoneThread.start();
flag_MIC_conn = true;
mWaveform.ch_appear();
bt_connect.setText("断开");
} catch (Exception e) {
// TODO Auto-generated catch block
Toast.makeText(getBaseContext(), "MIC未连接", 1).show();
}
}
<span style="white-space:pre"> </span>MicroPhoneThread线程:
<span style="white-space:pre"> </span>public class myMICThread extends Thread {
<span style="white-space:pre"> </span>private AudioRecord ar;
<span style="white-space:pre"> </span>private int bs;
<span style="white-space:pre"> </span>private int SAMPLE_RATE_IN_HZ = 44100;
<span style="white-space:pre"> </span>private bool