Windows环境下的麦克风录音系统[6]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 slimak 的 blog

    hmmio              m_hmmio;              // mm i/o handle for the wave
    mmckinfo      m_ck;                      // multimedia riff chunk
    mmckinfo      m_ckriff;               // use in opening a wave file
    dword             m_dwsize;             // the size of the wave file
    mmioinfo       m_mmioinfoout;
    dword             m_dwflags;
    bool                 m_bisreadingfrommemory;
    byte*               m_pbdata;
    byte*               m_pbdatacur;
    ulong              m_uldatasize;
    char*              m_presourcebuffer;   
protected:
    hresult readmmio();
    hresult writemmio( waveformatex *pwfxdest );

public:
    cwavefile();
    ~cwavefile();

    hresult open( lpctstr strfilename, waveformatex* pwfx, dword dwflags );
    hresult openfrommemory( byte* pbdata, ulong uldatasize,
                                                        waveformatex* pwfx, dword dwflags );
    hresult close();

    hresult read( byte* pbuffer, dword dwsizetoread, dword* pdwsizeread );
    hresult write( uint nsizetowrite, byte* pbdata, uint* pnsizewrote );

    dword   getsize();
    hresult resetfile();
    waveformatex* getformat() { return m_pwfx; };
};

我们有了这两个强有力的类的支持就可以开始我们的编程工作了….
   1.用vc6++建立一个mfc基于对话框的工程:micdemo;
   2.添加我们的两个类csoundin,cwavefile;
         
   3.当我们点击开始(start)按钮的时候我们就要开始录音了…

         void cmicdemodlg::onstart()
        {
 // todo: add your control notification handler code here
 
 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);
             

本文关键:Waveform Aduio APIs, Multimedia File I/O APIs,waveInXXX,mmioXXX,麦克风,录音,波形文件,VC6++
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top