⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 codecapp.pas

📁 Voice Commnucation Components for Delphi
💻 PAS
字号:

(*
	----------------------------------------------

	  codecApp.pas
	  Voice Communicator components version 2.5
	  Audio Tools - MS ACM codec application

	----------------------------------------------
	  This source code cannot be used without
	  proper permission granted to you as a private
	  person or an entity by the Lake of Soft, Ltd

	  Visit http://lakeofsoft.com/ for details.

	  Copyright (c) 2001, 2005 Lake of Soft, Ltd
		     All rights reserved
	----------------------------------------------

	  created by:
		Lake, 01 Nov 2001

	  modified by:
		Lake, Mar-Jun 2002
		Lake, Jun 2003
		Lake, Oct 2005

	----------------------------------------------
*)

{$I unaDef.inc}

unit
  codecApp;

interface

uses
  Windows, MMSystem,
  unaTypes, unaUtils, unaClasses, unavcApp,
  unaMsAcmClasses;

type
  unaCodecApp = class(unaVCApplication)
  private
    f_acm: unaMsAcm;
  protected
    function init(): bool; override;
    procedure feedback(); override;
  public
    destructor destroy(); override;
  end;

implementation


{ unaCodecApp }

// --  --
destructor unaCodecApp.destroy();
begin
  inherited;
  //
  f_acm.free();
end;

// --  --
procedure unaCodecApp.feedback();
var
  str: string;
begin
  str := 'Codec: [in ' + int2Str(device.inBytes, 10, 3) + ']  [out ' + int2Str(device.outBytes, 10, 3) + ']'#13;
{$IFDEF CONSOLE }
  write(str);
{$ELSE}
  infoMessage(str);
{$ENDIF}
end;

// --  --
function unaCodecApp.init(): bool;
var
  driver: unaMsAcmDriver;
  //
  mid: word;
  pid: word;
  in_tag: unsigned;
  in_index: unsigned;
  in_file: string;
  //
  out_tag: unsigned;
  out_index: unsigned;
  out_file: string;
  //
  back: bool;
  pc: unsigned;
begin
  result := inherited init();
  if (result) then begin
{$IFDEF CONSOLE}
{$ELSE}
    formatLabel.show(SW_HIDE);
    chooseButton.show(SW_HIDE);
{$ENDIF}
    //
    pc := 0;
    back := (hasSwitch('back') or hasSwitch('rev'));
    if (back) then
      infoMessage(' * reverse-encode mode is ON'#13#10);
    if (back) then
      inc(pc);
    //
    if (hasSwitch('enum')) then begin
      //
      infoMessage('Please use the acmEnum application to enum the ACM drivers and formats.'#13#10);
      result := false;
    end
    else begin
      //
      ini.section := 'driver';
      mid := ini.get('mid', unsigned(1));
      pid := ini.get('pid', unsigned(36));

      if (back) then
	ini.setSection('out-format')
      else
	ini.setSection('in-format');
      //
      in_tag := ini.get('tag', choice(back, unsigned(49), 1));
      in_index := ini.get('index', choice(back, unsigned(3), 7));

      if (back) then
	ini.setSection('in-format')
      else
	ini.setSection('out-format');
      //
      out_tag := ini.get('tag', choice(back, unsigned(1), unsigned(49)));
      out_index := ini.get('index', choice(back, unsigned(7), 3));

      ini.setSection('data');
      if (back) then begin
	out_file := ini.get('in_file', 'rec_buf.dat');
	in_file := ini.get('out_file', 'out_buf.dat');
      end
      else begin
	in_file := ini.get('in_file', 'rec_buf.dat');
	out_file := ini.get('out_file', 'out_buf.dat');
      end;

      if (integer(pc) < paramCount) then begin
	in_file := paramStr(pc + 1);
	if (1 < paramCount) then
	  out_file := paramStr(pc + 2);
      end
      else
	if (1 > pc) then
	  infoMessage('Syntax: codec [/rev | /back] [in_file [out_file]] [/enum]'#13#10);

      //
      f_acm := unaMsAcm.create();
      f_acm.enumDrivers();
      driver := f_acm.getDriver(mid, pid);
      if (nil <> driver) then begin
        //
	device := unaMsAcmCodec.create(driver, false);
	//
	unaMsAcmCodec(device).setFormatIndex(true, in_tag, in_index);
	unaMsAcmCodec(device).setFormatIndex(false, out_tag, out_index);
	//
	unaFileStream(device.assignStream(unaFileStream, true)).initStream(in_file, GENERIC_READ);
	with (unaFileStream(device.assignStream(unaFileStream, false))) do begin
	  //
	  initStream(out_file, GENERIC_WRITE);
	  clear();
	end;
	//
	infoMessage('----------------------------------------');
	infoMessage('driver     : ' + driver.getDetails().szShortName);
	infoMessage('in-format  : ' + device.srcFormatInfo);
	infoMessage('out-format : ' + device.dstFormatInfo);
        //
	assert(assertLog('chunk size : ' + int2Str(device.chunkSize)));
	//
	infoMessage('');
	infoMessage('in_file  : ' + in_file);
	infoMessage('out_file : ' + out_file);
	infoMessage('----------------------------------------'#13#10);
      end
      else begin
	infoMessage('Unable to find the driver for mid=' + int2Str(mid) + ', pid=' + int2Str(pid) + '.');
	result := false;
      end;
    end;
  end;

{$IFNDEF CONSOLE}
  if (result and (0 < ParamCount)) then
    doStart();
{$ENDIF}
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -