SAEA.Audio 26.4.22.2

dotnet add package SAEA.Audio --version 26.4.22.2
                    
NuGet\Install-Package SAEA.Audio -Version 26.4.22.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SAEA.Audio" Version="26.4.22.2">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SAEA.Audio" Version="26.4.22.2" />
                    
Directory.Packages.props
<PackageReference Include="SAEA.Audio">
  <PrivateAssets>all</PrivateAssets>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SAEA.Audio --version 26.4.22.2
                    
#r "nuget: SAEA.Audio, 26.4.22.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SAEA.Audio@26.4.22.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SAEA.Audio&version=26.4.22.2
                    
Install as a Cake Addin
#tool nuget:?package=SAEA.Audio&version=26.4.22.2
                    
Install as a Cake Tool

SAEA.Audio.Net - 实时语音通信组件

简介

SAEA.Audio.Net 是一个基于 .NET 的实时语音通信库,支持多人语音通话。采用 UDP 协议传输,集成 NAudio 音频引擎,支持 Speex、G.722、G.711 等多种音频编解码格式,适用于语音聊天、会议系统、客服对话等场景。

特性

  • 实时语音采集与播放 - NAudio 音频引擎
  • 多格式音频编解码 - Speex/G.722/G.711/GSM 等
  • UDP 实时传输 - 低延迟语音传输
  • 频道管理 - 用户邀请、加入频道、多人语音
  • 质量可配置 - 低/中/高三种语音质量
  • IOCP 高性能 - 基于 SAEA.Sockets

核心类

类名 说明
AudioServer<T> 语音服务器
AudioClient 语音客户端
TransferServer<T> UDP 传输服务器
TransferClient UDP 传输客户端
AudioCapture 音频捕获器
AudioPlayer 音频播放器
INetworkChatCodec 编解码器接口

音频编解码器

编解码器 格式 采样率 质量
NarrowBandSpeexCodec Speex 窄带 8kHz
WideBandSpeexCodec Speex 宽带 16kHz
UltraWideBandSpeexCodec Speex 超宽带 32kHz
G722ChatCodec G.722 16kHz
ALawChatCodec G.711 A-law 8kHz
MuLawChatCodec G.711 Mu-law 8kHz
Gsm610ChatCodec GSM 6.10 8kHz
UncompressedPcmChatCodec PCM 无压缩 8kHz 最高

快速使用

语音服务器

using SAEA.Audio.Net;

// 创建语音服务器
var server = new AudioServer<VStorage>(port: 39656);

server.OnInvited += (sender, args) => 
{
    Console.WriteLine($"用户 {args.FromID} 邀请 {args.ToID} 通话");
};

server.OnJoined += (channel, userId) => 
{
    Console.WriteLine($"用户 {userId} 加入频道 {channel}");
};

server.OnQuit += (channel, userId) => 
{
    Console.WriteLine($"用户 {userId} 离开频道 {channel}");
};

// 启动服务器
server.Start();

Console.WriteLine("语音服务器已启动,端口: 39656");

语音客户端

using SAEA.Audio.Net;
using SAEA.Audio.Net.Core;

// 创建语音客户端(默认使用宽带 Speex)
var client = new AudioClient(ip: "127.0.0.1", port: 39656);

// 选择编解码器
client.SetCodec(new WideBandSpeexCodec());  // 中等质量

// 注册事件
client.OnInvited += (info) => 
{
    Console.WriteLine($"收到通话邀请: 来自 {info.FromID}");
    // 可以选择同意或拒绝
    client.Agree(info.FromID);
};

client.OnAgreed += (info) => 
{
    Console.WriteLine($"通话已建立,加入频道 {info.Channel}");
};

client.OnDisagreed += (info) => 
{
    Console.WriteLine("通话邀请被拒绝");
};

client.OnJoined += (info) => 
{
    Console.WriteLine("已加入语音频道");
};

// 连接服务器
client.Connect();

发起通话邀请

using SAEA.Audio.Net;

var client = new AudioClient("127.0.0.1", 39656);
client.Connect();

// 邀请用户通话
client.Invite("user_002");

// 等待对方同意...
// 同意后双方自动加入同一频道,开始语音通话

接受/拒绝邀请

// 接受邀请
client.OnInvited += (info) => 
{
    client.Agree(info.FromID);  // 同意通话
};

// 拒绝邀请
client.OnInvited += (info) => 
{
    client.Disagree(info.FromID);  // 拒绝通话
};

加入/退出频道

// 加入指定频道(多人语音)
client.Join("meeting_room");

// 退出频道
client.Quit();

选择语音质量

using SAEA.Audio.Net.Core;

// 低质量(节省带宽)
client.SetCodec(new NarrowBandSpeexCodec());

// 中等质量(默认)
client.SetCodec(new WideBandSpeexCodec());

// 高质量(需要更多带宽)
client.SetCodec(new UltraWideBandSpeexCodec());

// 无压缩 PCM(最高质量,带宽最大)
client.SetCodec(new UncompressedPcmChatCodec());

// G.722 宽带编码
client.SetCodec(new G722ChatCodec());

// G.711 A-law(电话质量)
client.SetCodec(new ALawChatCodec());

自定义存储实现

using SAEA.Audio.Net.Model;

// 实现 IStorage 接口自定义频道用户映射
public class MyStorage : IStorage
{
    private Dictionary<string, List<string>> _channels = new();

    public void Add(string channel, string userId)
    {
        if (!_channels.ContainsKey(channel))
            _channels[channel] = new List<string>();
        _channels[channel].Add(userId);
    }

    public void Remove(string channel, string userId)
    {
        if (_channels.ContainsKey(channel))
            _channels[channel].Remove(userId);
    }

    public List<string> GetUsers(string channel)
    {
        return _channels.ContainsKey(channel) ? _channels[channel] : new List<string>();
    }
}

// 使用自定义存储
var server = new AudioServer<MyStorage>(39656);

传输协议类型

public enum ProtocalType
{
    Ping/Pong,     // 心跳检测
    Invite,        // 邀请通话
    Agree,         // 同意通话
    Disagree,      // 拒绝通话
    Join,          // 加入频道
    Data,          // 音频数据传输
    Quit           // 退出频道
}

传输架构

AudioClient
├── AudioCapture (麦克风采集 → 编码)
├── TransferClient (UDP 发送)
└── AudioPlayer (解码 → 播放)

UDP Protocol

AudioServer
├── TransferServer (UDP 接收 → 转发)
└── VStorage (频道-用户映射)

应用场景

  • 语音聊天 - 一对一语音通话
  • 会议系统 - 多人语音会议
  • 客服对话 - 客服语音系统
  • 游戏语音 - 游戏实时语音
  • 教学平台 - 在线语音教学

依赖项

项目 说明
SAEA.Sockets IOCP 通信框架
SAEA.Common 公共工具类
NAudio Windows 音频引擎(内置)
NSpeex Speex 编解码(内置)

注意事项

  • 本项目基于 .NET Framework 4.6.2
  • NAudio 仅支持 Windows 平台
  • 需要麦克风和扬声器设备

更多资源

许可证

Apache License 2.0

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on SAEA.Audio:

Repository Stars
yswenli/GFF
GFF is a imitation QQ communication project, based on high IOCP. GFF是模仿QQ通讯项目,通信基于SAEA.MessageSocket、SAEA.Http、SAEA.MVC实现
Version Downloads Last Updated
26.4.22.2 119 4/22/2026
26.4.22.1 114 4/21/2026
7.0.0.3 939 2/27/2022
7.0.0.2 623 2/27/2022
6.2.6.9 635 9/19/2021
6.2.6.2 616 4/17/2021
6.2.6.1 583 4/17/2021
6.1.2.5 583 2/22/2021
6.1.2.4 524 2/22/2021
6.1.2.3 555 2/21/2021
6.1.2.2 521 2/17/2021

SAEA.Audio.Net 是SAEA项目中的语音处理的项目