资源简介
一个通过网络实现语音对讲的小程序,核心代码就500行左右,已在这个基础上实现了二次开发,在网络环境差的情况下语音会有延迟,杂音还可以接受,欢迎一起讨论

代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
namespace g711audio
{
///
/// Turns 8-bit A-law bytes back into 16-bit PCM values.
///
public static class ALawDecoder
{
///
/// An array where the index is the a-law input and the value is
/// the 16-bit PCM result.
///
private static short[] aLawToPcmMap;
static ALawDecoder()
{
aLawToPcmMap = new short[256];
for (byte i = 0; i < byte.MaxValue; i++)
aLawToPcmMap[i] = decode(i);
}
///
/// Decode one a-law byte. For internal use only.
///
/// The encoded a-law byte
/// A short containing the 16-bit result
private static short decode(byte alaw)
{
//Invert every other bit and the sign bit (0xD5 = 1101 0101)
alaw ^= 0xD5;
//Pull out the value of the sign bit
int sign = alaw & 0x80;
//Pull out and shift over the value of the exponent
int exponent = (alaw & 0x70) >> 4;
//Pull out the four bits of data
int data = alaw & 0x0f;
//Shift the data four bits to the left
data <<= 4;
//Add 8 to put the result in the middle of the range (like adding a half)
data += 8;
//If the exponent is not 0 then we know the four bits followed a 1
//and can thus add this implicit 1 with 0x100.
if (exponent != 0)
data += 0x100;
/* Shift the bits to where they need to be: left (exponent - 1) places
* Why (exponent - 1) ?
* 1 2 3 4 5 6 7 8 9 A B C D E F G
* . 7 6 5 4 3 2 1 . . . . . . . . <-- starting bit (based on exponent)
* . . . . . . . Z x x x x 1 0 0 0 <-- our data (Z is 0 only when exponent is 0)
* We need to move the one under the value of the exponent
* which means it must move (exponent - 1) times
* It also means shifting is unnecessary if exponent is 0 or 1.
*/
if (exponent > 1)
data <<= (exponent - 1);
return (short)(sign == 0 ? data : -data);
}
///
/// Decode one a-law byte
///
/// The encoded a-law byte
/// A short containing the 16-bit result
public static short ALawDecode(byte alaw)
{
return aLawToPcmMap[alaw];
}
///
/// Decode an array of a-law encoded bytes
///
/// An array of a-law encoded bytes
/// An array of shorts c
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4741 2006-07-28 08:57 VoiceChat\Backup\VoiceChat\ALawDecoder.cs
文件 6387 2006-07-28 09:03 VoiceChat\Backup\VoiceChat\ALawEncoder.cs
文件 5055 2006-07-28 08:57 VoiceChat\Backup\VoiceChat\MuLawDecoder.cs
文件 6493 2006-07-28 09:02 VoiceChat\Backup\VoiceChat\MuLawEncoder.cs
文件 480 2007-06-29 01:27 VoiceChat\Backup\VoiceChat\Program.cs
文件 1266 2007-06-29 01:18 VoiceChat\Backup\VoiceChat\Properties\AssemblyInfo.cs
文件 2845 2007-06-29 01:18 VoiceChat\Backup\VoiceChat\Properties\Resources.Designer.cs
文件 5612 2007-06-29 01:18 VoiceChat\Backup\VoiceChat\Properties\Resources.resx
文件 1092 2007-06-29 01:18 VoiceChat\Backup\VoiceChat\Properties\Settings.Designer.cs
文件 249 2007-06-29 01:18 VoiceChat\Backup\VoiceChat\Properties\Settings.settings
文件 21765 2007-07-03 22:55 VoiceChat\Backup\VoiceChat\VoiceChat.cs
文件 3661 2007-07-03 13:09 VoiceChat\Backup\VoiceChat\VoiceChat.csproj
文件 6309 2007-07-03 19:19 VoiceChat\Backup\VoiceChat\VoiceChat.Designer.cs
文件 5814 2007-07-03 19:19 VoiceChat\Backup\VoiceChat\VoiceChat.resx
文件 916 2007-06-29 01:18 VoiceChat\Backup\VoiceChat.sln
文件 178176 2005-03-18 16:23 VoiceChat\dll\Microsoft.DirectX.DirectSound.dll
文件 223232 2005-03-18 16:23 VoiceChat\dll\Microsoft.DirectX.dll
文件 30048 2017-12-15 21:20 VoiceChat\UpgradeLog.htm
文件 8976 2017-12-15 21:20 VoiceChat\UpgradeLog.xm
文件 4741 2006-07-28 08:57 VoiceChat\VoiceChat\ALawDecoder.cs
文件 6387 2006-07-28 09:03 VoiceChat\VoiceChat\ALawEncoder.cs
文件 178176 2005-03-18 16:23 VoiceChat\VoiceChat\bin\Debug\Microsoft.DirectX.DirectSound.dll
文件 223232 2005-03-18 16:23 VoiceChat\VoiceChat\bin\Debug\Microsoft.DirectX.dll
文件 20480 2017-12-15 21:23 VoiceChat\VoiceChat\bin\Debug\VoiceChat.exe
文件 50688 2017-12-15 21:23 VoiceChat\VoiceChat\bin\Debug\VoiceChat.pdb
文件 21464 2017-12-15 21:20 VoiceChat\VoiceChat\bin\Debug\VoiceChat.vshost.exe
文件 490 2012-06-06 02:06 VoiceChat\VoiceChat\bin\Debug\VoiceChat.vshost.exe.manifest
文件 5055 2006-07-28 08:57 VoiceChat\VoiceChat\MuLawDecoder.cs
文件 6493 2006-07-28 09:02 VoiceChat\VoiceChat\MuLawEncoder.cs
文件 789 2017-12-15 21:21 VoiceChat\VoiceChat\obj\Debug\DesignTimeResolveAssemblyReferences.cache
............此处省略44个文件信息
- 上一篇:C# 键盘记录 按键记录
- 下一篇:C# 中英文界面切换
相关资源
- C#解析HL7消息的库135797
- C# OCR数字识别实例,采用TessnetOcr,对
- 考试管理系统 - C#源码
- asp.net C#购物车源代码
- C#实时网络流量监听源码
- C#百度地图源码
- Visual C#.2010从入门到精通配套源程序
- Winform可视化打印模板设计工具含源码
- C# 软件版本更新
- C#屏幕软键盘源码,可以自己定制界面
- 智慧城市 智能家居 C# 源代码
- c#获取mobile手机的IMEI和IMSI
- C#实现简单QQ聊天程序
- 操作系统 模拟的 欢迎下载 C#版
- C#写的计算机性能监控程序
- 用C#实现邮件发送,有点类似于outlo
- MVC model层代码生成器 C#
- c#小型图书销售系统
- C# Socket Server Client 通讯应用 完整的服
- c# winform 自动登录 百度账户 源代码
- C#编写的16进制计算器
- C#TCP通信协议
- C# 数据表(Dataset)操作 合并 查询一
- C#语音识别系统speechsdk51,SpeechSDK51L
- 数据库备份还原工具1.0 C# 源码
-
[免费]xm
lDocument 节点遍历C# - EQ2008LEDc#开发实例
- DirectX.Capturec# winform 操作摄像头录像附
- c# 实现的最大最小距离方法对鸢尾花
- C#版保龄球记分代码
评论
共有 条评论