语音聊天实现(Delphi)

Delphi简单TCP聊天程序(二):双向传输 在上一篇文章中,我们并没有实现服务器端发送数据到客户端,主要原因是Delphi 7自带的Indy控件存在Bug,所以我们首先需要将其升级为Indy 10,可在这里下载到。   由于IdTCPClient没有onExecute事件,所以我们要自己监听,新建一个线程来做这个就再好不 阅读详情


语音聊天实现
没有通过Acm控件的,比较长,有兴趣的可以看一下,还有通过UDP的聊天功能。

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, NMUDP, CheckLst,winsock, ElTree,ElHeader,ShellAPI, ExtCtrls,
  ComCtrls,MMSystem,Msacm, ElXPThemedControl;

type
  TForm1 = class(TForm)
    udp_Send: TNMUDP;
    Panel1: TPanel;
    Panel2: TPanel;
    btn_Send: TButton;
    Label1: TLabel;
    edt_Words: TEdit;
    tim_Timer: TTimer;
    rih_Words: TRichEdit;
    Button1: TButton;
    Button2: TButton;
    elt_Online: TElTree;
    procedure udp_SendDataReceived(Sender: TComponent; NumberBytes: Integer;FromIP: String; Port: Integer);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure elt_OnlineHeaderColumnDraw(Sender: TCustomElHeader;Section: TElHeaderSection; R: TRect; Pressed: Boolean);
    procedure btn_SendClick(Sender: TObject);
    procedure tim_TimerTimer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    procedure WndProc(var Msg:TMessage);override;
    procedure SendWords(SendMan,ReceiveMan,Word:String;RemoteIP:String);
    Function  GetHostIP(HostName:String=''):String;
    Function  ReturnPos(buf:TMemoryStream;Len,StartPos:Integer;Separator:Char):Integer;
    procedure DisplayWords(SendMan,ReceiveMan,Word:String);
    procedure UserLogin(UserName,IP:String;RemoteIP:String='');
    procedure UserLogout(UserName,IP:String);
    function  AddNextBuffer():Integer;
    function  InitWaveInHeader():Integer;
    function  QueueNextBuffer : Integer;
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

type TACMWAVEFORMAT=packed record
case Integer of
  0:(Format:twaveformatex);
  1:(Rawdata:array[0..128] of byte);
end;

const
  iBufferBlock=2040;
  oBufferLen=6;
var
  sHostIP,P_UserName,sBroadIP:String;
  nTickCount:DWord;
  NIM_Data:NOTIFYICONDATAA;
  bShowIcon,bPlayFlag:Boolean;
  iMsgCount,iBufIndex,iInputPoint,iPlayPoint:Integer;
  iHdr:Array [0..1] of WAVEHDR;
  iBuf:Array [0..1] of pChar;
  oBuf:Array [1..oBufferLen] of pChar;
  oHdr:Array [1..oBufferLen] of WAVEHDR;
  WaveFmt:TACMWAVEFORMAT;
  HOut:HWaveOut;
  HIn:HWAVEIN;

{$R *.DFM}
{$R msg.res}

 

procedure TForm1.udp_SendDataReceived(Sender: TComponent;NumberBytes: Integer; FromIP: String; Port: Integer);
var
   sUserName,sSendMan,sReceiveMan,sIP,sWord:String;
   iMsgType,iPos,i,iTmpPos:Integer;
   Node:TEltreeItem;
   mBuf:TMemoryStream;
   FindHandle, ResHandle: THandle;
   ResPtr: Pointer;
begin
   if Trim(FromIP)=sHostIP then
      Exit;

   mBuf := TMemoryStream.Create();
   mBuf.SetSize(NumberBytes);
   mBuf.Clear;
   udp_Send.ReadStream(mBuf);
   if (pchar(mBuf.Memory)^=#02) and (pchar(Longint(mBuf.Memory)+1)^=#03) then
      iMsgType := ord(pchar(Longint(mBuf.Memory)+2)^)
   else
   begin
      mBuf.Free;
      Exit;
   end;

   sUserName := '';
   case iMsgType of
      1:              //登录
      begin
        iPos := ReturnPos(mBuf,NumberBytes,4,#$1f);
        sUserName := copy(PChar(mBuf.Memory),4,iPos-4);
        sIP  := copy(PChar(mBuf.Memory),iPos+1,ReturnPos(mBuf,NumberBytes,iPos+1,#$1f)-iPos-1);
        for i:=0 to elt_Online.Items.Count-1 do
        begin
           Node := elt_Online.Items[i];
           if (strcomp(PChar(sUserName),PChar(Node.Text))=0)
              and (strcomp(PChar(sIP),PChar(Node.ColumnText[0]))=0) then
           begin
              mBuf.Free;
              Exit;
           end;
        end;
        Node := elt_Online.Items.Add(nil,sUserName);
        Node.ShowCheckBox := True;
        Node.ColumnText.Add(sIP);

        waveInStop(hIn);
        for i:=1 to 3 do
            UserLogin(p_UserName,sHostIP,sIP);
        waveInStart(hIn);
      end;
      2:              //退出
      begin
        iPos := ReturnPos(mBuf,NumberBytes,4,#$1f);
        sUserName := copy(PChar(mBuf.Memory),4,iPos-4);
        sIP  := copy(PChar(mBuf.Memory),iPos+1,ReturnPos(mBuf,NumberBytes,iPos+1,#$1f)-iPos-1);
        for i:=0 to elt_Online.Items.Count-1 do
        begin
           Node := elt_Online.Items[i];
           if (strcomp(PChar(sUserName),PChar(Node.Text))=0)
              and (strcomp(PChar(sIP),PChar(Node.ColumnText[0]))=0) then
           begin
              mBuf.Free;
              Node.Delete;
              Exit;
 

delphi实现音频传输  语音聊天在今天是一个很普通的话题,小厮写了一段音频采集、网络传输和播放的程序,实现和简单的语音聊天,但是语音信息没有经过很好的压缩,所以,在局域网外,由于网速问题,效果可能不会很理想下面我们切入正题。小厮使用的是ACM组件,ACMWaveOut——播放ACMWaveIn——采集ACMDialog——音频格式设置客户端:定义一个开始按钮,设置 阅读详情

相关推荐

Delphi语言的人工智能

Delphi是一种基于Object Pascal的编程语言,其最大特点是快速应用程序开发(RAD)和强大的可视化界面设计能力。Delphi为开发者提供了丰富的库和框架,使得开发高效、可维护的软件变得更加简单。在过去的几十年中,Delphi在桌面应用、数据库管理和企业应用等领域得到了广泛应用。

2501_90406420的博客 684

Delphi实现高质量点对点语音聊天系统源码解析

Delphi是一种强类型、编译型语言,它综合了快速开发的特性以及对底层系统调用的高效支持。Delphi的开发环境被称为Embarcadero RAD Studio,为开发者提供了丰富的组件库和可视化的开发工具。P2P(Peer-to-Peer,点对点)技术最初起源于文件共享应用,如Napster,用于音乐文件的分布式共享。这种技术打破了传统的客户端-服务器(Client-Server)模型的限制,允许每个节点既是请求信息的客户端,也是提供服务的服务器。

weixin_30598047的博客 1107

Delphi实现的P2P高质量语音聊天应用源码解析

随着即时通讯应用的普及,点对点(P2P)语音聊天应用已经成为人们沟通的重要工具。Delphi作为一款优秀的开发工具,提供了强大的P2P通信能力。本章将为读者提供Delphi点对点语音聊天应用的全面介绍,涵盖应用目的、所需技术栈以及开发流程概述。在开发Delphi点对点语音聊天应用时,首先需要设计合适的P2P网络架构以确保数据能够高效传输。接下来,需要选择合适的音频编解码技术以保证语音的质量和流畅性。最后,还需要对应用进行性能优化和安全性增强,以满足不同用户的使用需求。

weixin_42514750的博客 737

delphi 简易聊天

基于delphi 实现 简单QQ聊天工具,有源码。

完美acm语音delphi开发控件demo

完美acm语音delphi开发控件demo

delphi ACM语音组件for 2010源码

ACM组件, ACMWaveOut——播放 ACMWaveIn——采集 ACMDialog——音频格式设置 for delphi2010 d14

Delphi TCP控件做的聊天软件服务器与客户端

利用Delphi的indy server和indy client 中的TCP控件实现的聊天软件。 服务器和同一网关下的所有的客户端进行通信,实现各个客户端之间的聊天功能和文件传送功能。界面简单美观,功能稳定。

acm.rar_ACM 语音_ACM控件_acm delphi_delphi6_录音 播放

完美acm语音(audio)delphi开发控件: znACM ver5.1 完美的封装了微软的 acm 语音相关的函数,用于语音采集(录音),语音播放,使用简单(10分钟学会使用),可控制性强,容易扩展。 从使用角度出发,切合程序制作者的实际需要,解决了一般商用语音控件没有解决的问题。 真正好用的acm控件。适合delphi5 delphi6 delphi7

Delphi 12.3控件之Delphi点对点高质量语音聊天源码.zip

Delphi 12.3控件之Delphi点对点高质量语音聊天源码.zip

Unity通用Buff系统,Buff编辑器(1,理论篇)(技能系统之Buff篇)

逻辑层根据游戏的规则和设计,控制Buff的生命周期、影响目标对象的属性或行为,以及处理Buff的交互和冲突。Buff堆叠和冲突:有些游戏中允许同类型的Buff叠加,以增加效果的强度,而有些游戏中可能不允许Buff叠加,只能由更强力的Buff来覆盖较弱的Buff。灵活个性化:每个游戏对象拥有自己的BuffManager,可以实现个体对象的独特Buff效果,增加游戏的多样性和个性化。自由控制:每个对象独立管理自己的Buff,可以自由地激活、更新和移除Buff效果,提供更精细的控制和逻辑实现。

u010082265的博客 4698

【UE4】PMC程序化生成戈德堡多面体详解(六边形星球)

游戏实机录屏 【魔方超新星】30天独立开发PCG Minigame《盖亚计划》作品展示,尚有不足,大佬轻喷 目录 游戏实机录屏 一、简介 二、设计思路 2.1 Disco Ball 2.2 Fibonacci Sphere 2.3 Goldberg Polyhedron 2.3.1 细分+对偶(最终方案) 2.3.2 对偶+截角(更优) 三、参考文献 一、简介 在制作Minigame初期,游戏风格想模仿《文明6》与《Polygonal Planet Proje...

ColorGalaxy 5940

COMSOL电磁仿真-网格剖分-边界层

介绍COMSOL在低频电磁场中边界层网格的剖分方法。

奇妙水果的技术博客,欢迎交流技术~ 4506

YOLOv11 网络结构详解:一文看懂 Backbone、Head、C3k2、SPPF 和 Detect 检测头

在使用 YOLOv11 进行目标检测时,我们经常会接触到或这样的模型配置文件。backbone和head分别是什么意思?ConvC3k2SPPFC2PSA这些模块分别起什么作用?P3/8、P4/16、P5/32 代表什么?为什么最后 Detect 要同时接收 3 个不同尺度的特征图?YOLOv11n、YOLOv11s、YOLOv11m、YOLOv11l、YOLOv11x 的区别在哪里?

learnerYC的博客 1850

TMS320F280049C 学习笔记4 Led_ex1_blinky 初始化函数及系统时钟

承接上一篇学习笔记,这次开始实际运行例程。本文概述了280049C的第一个实验 Led灯闪烁。同时也总结了系统的初始化函数和时钟配置。

whyorwhnt的专栏 7037

STM32F407通过SMBus协议精准读取BQ40Z50电池电量

本文详细介绍了STM32F407通过SMBus协议精准读取BQ40Z50电池电量的实现方法。从硬件连接到软件驱动开发,再到通信异常排查,提供了完整的解决方案。重点解析了SMBus协议的特殊时序要求、GPIO模拟驱动的关键代码,以及实际调试中的常见问题与对策,帮助开发者高效完成电池管理系统开发。

weixin_29189003的博客 255

26 硬件工程师笔面试高频考点真题解析——CAN总线

CAN总线是一种差分多主串行半双工总线,采用非破坏性位仲裁机制和五层硬件错误检测(位错误、填充错误、CRC校验、格式错误、应答错误),具有高可靠性和故障容错能力。关键设计包括两端120Ω终端电阻匹配阻抗、手拉手总线拓扑、显性/隐性电平优先级仲裁。常见故障分析指出多节点异常多因终端电阻错配/漏装、星型布线违规或总线过载;高速通讯失败常由阻抗失配或线缆过长导致信号反射。相比RS485,CAN支持多主架构、硬件自动仲裁和节点故障隔离,更适用于汽车、工业等高可靠场景。

XU157303764的博客 568

Coze工作流的代码无法安装第三方模块(依赖)怎么办?(如何解决Coze工作流代码缺少模块(依赖)的问题)

Coze工作流的代码无法安装第三方模块(依赖)怎么办?(如何解决Coze工作流代码缺少模块(依赖)的问题)

XiaoqiangClub的博客 4373

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

上一篇: Socket编程原理(个人学习ing)
下一篇: 什么是Socket
formiss
博客等级 码龄21年 138粉丝 140原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值