Solved

Controlling voice modem with delphi

Posted on 1997-09-28
12
1,490 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
Comment Utility
Have the same problem, just signing for notification :-)
0
 

Author Comment

by:davegreen
Comment Utility
Adjusted points to 400
0
 
LVL 3

Expert Comment

by:KE
Comment Utility
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
 
LVL 1

Expert Comment

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

Expert Comment

by:mirek071497
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 4

Expert Comment

by:itamar
Comment Utility
I have interest in this question too...
0
 
LVL 3

Expert Comment

by:mirek071497
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thank you Mirek for such an excellent and comprehensive answer. Good luck to you.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now