uses
Vcl.StdCtrls, ACS_Converters, SyncObjs, Activex, ACS_Classes, ACS_Wave, ACS_AAC
type
TForm7 = class(TForm)
AdvFileNameEdit1 : TAdvFileNameEdit;
AdvFileNameEdit2 : TAdvFileNameEdit;
Button2 : TButton;
AdvComboBox2 : TAdvComboBox;
AdvComboBox3 : TAdvComboBox;
AdvEdit1 : TAdvEdit;
AdvComboBox4 : TAdvComboBox;
Memo1 : TMemo;
ProgressBar1 : TProgressBar;
procedure Button2Click(Sender : TObject);
procedure FormCreate(Sender : TObject);
procedure AdvComboBox1Change(Sender : TObject);
procedure FormClose(Sender : TObject; var Action : TCloseAction);
procedure FWaveOutDone(Sender : TComponent);
procedure FWaveOutProgress(Sender : TComponent);
procedure FWaveOutSyncDone(Sender : TComponent);
procedure FWaveOutThreadException(Sender : TComponent);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form7 : TForm7;
var
MP4In : TMP4In; // m4a 파일 인풋
WaveOut : TWaveOut; // wav 파일 아웃풋
AudioConverter : TAudioConverter; // 변환
AudioCache : TAudioCache; // 오디오 캐시
WavType : TWavType; // wav 파일 형식
implementation
{$R *.dfm}
procedure TForm7.FWaveOutDone(Sender : TComponent);
begin
Memo1.Lines.Add('WaveOutDone'); // 변환 완료
end;
procedure TForm7.FWaveOutProgress(Sender : TComponent);
begin
if Sender is TWaveOut then
ProgressBar1.Position := (Sender as TWaveOut).Progress;
// Form7.Memo1.Lines.Add(format('Progress : %d', [(Sender as TWaveOut).Progress]));
// 진행상황
end;
procedure TForm7.FWaveOutSyncDone(Sender : TComponent);
begin
Memo1.Lines.Add('WaveOutSyncDone');
end;
procedure TForm7.FWaveOutThreadException(Sender : TComponent);
begin
Memo1.Lines.Add('WaveOutThreadException');
end;
procedure TForm7.Button2Click(Sender : TObject);
begin
if not FileExists(AdvFileNameEdit1.Text) then
begin
Memo1.Lines.Add('소스 파일이 없습니다.');
AdvFileNameEdit1.SetFocus;
exit;
end;
if AdvFileNameEdit2.Text = '' then
begin
Memo1.Lines.Add('파일명을 입력하세요.');
AdvFileNameEdit2.SetFocus;
exit;
end;
try
try
ProgressBar1.Position := 0;
MP4In.FileName := AdvFileNameEdit1.Text;
AudioCache.Input := MP4In;
AudioConverter.Input := MP4In;
AudioConverter.OutBitsPerSample := strtoint((AdvComboBox2.Text));
AudioConverter.OutChannels := strtoint((AdvComboBox3.Text));
WaveOut.FileName := AdvFileNameEdit2.Text;
WaveOut.Input := MP4In;
WaveOut.BlockSize := strtoint(AdvEdit1.Text);
WaveOut.OnDone := FWaveOutDone;
WaveOut.OnProgress := FWaveOutProgress;
WaveOut.OnSyncDone := FWaveOutSyncDone;
WaveOut.OnThreadException := FWaveOutThreadException;
case AdvComboBox4.ItemIndex of
// wtUnsupported, wtPCM, wtDVIADPCM, wtMSADPCM, wtACM, wtIEEEFloat, wtExtPCM, wtExtIEEEFloat
0 :
begin
WavType := wtUnsupported;
end;
1 :
begin
WavType := wtPCM;
end;
2 :
begin
WavType := wtDVIADPCM;
end;
3 :
begin
WavType := wtMSADPCM;
end;
4 :
begin
WavType := wtACM;
end;
5 :
begin
WavType := wtIEEEFloat;
end;
6 :
begin
WavType := wtExtPCM;
end;
7 :
begin
WavType := wtExtIEEEFloat;
end;
end;
WaveOut.WavType := WavType;
WaveOut.Run;
//WaveOut.BlockingRun; // BlockingRun 사용시 FWaveOutDone, FWaveOutProgress 해당 이벤트 발생 안 함.
except
on E : Exception do
Memo1.Lines.Add(E.Message);
end;
finally
end;
end;
procedure TForm7.FormClose(Sender : TObject; var Action : TCloseAction);
begin
MP4In.DisposeOf;
WaveOut.DisposeOf;
AudioConverter.DisposeOf;
AudioCache.DisposeOf;
end;
procedure TForm7.FormCreate(Sender : TObject);
begin
MP4In := TMP4In.Create(self);
WaveOut := TWaveOut.Create(self);
AudioConverter := TAudioConverter.Create(self);
AudioCache := TAudioCache.Create(self);
end;
end.
(*
Class: TAACIn
This component can decode raw AAC files. It requires libfaad2p.dll.
The component is experimenatal and will probably not work for all types of AAC file.
Please send me samples of the files that it cannot play.
Descends from <TAuTaggedFileIn>.
Seeking isn't implemented yet.
*)
(*
Class: TMP4In
This component can decode AAC audio from M4A and MP4 files. It requires mp4ff.dll (derived from the faad package) and libfaad2p.dll.
Descends from <TAuTaggedFileIn>.
Exact positioning isn't implemented yet.
*)
'DELPHI(델파이)' 카테고리의 다른 글
[Delphi] Vcl.Themes 콤보박스로 설정 (0) | 2020.12.03 |
---|---|
[Delphi] 병렬 프로그래밍 (0) | 2020.12.03 |
[델파이 - DELPHI] SFTP Server Service (Devart SecureBridge) (0) | 2020.11.24 |
[델파이 - DELPHI] SFTP Client Class (Devart SecureBridge) (2) | 2020.11.24 |
[델파이 - DELPHI] HTTPS 서버 사용시 다른 포트 바인딩 주의점 (0) | 2020.11.24 |