有哪位高人知道ACMIn, ACMOut,ACMConvertor音频压缩是怎么回事吗 (50分)

  • 主题发起人 主题发起人 hxygod
  • 开始时间 开始时间
H

hxygod

Unregistered / Unconfirmed
GUEST, unregistred user!
有哪位高人知道音频压缩是怎么回事吗,我用以前别人的压缩方法:利用ACMIn, ACMOut,ACMConvertor对麦克风输入进行压缩,ACMConvertor输入为44.100KHz16位立体声172KB/秒 输出为11.025KHz8位单声道10KB/秒是正常的,但如果我希望实现输出低于10KB/秒,最好是实现压缩到2-3KB/秒的效果而且音质要保留到不低于11.025KHz8位单声道10KB/秒的效果,用这种方法可行吗?或者是不是就是说ACMConvertor压缩只是通过降低音质来活得音频压缩,有哪位知道的能否解释一二,我只有50分了,以下为我测试的源代码:


unit Demo2Main;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ACMIn, ACMOut,ACMConvertor, StdCtrls, NMUDP;
type
TfmMain = class(TForm)
ACMI: TACMIn;
ACMO1: TACMOut;
ACMC: TACMConvertor;
ACMC1: TACMConvertor;
NMUDP1: TNMUDP;
Memo1: TMemo;
Memo2: TMemo;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure ACMIBufferFull(Sender: TObject; Data: Pointer;
Size: Integer);
procedure NMUDP1DataReceived(Sender: TComponent; NumberBytes: Integer;
FromIP: String; Port: Integer);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);

private
{ Private declarations }
procedure TransmitData(Buffer : Pointer; Size : Integer);
public
{ Public declarations }
end;

var
fmMain: TfmMain;

implementation

uses ACMConvertorReg;

{$R *.DFM}

procedure TfmMain.FormCreate(Sender: TObject);
begin
ACMC.InputBufferSize :=8192;
ACMI.BufferSize := ACMC.InputBufferSize;
ACMC.Active := True;
ACMI.Open(ACMC.FormatIn);

ACMO1.NumBuffers := 0;

ACMC1.Active :=true;

ACMO1.Open(ACMC.FormatOut);

NMUDP1.RemoteHost :='127.0.0.1';
NMUDP1.RemotePort :=7388;
NMUDP1.LocalPort :=7388;
end;

procedure TfmMain.ACMIBufferFull(Sender: TObject; Data: Pointer;
Size: Integer);
var
NewSize : Integer;
begin
Move(Data^,ACMC.BufferIn^,Size);
NewSize := ACMC.Convert;

Memo1.Lines.Add(formatdatetime('nn:ss ',now)+':'+inttostr(Size)+'-------------'+inttostr(NewSize)) ;
TransmitData(ACMC.BufferOut,NewSize);
end;


procedure TfmMain.TransmitData(Buffer : Pointer; Size: Integer);
var
data:array[1..65535] of char;
i:integer;
begin
for i:=1 to size do
data:=pchar(dword(buffer)+dword(i-1))^;

NMUDP1.SendBuffer(data,size);
end;

procedure TfmMain.NMUDP1DataReceived(Sender: TComponent;
NumberBytes: Integer; FromIP: String; Port: Integer);
var
SB:array[0..65535] of char;
i:integer;
begin
NMUDP1.ReadBuffer(sb,numberbytes);
ACMO1.Play(sb,numberbytes);
end;

procedure TfmMain.Button1Click(Sender: TObject);
begin
ACMI.Close;
ACMO1.Close;
end;

procedure TfmMain.Button2Click(Sender: TObject);
begin
ACMI.Open(ACMC.FormatIn);
ACMO1.Open(ACMC.FormatOut);
end;

end.
 
据我所知,音频压缩实际上就是将多路通道的音频压缩到一路或者两路(左右声道),将多余的信号去掉,或者将采样频率降低
 
后退
顶部