Controlling voice modem with delphi

I want to write a small application to record a voice message via a phone using delphi 2 or 3 and a voice modem, very much like a simplified answering machine. Anyone know of components, info, code to do such a thing?
davegreenAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mivCommented:
Have the same problem, just signing for notification :-)
0
davegreenAuthor Commented:
Adjusted points to 400
0
KECommented:
I'll sugest that you find a COM component, and begin to study your modem manual for the commands to control the voice capabilities.
There are many good serial communication components, so this shouldn't be a problem. I'm afraid that the control sequences may vary on different modems.

I know that this might not be much of a help - anyway good luck!
0
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

mivCommented:
Maybe the TAPI spec. will help ?
(I think it´s a telephone API....?)
0
mirek071497Commented:
Hi
I see so probably no one know how to do this. This is very interesting problem so I try found something in the last days.
I found some.

1.Recording :
{ when i send this to modem then recording was started }
AT&F1
AT#CLS=8
AT#VLS=3
AT#VRX
{ i just working on data which is returned }

2.Playback :
{ after sending this commands }
AT&F1
AT#CLS=8
AT#VLS=3
AT#VTX
{ i can send data as voice }

However i just start working with this and this can end after some days, so do you waiting for more in this way or in other way ? :-)
0
davegreenAuthor Commented:
Thanks mirek, I was very interested in what you wrote. Whats the mechanism for getting voice data to/from a wave file?

There just seems no good information around on this problem :(

Example code would really be appreciated.

Thanks all,
0
itamarCommented:
I have interest in this question too...
0
mirek071497Commented:
Hi
The data wich came after AT#VRX or #VTX is in ADPCM (Adaptive Differential Pulse Code Modulation) I have now source in C to convert to and from Wav files, but there are some mistakes so i must spend some time on this.
I think so the code will be rather big
1.comm programming
2.modem programming
3.ADPCM coding

When i get this working I submit this to DSP but here I submit only the main idea of How To Do This.
0
davegreenAuthor Commented:
Thanks mirek, your help is appreciated - even after more days of searching I have come up blank on good information. I have increased the points because of it...

0
mirek071497Commented:
Hi I have now simple example how can you do this.

This is very trivial example especially in comm programming. Because I don't play with comm settings and don't resetting the modem sometimes this example can hangup. No worry. Choose Run-Terminate, wait a moment for modem reset and rerun example. You can travell in this way with voice modem programming. There are many commands for voice programming in many sities on internet (i have some description from rockwell).


This example records tone from line on the button1 and play this at the button2.


unit unEx1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Memo1: TMemo;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private {}
  public  {}
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

type
 TBaudRate = (cbr110, cbr300, cbr600, cbr1200, cbr2400, cbr4800,
               cbr9600, cbr14400, cbr19200, cbr38400, cbr56000,
               cbr57600, cbr115200, cbr128000, cbr256000);

const
  CBR: array[TBaudRate] of Integer =
    (CBR_110, CBR_300, CBR_600, CBR_1200, CBR_2400, CBR_4800, CBR_9600,
     CBR_14400, CBR_19200, CBR_38400, CBR_56000, CBR_57600, CBR_115200,
     CBR_128000, CBR_256000);

const
  TempFile : string = 'd:\tst.bin';
  ile   = 4;
  BufSize = 2048;

type
  buftype = array[0..BufSize-1] of byte;

var
  pHand : Integer; { handle to port }
  f     : file;
  buf   : array[0..ile] of BufType;

procedure Switch38400;
var
  FDCB: TDCB;
begin
  GetCommState( pHand, FDCB);
  FDCB.BaudRate := CBR[ cbr38400 ];
  SetCommState( pHand, FDCB);
end;

procedure OpenComm;
var
  Port  : String;
  Count : Longint;
  FCommConfig : TCommConfig;
begin
  Port := 'COM2';
  pHand := CreateFile( PCHar(Port), GENERIC_READ+GENERIC_WRITE, 0, nil,
                       OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
  if pHand=INVALID_HANDLE_VALUE then
  begin
    ShowMessage( 'INVALID HANDLE' );
    Halt;
  end;
  Count:= Sizeof(TCommConfig);
  GetCommConfig( pHand, FCommConfig, Count);
  SetCommConfig( pHand, FCommConfig, Count );
  {Switch38400;}
end;

procedure SendCOM( st : ShortString );
var
  st1   : string;
  Count : Longint;
  i,j   : integer;
begin
  st1 := st + #13;
  if WriteFile(pHand,st1[1],length(st1),Count,nil) then {Form1.Memo1.Lines.Add( st )};
  st1 := '.';
  if ReadFile(pHand,st1[1],1, Count,nil) then;
  i := 1;
  j := 0;
  repeat
    st1 := st1+'.';
    inc(i);
    if ReadFile(pHand,st1[i],1, Count,nil) then;
    if (st1[i-1]=#13) and (st1[i]=#10) then inc(j);
    Application.ProcessMessages;
  until j>1;
  for i:=1 to length(st1) do if (st1[i] in [#13,#10]) then st1[i]:= ' ';
  Form1.Memo1.Lines.Add( st1 );
end;

procedure TForm1.Button1Click(Sender: TObject);
var Count, i : Longint;
begin
  Fillchar( buf, sizeof(buf), 0 );
  AssignFile( f, TempFile );
  Rewrite( f,1); if IOResult<>0 then;
  OpenComm;
  SendCOM( 'AT&F1' );
  SendCOM( 'AT#CLS=8');
  SendCOM( 'AT#VSR=7200' );
  SendCOM( 'AT#VBS=4');
  SendCOM( 'AT#BDR=16');
  Switch38400;
  SendCOM( 'AT#VGT=220');
  SendCOM( 'AT#VLS=4'); { line and speaker }
  SendCOM( 'ATA' );
  SendCOM( 'AT#VRX');
  { load sound from modem }
  for i:=0 to ile do
  begin
    if ReadFile(pHand, buf[i], BufSize, Count,nil) then;
    Form1.Memo1.Lines.Add('readed '+IntToStr(Count));
  end;
  CloseHandle(pHand);
  { save sound to HD }
  for i:=0 to ile do
  begin
    BlockWrite( f, buf[i], BufSize, Count ); if IOResult<>0 then;
    Form1.Memo1.Lines.Add('saved '+IntToStr(Count));
  end;
  CloseFile( f );if IOResult<>0 then;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
 Count, i : Longint;
begin
  { read sound file from disk }
  AssignFile( f, TempFile );
  Reset( f,1); if IOResult<>0 then;
  for i:=0 to ile do
  begin
    BlockRead( f, buf[i], BufSize, Count ); if IOResult<>0 then;
    Form1.Memo1.Lines.Add('loaded from HD '+IntToStr(Count));
  end;
  CloseFile( f );if IOResult<>0 then;
  OpenComm;
  SendCOM( 'AT&F1' );
  SendCOM( 'AT#CLS=8');
  SendCOM( 'AT#VSR=7200' );
  SendCOM( 'AT#VBS=4');
  SendCOM( 'AT#BDR=16');
  Switch38400;
  SendCOM( 'AT#VGT=220');
  SendCOM( 'AT#VLS=2'); { only to speaker }
  SendCOM( 'AT#VTX');
  { play loaded sound }
  for i:=0 to ile do
  begin
    if WriteFile(pHand, buf[i], BufSize, Count,nil) then;
    Form1.Memo1.Lines.Add('played '+IntToStr(Count));
  end;
  CloseHandle(pHand);
end;

end.

If you need more help than submit a comment.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mirek071497Commented:
If you give me you'r mail i can send to you description from rockwell. This is in MS-Word format.
0
davegreenAuthor Commented:
Thank you Mirek for such an excellent and comprehensive answer. Good luck to you.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.