资源简介
Windows下局域网语音对讲程序 ,亲测可行。

代码片段和文件信息
// Sound_send.cpp : Defines the entry point for the console application.
//
#include “stdafx.h“
#include
#include
#include
#include
#include
#pragma comment(lib “ws2_32.lib“ )
#pragma comment(lib“Winmm.lib“)
#define MAXDATASIZE 10000
void readAudioBlock(HWAVEIN hWaveIn LPSTR block DWORD size);
int main(int argc char* argv[])
{
int iClientSock;
// int addr_len;
// int numbytes;
char buf[ MAXDATASIZE ];
struct sockaddr_in ClientAddr;
WSADATA WSAData;
if( WSAStartup( MAKEWORD( 2 2) &WSAData ) )
{
printf( “initializationing error!\n“ );
WSACleanup( );
exit( 0 );
}
iClientSock = socket( AF_INET SOCK_DGRAM 0 );
if( iClientSock == INVALID_SOCKET )
{
printf( “创建套接字失败!\n“ );
WSACleanup( );
exit( 0 );
}
ClientAddr.sin_family = AF_INET;
ClientAddr.sin_port = htons(4600);
ClientAddr.sin_addr.S_un.S_addr = inet_addr( “127.0.0.1“ );//记得换IP
memset( &( ClientAddr.sin_zero ) 0 sizeof( ClientAddr.sin_zero ) );
HWAVEIN hWaveIn; /* device handle */
WAVEFORMATEX wfx; /* look this up in your documentation */
// MMRESULT result;/* for waveOut return values */
/*
* first we need to set up the WAVEFORMATEX structure.
* the structure describes the format of the audio.
*/
wfx.nSamplesPerSec = 8000; /* sample rate */
wfx.wBitsPerSample = 16; /* sample size */
wfx.nChannels = 1; /* channels*/
/*
* WAVEFORMATEX also has other fields which need filling.
* as long as the three fields above are filled this should
* work for any PCM (pulse code modulation) format.
*/
wfx.cbSize = 0; /* size of _extra_ info */
wfx.wFormatTag = WAVE_FORMAT_PCM;
wfx.nBlockAlign = (wfx.wBitsPerSample >> 3) * wfx.nChannels;
wfx.nAvgBytesPerSec = wfx.nBlockAlign * wfx.nSamplesPerSec;
// try to open the default wave device.
if(waveInOpen(&hWaveIn WAVE_MAPPER &wfx 0 0 CALLBACK_NULL) !=MMSYSERR_NOERROR)
{
fprintf(stderr “unable to openWAVE_MAPPER device\n“);
ExitProcess(1);
}
while(1)
{
//numbytes = recvfrom( iServerSock buf MAXDATASIZE 0 ( struct sockaddr * ) & ServerAddr &addr_len );
// writeAudioBlock(hWaveOutbufnumbytes);
int t=sizeof(buf);
readAudioBlock(hWaveInbufsizeof(buf));
t=sizeof(buf);
int sendbytes=sendto(iClientSockbufsizeof(buf)0(sockaddr*)&ClientAddrsizeof(ClientAddr));
printf(“%d\t“sendbytes);
}
/*
* device is now open so print the success message
* and then close the device again.
*/
printf(“The Wave Mapper device was opened successfully!\n“);
// waveOutClose(hWaveIn);
return 0;
}
void readAudioBlock(HWAVEIN hWaveIn LPSTR block DWORD size)
{
WAVEHDR header;
/*
* initialize the block header with the size
* and pointer.
*/
ZeroMemory(&header sizeof(WAVEHDR));
header.dwBufferLength = size;
header.lpData = block;
/*
* prepare the block for playback
*/
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 1139712 2014-09-16 18:35 new_\发送\Debug\Sound_send.bsc
....... 172083 2014-09-17 08:39 new_\发送\Debug\Sound_send.exe
....... 207588 2014-09-17 08:39 new_\发送\Debug\Sound_send.ilk
....... 30168 2014-09-17 08:39 new_\发送\Debug\Sound_send.obj
....... 334800 2014-09-16 18:35 new_\发送\Debug\Sound_send.pch
....... 435200 2014-09-17 08:39 new_\发送\Debug\Sound_send.pdb
....... 505105 2014-09-16 18:36 new_\发送\Debug\Sound_send.sbr
....... 1828 2014-09-16 18:35 new_\发送\Debug\StdAfx.obj
....... 4003 2014-09-16 18:35 new_\发送\Debug\StdAfx.sbr
....... 99328 2014-09-17 08:39 new_\发送\Debug\vc60.idb
....... 143360 2014-09-17 08:39 new_\发送\Debug\vc60.pdb
....... 1232 2014-09-16 16:20 new_\发送\ReadMe.txt
....... 3674 2014-09-17 08:39 new_\发送\Sound_send.cpp
....... 4584 2014-09-16 16:20 new_\发送\Sound_send.dsp
....... 543 2014-09-16 16:20 new_\发送\Sound_send.dsw
....... 41984 2014-09-17 08:39 new_\发送\Sound_send.ncb
....... 107520 2014-09-17 08:31 new_\发送\Sound_send.opt
....... 0 2014-09-17 08:39 new_\发送\Sound_send.plg
....... 297 2014-09-16 16:20 new_\发送\StdAfx.cpp
....... 769 2014-09-16 16:20 new_\发送\StdAfx.h
....... 1147904 2014-09-16 16:14 new_\接收\Debug\Sound_win.bsc
....... 172081 2014-09-16 20:46 new_\接收\Debug\Sound_win.exe
....... 237144 2014-09-16 20:46 new_\接收\Debug\Sound_win.ilk
....... 29678 2014-09-16 20:46 new_\接收\Debug\Sound_win.obj
....... 334800 2014-09-16 16:14 new_\接收\Debug\Sound_win.pch
....... 435200 2014-09-16 20:46 new_\接收\Debug\Sound_win.pdb
....... 502071 2014-09-16 16:14 new_\接收\Debug\Sound_win.sbr
....... 1792 2014-09-16 16:14 new_\接收\Debug\StdAfx.obj
....... 4000 2014-09-16 16:14 new_\接收\Debug\StdAfx.sbr
....... 91136 2014-09-16 20:46 new_\接收\Debug\vc60.idb
............此处省略18个文件信息
- 上一篇:cyclone引脚定义
- 下一篇:波动方程有限差分模拟
相关资源
- Modbus协议官方文档中、英文全
- 语音信号处理 赵力
- ModelGoon-4.4.1-site.zip
- 信号奇异点Lipschitz指数计算
- vspd7.2.308.zip
- pthreads-w32-2-9-1-release.zip
- AE开发Windows最短路径分析
- Navicat Premium 15汉化包.zip55438
- 登录注册界面.zip48872
- 电信中兴光猫超密获取工具使用方法
- labview语音输入输出
-
Actionsc
ript 1.0实现能跟随鼠标运动的 - IAR-Keygen-2019+附使用教程.zip
-
st
yles 引文样式语言( CSL ) 引文样 -
Windows em
bedded Compact 2013 应用开发调 - Reparatory Effects of Nicotine on NMDA Recepto
- Apolipoprotein E4 Impairs in vivo Hippocampal
- flash as3 多点触控-缩放-旋转-滑动.zi
- 黑苹果硬件兼容检测和查询软件
- Quartus II 15.0中仿真Altera三速以太网I
- Quartus II 15.0中仿真Altera三速以太网I
-
imx6qSBP的jli
nk初始化脚本 - IMX385驱动代码.zip
- sony_imx385.zip
- Uninstall_Cortana_WINCLIENT.CN.rar
- 数字华容道
- jstl-api-1.2和jstl-impl-1.2
- 语音分帧,短时能量,过零率
- VMware65_SLP_DeLLSLIC2.1
- 基于MIPS指令集的32位CPU设计与Verilog语
评论
共有 条评论