}
else
{
FinalizeWaveFile();
}
}
void StopRecord()
{
AllChangeBtn(btn_luyin, true);
AllChangeBtn(btn_stop, false);
AllChangeBtn(btn_sendsound, true);
AllChangeBtn(btn_play, true);
//btn_luyin.Enabled = true;
//btn_stop.Enabled = false;
//btn_sendsound.Enabled = true;
//btn_play.Enabled = true;
if (waveIn != null)
waveIn.StopRecording();
//Cleanup();
}
private void Cleanup()
{
if (waveIn != null)
{
waveIn.Dispose();
waveIn = null;
}
FinalizeWaveFile();
}
private void FinalizeWaveFile()
{
if (writer != null)
{
writer.Dispose();
writer = null;
}
}
//开始录音
private void btn_luyin_Click(object sender, EventArgs e)
{
btn_stop.Enabled = true;
btn_luyin.Enabled = false;
if (waveIn == null)
{
CreateWaveInDevice();
}
if (File.Exists(soundfile))
{
File.Delete(soundfile);
}
writer = new WaveFileWriter(soundfile, waveIn.WaveFormat);
waveIn.StartRecording();
}