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

By , 31 Aug 2003
 

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
Member
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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionI cant debug solution!memberdiepa9k3920 Feb '12 - 21:27 
Help me!
i cant debug solution.Warning,Cant open "dsound.h" file.Help me
QuestionI need to develop a softphone to make calls to telephonememberRinosh_sasidharan6 Nov '11 - 7:37 
I need to develop a softphone to make calls to telephone my website users must be able to download this softphone and they should be able to call, and I need to track all the call information, and the customers balance and everything
the customers are able to get points in their account online,
 
Please help me I have searched a lot, and I could find some sourcecodes for softphone how can i develop a proxy application and, how can i communicate with them, do i need to keep this in a machine with public ip and i need to run this server application there
 
Please help
 
Regards
Rinosh
Generalvoip solutionmembersdfsdfsdfsdfdfgdf30 Sep '10 - 2:56 
I came across this SIP VOIP solution:
www.voipcore.com
 
Can anybody share experience using it?
QuestionXML data uploadmembernilukachapterzero6 Sep '10 - 23:24 
Hi
I am looking for any methods how to upload any XML data files into SQL specify table. If it is possible please let me know. Thanks
QuestionTesting this programmemberkurankar6 Dec '09 - 19:43 
Hello
 
I was searching for the VOIP program & came across your program.I downloaded it & installed FullDuplex on 2 seperate PC's for one i started in server mode other in client mode & on client i used 8bit 8KHz Duplex but i cannot hear my voice on server.
 

Can u please suggest me the steps to test your application.
 

Regards
Indrajeet
GeneralChange Waveform Standard [modified]membercun-cun10 Sep '09 - 16:49 
Hai friends,
 
I am new in multimedia programming like VOIP, but i have some exam about VOIP.
I change you code like this:
 
1.for wave standard:
        WAVEFORMATEX wfx;
	wfx.wFormatTag = WAVE_FORMAT_PCM;
	wfx.nSamplesPerSec = 44100;
	wfx.wBitsPerSample = 16;
	wfx.nChannels = 2;
	wfx.nBlockAlign = wfx.nChannels*(wfx.wBitsPerSample>>3);
	wfx.cbSize = 0;
	wfx.nAvgBytesPerSec = 176400;
2. Spesification vaiable
        byte audio_receive[11025];
	byte audio[44100];
        .
        .
        FillMemory(audio,44100,0);
        .
        .
        //In wave thread
        BYTE audio[11026];
	BYTE receive_audio[11026];
 

 
3. Protocol
m_sConnectSocket.Receive(audio_receive,11025);
 
But when i run your program, program is error.
I have been try debug error of your program but i cann't find the problem.
Can you explain this problem?
 
Thank you
 
modified on Tuesday, September 15, 2009 3:01 AM

GeneralRe:Voipmemberjomoal998 Sep '09 - 1:13 
For a complete idiot, if I want to learn about voip what do I do, I can use a computer, program in HTML and PHP. what are the very basics of Voip. I would be glad if some body would just make it simple..
General[Message Deleted]memberit.ragester28 Mar '09 - 5:34 
[Message Deleted]
Questionvoip securitymembershankaranarayanan.m17 Feb '09 - 15:39 
i need a voip security software with source code and also i need to access my voip with in my LAN network as an intercom can you suggest me some ideas
GeneralGreat KnowlagememberSIN123456785 Dec '08 - 22:42 
Smile | :) It's great.You knowledge is great.Can you tell me this program in vb.net.
Thanks.

GeneralReplacement For Skypememberedwardking5 Oct '08 - 13:29 
I'm feed up with the bad sound quality I experience when using skpye. Could I use your program to talk to someone across the internet? I know that if we are behind a router then we'll have to setup port forwarding etc (which is easy).
GeneralSIP Dialermembersdaeesh3 Oct '08 - 19:06 
Hi All,
 
I am new to the Windows mobile ,now I want to develope a "SIP Dialer" also having windows mobile 5.0,VS2005,win32 C++.
 
what are the developing tools? How to use VOIP? where can I start from visual studio?
 
Please anybody help me,If you have anyone please sugget to me and please give some sample code.
 
Is very urgent...
 
I am waiting for soon reply.... Sniff | :^)
GeneralCan't Download the filesmemberMember 259783720 Sep '08 - 8:25 
Dear,
I can't download the 2 files u have provided in your article. Can you please make them downloadable coz i believe that they are removed from the server.
 
Take care
GeneralDetect Voice and Echo CancellermemberMember 467834318 Jun '08 - 0:19 
I'm developing SIP Softphone. I'm have some deficulties in detecting voice and cancelling echo. Who can help me? please send to email: dongpd@cdit.com.vn. I'll have special gift for person who help me
Thanks
Generalneed help to apply AES with the applicationmemberquoc phong4 Jun '08 - 22:21 
Dear Petrov!
I am trying to apply security to VoIP application, this is my graduation project in university. I have spent a lot of time in SRTP and MIKEY theory so that i don't have enough time for building the application. Unfortunately, i am not good at programming. So can you do me a favour to help me include the AES block code to the this application. Thanks a lot.
I am looking forward to your reply.
Please contact me at qphongkdt@gmail.com.
 
Truly yours!
QuestionCan any one provide me a project with source codemembersanei0521 Mar '08 - 21:19 
hi friends,
 
I am planning to shift my job from networking to s/w domain with VC++ knowledge. I would like to have some live projects to include in VC++ and i need to get trained on that. If anyone know any training center where they provide live projects in VC++ and give some training located at bangalore, Please send me the details to my mail id sandeepeie@gmail.com.
 
Sandeep N R

AnswerRe: Can any one provide me a project with source codememberGeorgi Petrov22 Mar '08 - 6:58 
Hi what training do you like?
 
We can provide you such courses on VC++:
http://cisco-edu.com/index.php?lang=en[^]
 
Regards,
GeneralRe: Can any one provide me a project with source codemembersanei0522 Mar '08 - 18:43 
hi,
 
I would like to get training on specific live project where i can learn all the necessities of that projects. What the classes used in the project. I need to include in my resume about the project. I am interested in doing a project in VC++ MFC.
 

I know VC++ concepts. I need a training on a project specific. Please mail me with the details to my mail id sanei05@gmail.com
 
Thanks and regards
 
Sandeep N R

GeneralNeed code in VC++ for voice over ipmembersanei0521 Mar '08 - 21:08 
Hi,
 
I need stack development protocol of ITUT H323 standard for transmitting voice over data network. An IP Phone, which works on top of H323 protocol stack, need to be developed in OCX form as well as an applciation.
 
Can anyone help me on this.
 
Sandeep N R

Generalin symbianmemberadien16 Mar '08 - 14:44 
hi.. my name aldryn. i have some problem in my project about voip D'Oh! | :doh: .
can voip be operated in PDA with symbian OS.??? and how to program it ??
please help me... tanks
Generalneed code for VOIP in javamembersekarbright21 Sep '07 - 0:06 
i need a code for voice transmission over internet protocol implemented in java or atleast voice transmission between two systemsRose | [Rose] Rose | [Rose]
 
r.rajasekar
GeneralRequest for the projectmember<..???....>??///9 Jun '07 - 21:00 
I am an MCA student. I came across this link while searching a project on VoIP. I tried to run it on my PC, but errors occur. Some of them are:
fatal error LNK1104: cannot open file 'dsound.lib'
cannot find file 'afxwin.h'
I have to submit my academic project within a month.so plz send me the whole project and also how I can deal with the errors.

GeneralRe: Request for the projectmembermari ram26 Jun '07 - 18:38 
dear friend ,
i am also a member of codeproject.com....
i saw your request for voip project. i also have the same academic project to be submitted. i have already crossed my deadlineCry | :(( . so if you have got the code please forward to my mail id cmrnit@yahoo.co.in
GeneralRe: Request for the projectmember<..???....>??///29 Jun '07 - 0:01 
Dear friend,
 
I've succeeded in finding some code of the sort I wanted. Still some errors exist. If u r luking for a custom VoIP dailer, just look into www.vaxvoip.com there u'll find some sample codes. keep it as a base n develop ur version frm it.
QuestionSOSmembersweet chocolate22 Feb '07 - 3:44 
HI I am a new partner and I really need help because I am just begginer in programming C#
I tried to open Full duplex but I couldn't ,can anyone help and tell me step by step what should I do? thanks

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

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