Click here to Skip to main content
Click here to Skip to main content

VoIP For You - Full duplex 8bit/8KHz VoIP application for Windows98 & DirectX

, 31 Aug 2003
Rate this:
Please Sign up or sign in to vote.
Sending and receiving voice under TCP/IP and Windows 98 & Direct X.

Introduction

Hi friends, this is my second article in Code Project. Therefore, I’ll try to make it better.

The application is Windows 98.SE tested. When using Direct Sound objects, don’t forget to include in your application the following libs in your project settings - link:

  • dsound.lib
  • dxguid.lib
  • winmm.lib

It is very fashionable to talk about VoIP – Voice Over IP, but many of my friends think that this is too difficult to understand, how to urge? Therefore, I’ll try to explain VoIP from my side.

To make a commercial VoIP application is too difficult. For many of us, it is good to use some programs to talk in home networks with friends. Before starting to build a VoIP application, it was 2 years behind, I scraped with two main problems:

  • First – how to program network applications via TCP/IP?
  • Second – how to record and play waveform audio on my PC?

First problem was very easy to decide – read “Visual C++ 6” book published by SAMS. To solve the second problem, I encountered with hard to understand Windows Sound Programming. In the beginning, I started to read BIG BOOKS how to program DMA – Direct Memory Access and sound card direct programming using in/out ports, but soon I detected that this kind of programming is a very thankless job and I started to search additional ways to solve the problem. This is easily called Direct Sound. (DMA programming is a good choice, but only if you are programming device drivers or when programming on Assembler.)

Let me explain how I did it.

First, assume you and some of your friends have a need to talk inside a private network. This is easily to test applications at home network. Remember one! To develop and test network applications, there is no need to have a real Internet or TCP/IP WAN network. You can use “loopback” server with IP address 127.0.0.1 and some of the free ports between 3000 and 5000. (Before this, install TCP/IP protocols on your machine – using Start button, Control Panel, Networks and add new protocol – Microsoft TCP/IP.)

The main program is a full duplex 8KHz 8bit recording and playing waveform audio application that can send and receive captured audio data via Internet connection. In real conditions, to test the program, you must install and start 2 copies of this program on 2 different PCs in your network. One of these two programs must be set to work as a server, and another program must be set to work as a client. Start the server program to listen for network events and then activate another program to work as a client and try to connect with the first one (server). To make a connection, you must know the IP address, or name and port of the computer where the server program was started. If the IP and port are not the same as the IP and port of the server program, there will not be a connection.

When 2 programs are connected, you can use “8bit 8KHz DUPLEX” button to start recording and receiving the audio data from another computer. When you want to stop the recording and playing process, press the “Stop DUPLEX” button.

If you have no TCP/IP network at home, you can test the software using the second application. An echo receiver and transmitter program works as echo server that can be started on the same PC. In this case, you can connect your VoIP application to an already started echo server using IP -127.0.0.1 address and port 4000. Now, click on “8bit 8KHz DUPLEX” button and start to talk on the microphone, you will listen your voice echo on the headphones. You can make some experiments with this echo server even if you plan to test the program on a working TCP/IP network. This is a good choice, think about that, in some cases there will be difficulty to tell somebody to speak all day “1,2,3 check”.

Conclusions

VoIP program is working. In some cases, there will be problem with full duplex working regime. To start the program, you need a PCI full duplex sound card and DirectX installed on your PC. Software was tested on Windows 98 (CPU AMD 300MHz, 64MB RAM) machine with ALS4000 sound card and DirectX 8. There may be a problem to start the program on NT/2000 – these operating systems do not support 8KHz, 8bit Mono Full Duplex audio recording and playing without a proper DirectX version.

About software “FULL_DUPLEX”

Program contains 3 main classes: FULL_DUPLEX.dlg, CmySocket and Duplex.

First and the main class is Dlg class. CmySocket class takes care about network communications and Duplex class operates with waveform audio.

Duplex creates a streaming 1-second playing and recording audio buffer using functions HRESULT Duplex::CreateOutputBuffer() and HRESULT Duplex::SetBufferFormats(). This 1 second is divided by 15 different segments, and for each segment is specified NotificationEvent. So when the recording process comes to the next position in audio buffer, front segment can be read or written from the main program. This is done by thread UINT WaitThreadProc( LPVOID param ) in the FULL_DUPLEX.dlg class. Each time when WaitThreadProc detects that there are some audio data ready to be send via network, this function activates dlg->SendAudio(audio,lenght);. If there are some data to be written in audio buffer this is done using CopyMemory(receive_audio,dlg->audio_receive,500);. If there are no received data from network connection, we fill the playing buffer with silence using FillMemory(audio,500,128);. That is all.

Future features can be added later, so they will provide DSP – Digital Signal Processing techniques on the input and output audio signals, differential compression and decompression and noise filtering using low pass filters. This simple compression algorithm can provide effective decreasing in data transmitting rate from 8Kbits/s to 3.2Kbits/s.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Georgi Petrov
Instructor / Trainer
Bulgaria Bulgaria
PhD, Cum Laude in digital automation systems
M.S. in Telemommunication management
B.S. in Telecommunication systems engineering
Programming: CUDA, C/C++, VHDL
Software and Hardware development and consulting:
data acquisition, image processing, medical instrumentation

Comments and Discussions

 
GeneralMy vote of 3 PinmemberMic6-Aug-13 14:29 
QuestionI cant debug solution! Pinmemberdiepa9k3920-Feb-12 21:27 
QuestionI need to develop a softphone to make calls to telephone PinmemberRinosh_sasidharan6-Nov-11 7:37 
Generalvoip solution Pinmembersdfsdfsdfsdfdfgdf30-Sep-10 2:56 
QuestionXML data upload Pinmembernilukachapterzero6-Sep-10 23:24 
QuestionTesting this program Pinmemberkurankar6-Dec-09 19:43 
GeneralChange Waveform Standard [modified] Pinmembercun-cun10-Sep-09 16:49 
GeneralRe:Voip Pinmemberjomoal998-Sep-09 1:13 
General[Message Deleted] Pinmemberit.ragester28-Mar-09 5:34 
Questionvoip security Pinmembershankaranarayanan.m17-Feb-09 15:39 
GeneralGreat Knowlage PinmemberSIN123456785-Dec-08 22:42 
GeneralReplacement For Skype Pinmemberedwardking5-Oct-08 13:29 
GeneralSIP Dialer Pinmembersdaeesh3-Oct-08 19:06 
GeneralCan't Download the files PinmemberMember 259783720-Sep-08 8:25 
GeneralDetect Voice and Echo Canceller PinmemberMember 467834318-Jun-08 0:19 
Generalneed help to apply AES with the application Pinmemberquoc phong4-Jun-08 22:21 
QuestionCan any one provide me a project with source code Pinmembersanei0521-Mar-08 21:19 
AnswerRe: Can any one provide me a project with source code PinmemberGeorgi Petrov22-Mar-08 6:58 
GeneralRe: Can any one provide me a project with source code Pinmembersanei0522-Mar-08 18:43 
GeneralNeed code in VC++ for voice over ip Pinmembersanei0521-Mar-08 21:08 
Generalin symbian Pinmemberadien16-Mar-08 14:44 
Generalneed code for VOIP in java Pinmembersekarbright21-Sep-07 0:06 
GeneralRequest for the project Pinmember<..???....>??///9-Jun-07 21:00 
GeneralRe: Request for the project Pinmembermari ram26-Jun-07 18:38 
GeneralRe: Request for the project Pinmember<..???....>??///29-Jun-07 0:01 
QuestionSOS Pinmembersweet chocolate22-Feb-07 3:44 
Questionabout implementation of voip: urgent PinmemberAnand_NIST15-Feb-07 20:22 
QuestionDSP Pinmembersidzpalz7-Feb-07 22:43 
AnswerRe: DSP PinmemberGeorgi Petrov7-Feb-07 22:54 
Generali have a error. Pinmemberakashgana14-Jan-07 0:48 
GeneralRe: i have a error. Pinmembersubhashv9-May-07 8:08 
Generalplease help [modified] Pinmemberakashgana13-Jan-07 23:00 
GeneralCustom VOIP PinmemberHatem Mostafa13-Jan-07 3:26 
QuestionA dll release?? PinmemberMega Byte3-Jan-07 20:07 
AnswerRe: A dll release?? PinmemberGeorgi Petrov3-Jan-07 20:36 
GeneralTry This Example TAPI3 Audio Conference PinmemberFadi Abdelqader , www.fadidotnet.org6-Jan-07 15:44 
GeneralVOIP Implementation in .NET (C# Code) PinmemberFadi Abdelqader , www.fadidotnet.org20-Dec-06 11:30 
GeneralRe: VOIP Implementation in .NET (C# Code) PinmemberGeorgi Petrov20-Dec-06 11:48 
GeneralRe: VOIP Implementation in .NET (C# Code) PinmemberFadi Abdelqader , www.fadidotnet.org25-Dec-06 2:07 
GeneralRe: VOIP Implementation in .NET (C# Code) Pinmemberdaluu15-May-07 13:47 
Fadi,
 
Thanks for sharing this useful info. Do you have anything on SIP protocol?
 

 
"A good scientist is a person with original ideas. A good engineer is a person who makes a design that works with as few original ideas as possible." - Freeman Dyson

Generalurgent Pinmembersdfrtghj14-Nov-06 10:14 
QuestionAre you sure? PinmemberVuNic4-Jul-06 1:13 
AnswerRe: Are you sure? PinmemberGeorgi Petrov4-Jul-06 4:39 
GeneralRe: Are you sure? PinmemberGeorgi Petrov27-Nov-06 23:28 
General- PinmemberReema Arke7-Apr-06 6:20 
GeneralRe: about the dsound.h file missing PinmemberWilliam.Zhang15-Mar-07 18:56 
GeneralRe: about the dsound.h file missing Pinmemberakashgana14-Jan-07 1:02 
GeneralControl Information PinmemberMRAAX20-Dec-05 5:42 
Generaldirectex PinmemberMRAAX15-Dec-05 20:57 
GeneralSimial App in C# PinmemberNiallC18-Nov-05 12:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 1 Sep 2003
Article Copyright 2003 by Georgi Petrov
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid