全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:1005
推到 Plurk!
推到 Facebook!

好用的錄音程式

 
leobxb
一般會員


發表:18
回覆:30
積分:14
註冊:2003-10-02

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-10-07 10:15:55 IP:220.229.xxx.xxx 未訂閱
 
//---------------------------------------------------------------------------    #include 
#include 
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;    HINSTANCE g_hInstance;
HANDLE m_hMCIWnd;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
        : TForm(Owner)
{
  m_hMCIWnd=MCIWndCreate(Handle,
                         g_hInstance,
                         WS_CHILD | WS_OVERLAPPED | WS_CAPTION | WS_BORDER |
                         MCIWNDF_RECORD | MCIWNDF_SHOWALL,
                         NULL );
  if ( NULL==m_hMCIWnd )
  {
    MessageBox(Handle,"Error Creating MCIWnd Window!",NULL, MB_OK);
    return;
  }
  Button1->Enabled=true;
  Label1->Caption="IDLE";
}
//---------------------------------------------------------------------------
__fastcall TForm1::~TForm1(void)
{
  if ( Button2->Enabled )
    Button2Click(NULL);      MCIWndDestroy(m_hMCIWnd);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  MCIWndNew(m_hMCIWnd, "waveaudio");
  // change the default audio setting (which is 11khz 8bit mono)
  MCI_WAVE_SET_PARMS set_parms;
  set_parms.wFormatTag      = WAVE_FORMAT_PCM;
  set_parms.wBitsPerSample  = 16;
  set_parms.nChannels       = 1;
  set_parms.nBlockAlign     = (set_parms.nChannels*set_parms.wBitsPerSample)/8;
  set_parms.nSamplesPerSec  = 44100;
  set_parms.nAvgBytesPerSec = ((set_parms.wBitsPerSample) *
                                set_parms.nChannels *
                                set_parms.nSamplesPerSec)/8;      int deviceID=MCIWndGetDeviceID(m_hMCIWnd);
  int result = mciSendCommand( deviceID, MCI_SET,
                               MCI_WAIT
                             | MCI_WAVE_SET_FORMATTAG
                             | MCI_WAVE_SET_BITSPERSAMPLE
                             | MCI_WAVE_SET_CHANNELS
                             | MCI_WAVE_SET_SAMPLESPERSEC
                             | MCI_WAVE_SET_AVGBYTESPERSEC
                             | MCI_WAVE_SET_BLOCKALIGN,
                               (DWORD)(LPVOID)&set_parms);
  if ( result )
  {
    char buffer[100];
    mciGetErrorString(result, buffer, sizeof(buffer));
    MessageBox( NULL, buffer, "MCI_WAVE_SET_1", MB_OK);
    return;
  }      MCIWndRecord(m_hMCIWnd);      Button1->Enabled=false;
  Button2->Enabled=true;
  Label1->Caption="RECORDING";        
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
  MCIWndStop(m_hMCIWnd);
  MCIWndSave(m_hMCIWnd,"test.wav");
  MCIWndClose(m_hMCIWnd);      Button1->Enabled=true;
  Button2->Enabled=false;
  Label1->Caption="IDLE";
}
//---------------------------------------------------------------------------
這個錄音程式很好用,但我用時原本要存成test.wav的檔案,會變成亂碼? 不知道為什麼?請大家試試吧!!!如有解決方式也分享一下吧...呵呵 有收穫記得回饋,讓我們台灣跨出程式的出頭天...
系統時間:2024-05-16 16:48:40
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!