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

如何讓錄音品質變好?

尚未結案
linmon416
一般會員


發表:11
回覆:44
積分:11
註冊:2003-12-19

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-11-01 11:19:41 IP:211.75.xxx.xxx 未訂閱
各位大大好: 小弟在網路上找到一段程式如下,我利用它來使播flash時,可以錄下flash的聲音,並儲存成wav聲音檔,而結果是可以錄,但品質不好,位元率88kbps,8位元,單聲道,取樣速度11k,格式PCM,請問各位大大如何改下面的程式,使錄音品質變好, ,而位元,聲道(單或雙),取樣速度是可以自已決定的,謝謝.
 
unit Unit1;    interface    uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
  Dialogs,MMSystem,StdCtrls;    type
    TWavHeader = record //定義Wav文件與格式
    rId : longint;
    rLen : longint;
    wId : longint;
    fId : longint;
    fLen : longint;
    wFormatTag : word;
    nChannels : word;
    nSamplesPerSec : longint;
    nAvgBytesPerSec : longint;
    nBlockAlign : word;
    wBitsPerSample : word;
    dId : longint;
    wSampleLength : longint;
    end;
    TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure AppException(Sender: TObject; E: Exception);
  private
    { Private declarations }
    FDeviceID: Word;
  public
    { Public declarations }
    procedure OpenMedia;
    procedure RecordMedia;
    procedure StopMedia;
    procedure SaveMedia;
    procedure CloseMedia;
  end;    var
  Form1: TForm1;    implementation    {$R *.dfm}
var
  MyError,Flags: Longint;    { TForm1 }    procedure TForm1.CloseMedia;
var
    MyGenParms: TMCI_Generic_Parms;
begin
    if FDeviceID <> 0 then
    begin
        Flags:=0;
        MyGenParms.dwCallback:=Handle; // TForm1.Handle
        MyError:=mciSendCommand(FDeviceID, mci_Close, Flags,longint(@MyGenParms));
        if MyError = 0 then
            FDeviceID:=0;
    end;
end;    procedure TForm1.OpenMedia;
var
    MyOpenParms: TMCI_open_Parms;
    MyPChar: PChar;
    TextLen: Longint;
begin
    Flags:=mci_wait or mci_Open_Element or mci_Open_Type ;
    MyOpenParms.dwCallback:=Handle; // TForm1.Handle
    MyOpenParms.lpstrDeviceType:=PChar('waveaudio');        MyOpenParms.lpstrElementName:=PChar('');        MyError:=mciSendCommand(0, mci_Open, Flags,longint(@myopenparms));
    if MyError = 0 then
        FDeviceID:=MyOpenParms.wDeviceID;
end;    procedure TForm1.RecordMedia;
var
    MyRecordParms: TMCI_Record_Parms;
    TextLen: Longint;
begin
    Flags:=mci_Notify;        with MyRecordParms do
    begin
        dwCallback:=Handle;  // TForm1.Handle
        dwFrom:=0;
        dwTo:=10000;
    end;        MyError:=mciSendCommand(FDeviceID, mci_Record, Flags,Longint(@MyRecordParms));
end;    procedure TForm1.SaveMedia;
type    // not implemented by Delphi
    PMCI_Save_Parms = ^TMCI_Save_Parms;
    TMCI_Save_Parms = record
    dwCallback: DWord;
    lpstrFileName: PAnsiChar;  // name of file to save
end;
var
    MySaveParms: TMCI_Save_Parms;
begin
    if FDeviceID <> 0 then
    begin
        // save the file...
        Flags:=(mci_Save_File or mci_Wait);
        with MySaveParms do
        begin
            dwCallback:=Handle;
            lpstrFileName:=PChar('c:\message.wav');
        end;
        MyError:=mciSendCommand(FDeviceID, mci_Save, Flags, Longint(@MySaveParms));
    end;
end;    procedure TForm1.StopMedia;
var
    MyGenParms: TMCI_Generic_Parms;
begin
    if FDeviceID <> 0 then
    begin
        Flags:=mci_Wait;
        MyGenParms.dwCallback:=Handle;  // TForm1.Handle
        MyError:=mciSendCommand(FDeviceID, mci_Stop, Flags,Longint(@MyGenParms));
    end;
end;    procedure TForm1.Button1Click(Sender: TObject);
begin
    OpenMedia;
    RecordMedia;
end;    procedure TForm1.Button2Click(Sender: TObject);
begin
    StopMedia;
    SaveMedia;
    CloseMedia;
end;    procedure TForm1.FormCreate(Sender: TObject);
begin
    Application.OnException := AppException;
end;    procedure TForm1.AppException(Sender: TObject; E: Exception);
begin
    CloseMedia;
end;    end.
linmon416
一般會員


發表:11
回覆:44
積分:11
註冊:2003-12-19

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-11-15 16:14:51 IP:211.75.xxx.xxx 未訂閱
好像沒人知道,在放個一星期看看,如都沒人回應,那就結案了。
系統時間:2024-05-05 20:28:28
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!