Solved

Controlling voice modem with delphi

Posted on 1997-09-28
12
1,519 Views
Last Modified: 2012-06-21
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?
0
Comment
Question by:davegreen
  • 4
  • 4
  • 2
  • +2
12 Comments
 
LVL 1

Expert Comment

by:miv
ID: 1346397
Have the same problem, just signing for notification :-)
0
 

Author Comment

by:davegreen
ID: 1346398
Adjusted points to 400
0
 
LVL 3

Expert Comment

by:KE
ID: 1346399
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 1

Expert Comment

by:miv
ID: 1346400
Maybe the TAPI spec. will help ?
(I think it´s a telephone API....?)
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1346401
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
 

Author Comment

by:davegreen
ID: 1346402
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
 
LVL 4

Expert Comment

by:itamar
ID: 1346403
I have interest in this question too...
0
 
LVL 3

Expert Comment

by:mirek071497
ID: 1346404
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
 

Author Comment

by:davegreen
ID: 1346405
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
 
LVL 3

Accepted Solution

by:
mirek071497 earned 430 total points
ID: 1346406
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
 
LVL 3

Expert Comment

by:mirek071497
ID: 1346407
If you give me you'r mail i can send to you description from rockwell. This is in MS-Word format.
0
 

Author Comment

by:davegreen
ID: 1346408
Thank you Mirek for such an excellent and comprehensive answer. Good luck to you.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi TcxGrid group footer summary 3 316
Newbie Thread Programming 1 161
drawing animated level bar based on numbers 3 103
Base1 Encode/Decode 3 81
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question