|
我们有了这两个强有力的类的支持就可以开始我们的编程工作了….
1.用VC6++建立一个MFC基于对话框的工程:MicDemo;
2.添加我们的两个类CSoundIn,CwaveFile;
3.当我们点击开始(Start)按钮的时候我们就要开始录音了…
void CMicDemoDlg::OnStart()
{
m_btnStart.EnableWindow(FALSE);
if(theSoundCapture().__initMic())
{
m_filePath.SetWindowText(_T("yangchen.wav."));
theSoundCapture().__createOutputWaveFile(_T("yangchen.wav"));
if(!theSoundCapture().__openMic())
{
::MessageBox(this->m_hWnd,_T("Can not open microphone!"), _T("Error"),MB_OK|MB_ICONERROR);
return;
}
}
m_btnStop.EnableWindow(TRUE);
// 设置定时器是为了画波形用的
SetTimer(1, 200 /*start slow*/, NULL);
}
4.在定时器的回调函数中画波形.
void CMicDemoDlg::OnTimer(UINT nIDEvent)
{
if(nIDEvent == 1)
{
static const int xCon = 13;
static const int yCon = 13;
static const int wCon = 623;
static const int hCon = 80;
CClientDC dc(this);
CBitmap Bitmap;
CBitmap * pbmOld = NULL;
CDC &n [1] [2] [3] 下一页 |