線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:1927
推到 Plurk!
推到 Facebook!

關於wav的問題

尚未結案
mismmx
一般會員


發表:4
回覆:6
積分:2
註冊:2003-05-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-06-12 21:52:09 IP:218.162.xxx.xxx 未訂閱
請問各位大大有沒有辦法擷取喇叭的聲音,只要喇叭播放什麼程式就將之擷取下來存成WAV檔呢??? 小弟有尋找過文章~~有人提出來過~~~可是是delphi寫的,小弟沒學過~~~ 所以完全看不懂~~~ 謝謝!!!
turboted
版主


發表:95
回覆:754
積分:452
註冊:2002-07-23

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-06-13 09:54:03 IP:210.241.xxx.xxx 未訂閱
這裏有一個用MCI錄WAV的例子 原文出處 http://bcbcaq.bytamin-c.com/CAQs/API_RecordMCI.html
     
 
 
  Recording via the MCI     The VCL offers the TMediaPlayer component that serves the needs of common multimedia tasks.  However, there are times when it is prudent to use the MCI (Media Control Interface) directly.  Recording sounds is a good example of this.  Although the TMediaPlayer component is capable of recording, its functionality is severly limited.  Indeed, the MCI offers ways around these limitations.  The example below is a simple demonstration of using the MCI to record waveform data, then saving this data was a .wav file.     KEYWORDS: timeGetDevCaps(), timeSetEvent(), timeKillEvent().
      --------------------------------------------------------------------------------      //--------------------------------------------------------------------------- 
// in header...         int MediaID; 
    int MCIWavOpenNew(); 
    long int MCIWavRecordNew(int MediaID); 
    long int MCIWavStop(int MediaID); 
    long int MCIWavPlayRecording(int MediaID); 
    long int MCIWavSave(int MediaID, AnsiString FileName); 
    void __fastcall MMMcnotify(TMessage &Msg);     BEGIN_MESSAGE_MAP 
    MESSAGE_HANDLER(MM_MCINOTIFY, TMessage, MMMcnotify) 
END_MESSAGE_MAP(TForm) 
      //---------------------------------------------------------------------------      
 
       
 //--------------------------------------------------------------------------- 
#include  
//---------------------------------------------------------------------------     __fastcall TForm1::TForm1(TComponent* Owner) 
    : TForm(Owner) 
{ 
    MediaID = 0; 
} 
      void __fastcall TForm1::MMMcnotify(TMessage &Msg) 
{ 
    // perform special notification 
    // processing here if needed 
    TForm::Dispatch(&Msg); 
} 
      // open the wave device for a new file 
int TForm1::MCIWavOpenNew() 
{ 
  MCI_OPEN_PARMS mciOp;       // Specify the device type 
  mciOp.lpstrDeviceType = "waveaudio";       // Specify a new file using an empty string 
  mciOp.lpstrElementName = "";       // open MCI device 
  long int result = mciSendCommand(0, MCI_OPEN, MCI_NOTIFY | 
                                   MCI_OPEN_ELEMENT | MCI_OPEN_TYPE, 
                                   (LPARAM)&mciOp);       // result is zero if successful 
  if (result == 0) return mciOp.wDeviceID; 
  else return 0; 
} 
      // start recording 
long int TForm1::MCIWavRecordNew(int MediaID) 
{ 
    MCI_RECORD_PARMS mciRp;         // tell the MCI device to send callback messages 
    // to this window procedure (MMMcnotify message handler) 
    mciRp.dwCallback = MAKELONG(Handle, 0); 
  
    // start recording 
    long int result = mciSendCommand(MediaID, MCI_RECORD, 
                                     MCI_NOTIFY, (LONG)&mciRp);         // result is zero if successful 
    if (result != 0) 
        mciSendCommand(MediaID, MCI_CLOSE, 0, NULL); 
    return result; 
} 
      // this function will stop the recording process 
long int TForm1::MCIWavStop(int MediaID) 
{ 
    MCI_GENERIC_PARMS mciGp; 
    long int result = mciSendCommand(MediaID, MCI_STOP, 
                                     MCI_NOTIFY, (LONG)&mciGp);         // result is zero if successful 
    if (result != 0) 
        mciSendCommand(MediaID, MCI_CLOSE, 0, NULL); 
    return result; 
}     // this will playback the recorded wave data 
long int TForm1::MCIWavPlayRecording(int MediaID) 
{ 
    MCI_PLAY_PARMS mciPp; 
    mciPp.dwFrom = 0L; 
    long int result = mciSendCommand(MediaID, MCI_PLAY, MCI_FROM | 
                                     MCI_WAIT, (LONG)&mciPp); 
    if (result != 0) 
        mciSendCommand(MediaID, MCI_CLOSE, 0, NULL); 
    return result; 
}     // this will save the buffer to disk 
long int TForm1::MCIWavSave(int MediaID, AnsiString FileName) 
{ 
    MCI_SAVE_PARMS mciSp; 
    mciSp.lpfilename = FileName.c_str(); 
    long int result = mciSendCommand(MediaID, MCI_SAVE, 
                                     MCI_SAVE_FILE | MCI_WAIT, 
                                     (LONG)&mciSp); 
    if (result != 0) 
        mciSendCommand(MediaID, MCI_CLOSE, 0, NULL); 
    return result; 
} 
  
      //--------------------------------------------------------------------------- 
// The following are methods demonstrating use of the above functions 
//---------------------------------------------------------------------------  
void __fastcall TForm1::RecordButtonClick(TObject *Sender) 
{ 
    if (MediaID != 0) mciSendCommand(MediaID, MCI_CLOSE, 0, NULL);         MediaID = MCIWavOpenNew(); 
    if (MediaID != 0) 
    { 
        long int result = MCIWavRecordNew(MediaID); 
        if (result != 0) ShowMessage("Error Recording"); 
    } 
    else ShowMessage("error opening"); 
} 
      void __fastcall TForm1::StopButtonClick(TObject *Sender) 
{ 
    long int result = MCIWavStop(MediaID); 
    if (result != 0) ShowMessage("Error Stopping"); 
} 
      void __fastcall TForm1::PlayButtonClick(TObject *Sender) 
{ 
    if (MediaID != 0) 
    { 
        long int result = MCIWavPlayRecording(MediaID); 
        if (result != 0) ShowMessage("Error Playing"); 
    } 
    else ShowMessage("No device open"); 
} 
      void __fastcall TForm1::SaveButtonClick(TObject *Sender) 
{ 
    if (MediaID != 0) 
    { 
        if (SaveDialog1->Execute()) 
        { 
            long int result = MCIWavSave(MediaID, SaveDialog1->FileName); 
            if (result != 0) ShowMessage("Error Saving"); 
        } 
    } 
    else ShowMessage("No device open"); 
} 
      void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action) 
{ 
    if (MediaID != 0) mciSendCommand(MediaID, MCI_CLOSE, 0, NULL); 
} 
系統時間:2024-05-18 4:12:58
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!