Post by code on Jan 10, 2021 10:20:47 GMT
///
Note :(edit:) programs/codes could be wrong/not working.
///
Hello,
Years ago i tried to make some voip program... it worked a bit.
If you wanna try such a thing , then its maybe intresting to look
at the code below(C++)
2 programs :
v.exe (capture sample) in rec.data file
vplay.exe opens rec.data and plays the sample.
code(C++) v.exe :
code(C++) vplay.exe :
v.exe (152.03 KB)vplay.exe (516.04 KB)
Note :(edit:) programs/codes could be wrong/not working.
///
Hello,
Years ago i tried to make some voip program... it worked a bit.
If you wanna try such a thing , then its maybe intresting to look
at the code below(C++)
2 programs :
v.exe (capture sample) in rec.data file
vplay.exe opens rec.data and plays the sample.
code(C++) v.exe :
#include "stdafx.h"
#include "windows.h"
#include <stdio.h>
#include <vfw.h>
#include <conio.h>
#include <process.h>
#include <winsock.h>
#include <mmsystem.h>
int main(int argc, char* vari1)
{
#define TV_VAR 0x1000
BYTE b9[TV_VAR];
MMRESULT m;
GSM610WAVEFORMAT g;
WAVEHDR *w;
WAVEHDR *w2;
WAVEFORMATEX wf;
HWAVEIN hw={0};
HWAVEOUT hout={0};
HMIXER hm;
WAVEINCAPS caps;
WAVEOUTCAPS caps2;
UINT ui;
int r;
wf.nSamplesPerSec=8000;
wf.wBitsPerSample=8;
wf.nChannels=1;
wf.wFormatTag=WAVE_FORMAT_PCM;
wf.nBlockAlign=wf.nChannels*(wf.wBitsPerSample/8);
wf.nAvgBytesPerSec= wf.nSamplesPerSec * wf.nBlockAlign;
wf.cbSize=0;
m=waveInOpen(&hw,WAVE_MAPPER,&wf,(DWORD)NULL,(DWORD)NULL,NULL);
m=waveOutOpen(&hout,WAVE_MAPPER,&wf,(DWORD)NULL,(DWORD)NULL,NULL);
w=(WAVEHDR*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(WAVEHDR));
w->lpData=(char*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,TV_VAR);
w->lpData=(char*)(b9);
w->dwBufferLength=TV_VAR;
w->dwFlags = 0;
r=waveInPrepareHeader(hw,w,sizeof(WAVEHDR));
r=waveInAddBuffer(hw,w,sizeof(WAVEHDR));
r=waveInStart(hw);
Sleep(20);
r=waveInStop(hw);
strcpy(vari1,(char*)(b9));
FILE * fd;
fd = fopen ("rec.data","w");
if (fd!=NULL)
{
fputs (vari1,fd);
fclose (fd);
}
return *vari1;
// return 0;
}
code(C++) vplay.exe :
#include "stdafx.h"
#include "windows.h"
#include <stdio.h>
#include <vfw.h>
#include <conio.h>
#include <process.h>
#include <winsock.h>
#include <mmsystem.h>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(int argc, char* b6)
{
//extern "C" int __cdecl test(char* b6){
string dl;
ifstream af ("rec.data");
if (af.is_open()){
while ( getline (af,dl) )
{
cout << dl << '\n';
}
af.close();
}
#define TV_VAR2 0x1000
BYTE b4[TV_VAR2];
MMRESULT m;
GSM610WAVEFORMAT g;
WAVEHDR *w;
WAVEHDR *w2;
WAVEFORMATEX wf;
HWAVEIN hw={0};
HWAVEOUT hout={0};
HMIXER hm;
WAVEINCAPS caps;
WAVEOUTCAPS caps2;
UINT ui;
int r;
wf.nSamplesPerSec=8000;
wf.wBitsPerSample=8;
wf.nChannels=1;
wf.wFormatTag=WAVE_FORMAT_PCM;
wf.nBlockAlign=wf.nChannels*(wf.wBitsPerSample/8);
wf.nAvgBytesPerSec= wf.nSamplesPerSec * wf.nBlockAlign;;
wf.cbSize=0;
w2=(WAVEHDR*)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(WAVEHDR));
w2->dwBufferLength= TV_VAR2;
//w2->lpData=(char*)(b6);
w2->lpData=(char*)dl.c_str();
r=waveInStop(hw);
r=waveOutPause(hout);
r=::waveOutGetDevCaps(ui,&caps2,sizeof(caps2));
r=waveOutOpen(&hout,WAVE_MAPPER,&wf,(DWORD)NULL,(DWORD)NULL,NULL);
r=waveOutPrepareHeader(hout,w2,sizeof(WAVEHDR));
r=waveOutWrite(hout,w2,sizeof(WAVEHDR));
r=waveOutRestart(hout);
return *b6;
//return 0;
}
v.exe (152.03 KB)vplay.exe (516.04 KB)