WPF 按钮点击音效实现

WPF 按钮点击音效实现

下面我将为您提供一个完整的 WPF 按钮点击音效实现方案,包含多种实现方式和高级功能:

完整实现方案

MainWindow.xaml

<Window x:Class="ButtonClickSound.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:ButtonClickSound"mc:Ignorable="d"Title="按钮点击音效演示" Height="450" Width="800"WindowStartupLocation="CenterScreen"Background="#FF1E1E1E"><Window.Resources><!-- 音效资源 --><MediaPlayer x:Key="ClickSoundPlayer" Source="sounds/click.wav" Volume="0.7"/><MediaPlayer x:Key="HoverSoundPlayer" Source="sounds/hover.wav" Volume="0.5"/><!-- 按钮样式 --><Style x:Key="SoundButtonStyle" TargetType="Button"><Setter Property="Background" Value="#FF252526"/><Setter Property="Foreground" Value="White"/><Setter Property="BorderBrush" Value="#FF3F3F46"/><Setter Property="BorderThickness" Value="1"/><Setter Property="FontSize" Value="18"/><Setter Property="Padding" Value="20,10"/><Setter Property="Margin" Value="10"/><Setter Property="Cursor" Value="Hand"/><Setter Property="Template"><Setter.Value><ControlTemplate TargetType="Button"><Border x:Name="border" Background="{TemplateBinding Background}"BorderBrush="{TemplateBinding BorderBrush}"BorderThickness="{TemplateBinding BorderThickness}"CornerRadius="8"><ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"Margin="{TemplateBinding Padding}"/></Border><ControlTemplate.Triggers><Trigger Property="IsMouseOver" Value="True"><Setter Property="Background" Value="#FF3A80D2"/><Setter Property="BorderBrush" Value="#FF2A70C2"/></Trigger><Trigger Property="IsPressed" Value="True"><Setter Property="Background" Value="#FF2A70C2"/><Setter Property="BorderBrush" Value="#FF1A60B2"/></Trigger></ControlTemplate.Triggers></ControlTemplate></Setter.Value></Setter></Style></Window.Resources><Grid><Grid.RowDefinitions><RowDefinition Height="Auto"/><RowDefinition Height="*"/><RowDefinition Height="Auto"/></Grid.RowDefinitions><!-- 标题 --><TextBlock Text="按钮点击音效演示" Grid.Row="0"FontSize="28"FontWeight="Bold"Foreground="White"HorizontalAlignment="Center"Margin="0,20"/><!-- 按钮区域 --><Grid Grid.Row="1"><Grid.ColumnDefinitions><ColumnDefinition Width="*"/><ColumnDefinition Width="*"/></Grid.ColumnDefinitions><!-- 简单实现 --><StackPanel Grid.Column="0" VerticalAlignment="Center"HorizontalAlignment="Center"><TextBlock Text="简单实现" FontSize="20"Foreground="#AAAAAA"HorizontalAlignment="Center"Margin="0,0,0,20"/><!-- 直接绑定事件 --><Button Content="事件处理器" Style="{StaticResource SoundButtonStyle}"Click="ButtonWithEventHandler_Click"/><!-- 使用行为 --><Button Content="使用行为" Style="{StaticResource SoundButtonStyle}"local:SoundBehavior.ClickSound="{StaticResource ClickSoundPlayer}"/><!-- 使用命令 --><Button Content="使用命令" Style="{StaticResource SoundButtonStyle}"Command="{Binding PlaySoundCommand}"/></StackPanel><!-- 高级实现 --><StackPanel Grid.Column="1" VerticalAlignment="Center"HorizontalAlignment="Center"><TextBlock Text="高级实现" FontSize="20"Foreground="#AAAAAA"HorizontalAlignment="Center"Margin="0,0,0,20"/><!-- 悬停+点击音效 --><Button Content="悬停+点击音效" Style="{StaticResource SoundButtonStyle}"local:SoundBehavior.HoverSound="{StaticResource HoverSoundPlayer}"local:SoundBehavior.ClickSound="{StaticResource ClickSoundPlayer}"/><!-- 自定义音效 --><Button Content="自定义音效" Style="{StaticResource SoundButtonStyle}"local:SoundBehavior.ClickSound="{StaticResource ClickSoundPlayer}"Click="CustomSoundButton_Click"/><!-- 随机音效 --><Button Content="随机音效" Style="{StaticResource SoundButtonStyle}"Click="RandomSoundButton_Click"/></StackPanel></Grid><!-- 控制面板 --><Border Grid.Row="2"Background="#202020"CornerRadius="10"Padding="20"Margin="20"HorizontalAlignment="Center"><StackPanel Orientation="Horizontal" Spacing="20"><Button Content="播放点击音效" Style="{StaticResource SoundButtonStyle}"Click="PlaySound_Click"/><Button Content="停止所有音效" Style="{StaticResource SoundButtonStyle}"Click="StopAllSounds_Click"/><Button Content="切换静音模式" Style="{StaticResource SoundButtonStyle}"Click="ToggleMute_Click"/></StackPanel></Border></Grid>
</Window>

SoundBehavior.cs (音效行为类)

using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;namespace ButtonClickSound
{public static class SoundBehavior{#region ClickSound 附加属性public static MediaPlayer GetClickSound(DependencyObject obj){return (MediaPlayer)obj.GetValue(ClickSoundProperty);}public static void SetClickSound(DependencyObject obj, MediaPlayer value){obj.SetValue(ClickSoundProperty, value);}public static readonly DependencyProperty ClickSoundProperty =DependencyProperty.RegisterAttached("ClickSound", typeof(MediaPlayer), typeof(SoundBehavior), new PropertyMetadata(null, OnClickSoundChanged));private static void OnClickSoundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){if (d is Button button){button.Click -= Button_Click;if (e.NewValue != null){button.Click += Button_Click;}}}private static void Button_Click(object sender, RoutedEventArgs e){if (sender is Button button){var player = GetClickSound(button);if (player != null){player.Position = TimeSpan.Zero;player.Play();}}}#endregion#region HoverSound 附加属性public static MediaPlayer GetHoverSound(DependencyObject obj){return (MediaPlayer)obj.GetValue(HoverSoundProperty);}public static void SetHoverSound(DependencyObject obj, MediaPlayer value){obj.SetValue(HoverSoundProperty, value);}public static readonly DependencyProperty HoverSoundProperty =DependencyProperty.RegisterAttached("HoverSound", typeof(MediaPlayer), typeof(SoundBehavior), new PropertyMetadata(null, OnHoverSoundChanged));private static void OnHoverSoundChanged(DependencyObject d, DependencyPropertyChangedEventArgs e){if (d is Button button){button.MouseEnter -= Button_MouseEnter;if (e.NewValue != null){button.MouseEnter += Button_MouseEnter;}}}private static void Button_MouseEnter(object sender, MouseEventArgs e){if (sender is Button button){var player = GetHoverSound(button);if (player != null){player.Position = TimeSpan.Zero;player.Play();}}}#endregion}
}

MainWindow.xaml.cs

using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;namespace ButtonClickSound
{public partial class MainWindow : Window{// 全局音效播放器private MediaPlayer _globalClickPlayer = new MediaPlayer();// 随机音效列表private List<MediaPlayer> _randomSounds = new List<MediaPlayer>();private Random _random = new Random();// 静音状态private bool _isMuted = false;public ICommand PlaySoundCommand { get; }public MainWindow(){InitializeComponent();LoadSounds();// 初始化命令PlaySoundCommand = new RelayCommand(ExecutePlaySound);DataContext = this;}private void LoadSounds(){try{// 初始化全局点击音效_globalClickPlayer.Open(new Uri("sounds/click.wav", UriKind.Relative));_globalClickPlayer.Volume = 0.7;// 初始化随机音效_randomSounds.Add(CreateSoundPlayer("sounds/click1.wav", 0.7));_randomSounds.Add(CreateSoundPlayer("sounds/click2.wav", 0.6));_randomSounds.Add(CreateSoundPlayer("sounds/click3.wav", 0.8));_randomSounds.Add(CreateSoundPlayer("sounds/click4.wav", 0.5));}catch (Exception ex){MessageBox.Show($"加载音效失败: {ex.Message}", "错误", MessageBoxButton.OK, MessageBoxImage.Error);}}private MediaPlayer CreateSoundPlayer(string path, double volume){var player = new MediaPlayer();player.Open(new Uri(path, UriKind.Relative));player.Volume = volume;return player;}#region 简单实现方法// 方法1: 直接在事件处理器中播放音效private void ButtonWithEventHandler_Click(object sender, RoutedEventArgs e){PlayGlobalClickSound();}// 方法2: 使用命令播放音效private void ExecutePlaySound(){PlayGlobalClickSound();}#endregion#region 高级实现方法// 自定义音效按钮private void CustomSoundButton_Click(object sender, RoutedEventArgs e){// 创建临时音效播放器var player = new MediaPlayer();player.Open(new Uri("sounds/special_click.wav", UriKind.Relative));player.Volume = 0.8;player.Play();// 播放完成后自动释放资源player.MediaEnded += (s, args) => player.Close();}// 随机音效按钮private void RandomSoundButton_Click(object sender, RoutedEventArgs e){if (_randomSounds.Count == 0) return;int index = _random.Next(0, _randomSounds.Count);var player = _randomSounds[index];player.Position = TimeSpan.Zero;player.Play();}#endregion#region 控制面板方法private void PlaySound_Click(object sender, RoutedEventArgs e){PlayGlobalClickSound();}private void StopAllSounds_Click(object sender, RoutedEventArgs e){_globalClickPlayer.Stop();foreach (var player in _randomSounds){player.Stop();}}private void ToggleMute_Click(object sender, RoutedEventArgs e){_isMuted = !_isMuted;// 设置全局音量double volume = _isMuted ? 0.0 : 0.7;_globalClickPlayer.Volume = volume;foreach (var player in _randomSounds){player.Volume = volume;}// 更新按钮文本((Button)sender).Content = _isMuted ? "取消静音" : "切换静音模式";}#endregionprivate void PlayGlobalClickSound(){_globalClickPlayer.Position = TimeSpan.Zero;_globalClickPlayer.Play();}}// 命令实现public class RelayCommand : ICommand{private readonly Action _execute;private readonly Func<bool> _canExecute;public event EventHandler CanExecuteChanged{add { CommandManager.RequerySuggested += value; }remove { CommandManager.RequerySuggested -= value; }}public RelayCommand(Action execute, Func<bool> canExecute = null){_execute = execute ?? throw new ArgumentNullException(nameof(execute));_canExecute = canExecute;}public bool CanExecute(object parameter) => _canExecute?.Invoke() ?? true;public void Execute(object parameter) => _execute();}
}

实现方法详解

1. 简单实现方法

方法1: 直接在事件处理器中播放音效
private void ButtonWithEventHandler_Click(object sender, RoutedEventArgs e)
{// 创建或使用全局播放器var player = new MediaPlayer();player.Open(new Uri("sounds/click.wav", UriKind.Relative));player.Play();// 或者使用全局播放器_globalClickPlayer.Position = TimeSpan.Zero;_globalClickPlayer.Play();
}
方法2: 使用附加行为
<Button Content="使用行为" local:SoundBehavior.ClickSound="{StaticResource ClickSoundPlayer}"/>

2. 高级实现方法

悬停+点击音效组合
<Button Content="悬停+点击音效" local:SoundBehavior.HoverSound="{StaticResource HoverSoundPlayer}"local:SoundBehavior.ClickSound="{StaticResource ClickSoundPlayer}"/>
自定义音效
private void CustomSoundButton_Click(object sender, RoutedEventArgs e)
{// 创建临时音效播放器var player = new MediaPlayer();player.Open(new Uri("sounds/special_click.wav", UriKind.Relative));player.Play();// 播放完成后自动释放资源player.MediaEnded += (s, args) => player.Close();
}
随机音效
private void RandomSoundButton_Click(object sender, RoutedEventArgs e)
{if (_randomSounds.Count == 0) return;int index = _random.Next(0, _randomSounds.Count);var player = _randomSounds[index];player.Position = TimeSpan.Zero;player.Play();
}

3. 使用命令实现

public ICommand PlaySoundCommand { get; }public MainWindow()
{PlaySoundCommand = new RelayCommand(ExecutePlaySound);
}private void ExecutePlaySound()
{PlayGlobalClickSound();
}// XAML
<Button Content="使用命令" Command="{Binding PlaySoundCommand}"/>

高级功能实现

1. 音效管理

// 全局音效管理器
public static class SoundManager
{private static readonly Dictionary<string, MediaPlayer> _sounds = new Dictionary<string, MediaPlayer>();private static double _globalVolume = 0.7;private static bool _isMuted = false;public static void LoadSound(string name, string path, double volume = 1.0){if (_sounds.ContainsKey(name)) return;var player = new MediaPlayer();player.Open(new Uri(path, UriKind.Relative));player.Volume = volume * _globalVolume;_sounds[name] = player;}public static void PlaySound(string name){if (_isMuted || !_sounds.TryGetValue(name, out var player)) return;player.Position = TimeSpan.Zero;player.Play();}public static void SetGlobalVolume(double volume){_globalVolume = volume;foreach (var player in _sounds.Values){player.Volume = volume;}}public static void SetMute(bool isMuted){_isMuted = isMuted;}
}// 使用
SoundManager.LoadSound("click", "sounds/click.wav", 0.7);
SoundManager.PlaySound("click");

2. 3D音效效果

private void PlayPositionalSound(Point position)
{// 计算相对于窗口中心的位置double centerX = ActualWidth / 2;double centerY = ActualHeight / 2;// 计算相对位置 (-1 到 1)double relX = (position.X - centerX) / centerX;double relY = (position.Y - centerY) / centerY;// 创建音效播放器var player = new MediaPlayer();player.Open(new Uri("sounds/click.wav", UriKind.Relative));// 应用平衡效果 (左右声道)player.Balance = Math.Clamp(relX, -1.0, 1.0);// 应用音量衰减double distance = Math.Sqrt(relX * relX + relY * relY);player.Volume = Math.Clamp(1.0 - distance * 0.5, 0.2, 1.0);player.Play();
}

3. 音效池系统

public class SoundPool
{private readonly List<MediaPlayer> _players = new List<MediaPlayer>();private readonly string _soundPath;private readonly double _volume;private int _currentIndex = 0;public SoundPool(string soundPath, int poolSize = 5, double volume = 1.0){_soundPath = soundPath;_volume = volume;// 初始化播放器池for (int i = 0; i < poolSize; i++){var player = new MediaPlayer();player.Open(new Uri(soundPath, UriKind.Relative));player.Volume = volume;_players.Add(player);}}public void Play(){// 选择下一个播放器var player = _players[_currentIndex];// 重置位置player.Position = TimeSpan.Zero;player.Play();// 移动到下一个播放器_currentIndex = (_currentIndex + 1) % _players.Count;}
}// 使用
private SoundPool _clickSoundPool = new SoundPool("sounds/click.wav", 5, 0.7);private void Button_Click(object sender, RoutedEventArgs e)
{_clickSoundPool.Play();
}

专业建议

1. 音效文件处理

  • 使用16位PCM WAV格式以获得最佳兼容性
  • 保持音效文件短小(通常小于500ms)
  • 使用44.1kHz采样率
  • 预加载常用音效以减少延迟

2. 性能优化

// 预加载音效
private void PreloadSounds()
{// 使用后台线程预加载Task.Run(() =>{var player = new MediaPlayer();player.Open(new Uri("sounds/click.wav", UriKind.Relative));// 预读到内存player.Play();player.Pause();player.Position = TimeSpan.Zero;});
}// 使用NAudio进行低延迟播放
private void PlayLowLatencySound(string path)
{using (var audioFile = new AudioFileReader(path))using (var outputDevice = new WaveOutEvent()){outputDevice.Init(audioFile);outputDevice.Play();}
}

3. 无障碍支持

// 检查用户是否启用了声音
private bool IsSoundEnabled()
{// 检查系统设置bool systemSoundEnabled = SystemParameters.ClientAudioPlayback;// 检查用户偏好bool userPreference = Properties.Settings.Default.SoundEnabled;return systemSoundEnabled && userPreference;
}// 提供视觉反馈替代
private void PlaySoundWithVisualFeedback()
{if (IsSoundEnabled()){PlayGlobalClickSound();}else{// 提供视觉反馈var button = sender as Button;var originalBrush = button.Background;button.Background = Brushes.Gray;// 短暂延迟后恢复Task.Delay(100).ContinueWith(_ => {Dispatcher.Invoke(() => button.Background = originalBrush);});}
}

这个实现提供了多种按钮点击音效的实现方式,从简单的直接事件处理到高级的音效管理系统和3D音效效果。您可以根据项目需求选择合适的实现方法,

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.pswp.cn/diannao/84952.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

C++ list基础概念、list初始化、list赋值操作、list大小操作、list数据插入

list基础概念&#xff1a;list中的每一部分是一个Node&#xff0c;由三部分组成&#xff1a;val、next、prev&#xff08;指向上一个节点的指针&#xff09; list初始化的代码&#xff0c;见下 #include<iostream> #include<list>using namespace std;void printL…

【Pandas】pandas DataFrame equals

Pandas2.2 DataFrame Reindexing selection label manipulation 方法描述DataFrame.add_prefix(prefix[, axis])用于在 DataFrame 的行标签或列标签前添加指定前缀的方法DataFrame.add_suffix(suffix[, axis])用于在 DataFrame 的行标签或列标签后添加指定后缀的方法DataFram…

【ROS2】创建单独的launch包

【ROS】郭老二博文之:ROS目录 1、简述 项目中,可以创建单独的launch包来管理所有的节点启动 2、示例 1)创建launch包(python) ros2 pkg create --build-type ament_python laoer_launch --license Apache-2.02)创建启动文件 先创建目录:launch 在目录中创建文件:r…

GitHub 趋势日报 (2025年05月23日)

本日报由 TrendForge 系统生成 https://trendforge.devlive.org/ &#x1f310; 本日报中的项目描述已自动翻译为中文 &#x1f4c8; 今日整体趋势 Top 10 排名项目名称项目描述今日获星总星数语言1All-Hands-AI/OpenHands&#x1f64c;开放式&#xff1a;少代码&#xff0c;做…

鸿蒙OSUniApp 实现的数据可视化图表组件#三方框架 #Uniapp

UniApp 实现的数据可视化图表组件 前言 在移动互联网时代&#xff0c;数据可视化已成为产品展示和决策分析的重要手段。无论是运营后台、健康监测、还是电商分析&#xff0c;图表组件都能让数据一目了然。UniApp 作为一款优秀的跨平台开发框架&#xff0c;支持在鸿蒙&#xf…

[ctfshow web入门] web124

信息收集 error_reporting(0); //听说你很喜欢数学&#xff0c;不知道你是否爱它胜过爱flag if(!isset($_GET[c])){show_source(__FILE__); }else{//例子 c20-1$content $_GET[c];// 长度不允许超过80个字符if (strlen($content) > 80) {die("太长了不会算");}/…

Vue 技术文档

一、引言 Vue 是一款用于构建用户界面的渐进式 JavaScript 框架&#xff0c;具有易上手、高性能、灵活等特点&#xff0c;能够帮助开发者快速开发出响应式的单页面应用。本技术文档旨在全面介绍 Vue 的相关技术知识&#xff0c;为开发人员提供参考和指导。 二、环境搭建 2.1…

Nodejs+http-server 使用 http-server 快速搭建本地图片访问服务

在开发过程中&#xff0c;我们经常需要临时查看或分享本地的图片资源&#xff0c;比如设计稿、截图、素材等。虽然可以通过压缩发送&#xff0c;但效率不高。本文将教你使用 Node.js 的一个轻量级工具 —— http-server&#xff0c;快速搭建一个本地 HTTP 图片预览服务&#xf…

通义智文开源QwenLong-L1: 迈向长上下文大推理模型的强化学习

&#x1f389; 动态 2025年5月26日: &#x1f525; 我们正式发布&#x1f917;QwenLong-L1-32B——首个采用强化学习训练、专攻长文本推理的LRM模型。在七项长文本文档问答基准测试中&#xff0c;QwenLong-L1-32B性能超越OpenAI-o3-mini和Qwen3-235B-A22B等旗舰LRM&#xff0c…

学习如何设计大规模系统,为系统设计面试做准备!

前言 在当今快速发展的技术时代&#xff0c;系统设计能力已成为衡量一名软件工程师专业素养的重要标尺。随着云计算、大数据、人工智能等领域的兴起&#xff0c;构建高性能、可扩展且稳定的系统已成为企业成功的关键。然而&#xff0c;对于许多工程师而言&#xff0c;如何有效…

Python生成ppt(python-pptx)N问N答(如何绘制一个没有背景的矩形框;如何绘制一个没有背景的矩形框)

文章目录 [toc]1. **如何安装python-pptx库&#xff1f;**2. **如何创建一个空白PPT文件&#xff1f;**3. **如何添加幻灯片并设置布局&#xff1f;**4. **如何添加文本内容&#xff1f;**5. **如何插入图片&#xff1f;**6. **如何设置动画和转场效果&#xff1f;**9. **如何绘…

命令模式,观察者模式,状态模式,享元模式

什么是命令模式&#xff1f; 核心思想是将原本直接调用的方法封装为对象&#xff08;如AttackCommand&#xff09;&#xff0c;对象包含​​执行逻辑​​和​​上下文信息​​&#xff08;如目标、参数&#xff09;。比如&#xff0c;玩家的按键操作被封装成一个命令对象&#…

Window Server 2019--07 PKI、SSL网站与邮件安全

了解PKI、SSL技术的核心原理掌握PKI架构服务器配置掌握证书管理与应用 公钥基础设施&#xff08;Public Key Infrastructure&#xff0c;PKI&#xff09;是一个完整的颁发、吊销、管理数字证书的系统&#xff0c;是支持认证、加密、完整性和可追究性服务的基础设施。PKI通过第…

从C++编程入手设计模式2——工厂模式

从C编程入手设计模式 工厂模式 ​ 我们马上就要迎来我们的第二个创建型设计模式&#xff1a;工厂方法模式&#xff08;Factory Method Pattern&#xff09;。换而言之&#xff0c;我们希望使用一个这样的接口&#xff0c;使用其他手段而不是直接创建的方式&#xff08;说的有…

MySQL、PostgreSQL、Oracle 区别详解

MySQL、PostgreSQL、Oracle 区别详解 一、基础架构对比 1.1 数据库类型 MySQL:关系型数据库(支持NoSQL插件如MySQL Document Store)PostgreSQL:对象-关系型数据库(支持JSON等半结构化数据)Oracle:多模型数据库(关系型+文档+图+空间等)关键结论:PostgreSQL在数据类型…

window11系统 使用GO语言建立TDengine 连接

目录 1、安装GCC、TDengine-client 1、github下载mingw64 软件包 2、解压指定目录、配置环境变量 3、检验gcc是否安装成功 4、安装TDengine-client 2、配置go环境变量 3、配置Goland 系统变量、重启Goland&#xff08;该软件自己也有系统变量&#xff0c;有时候会和win…

VR 赋能病毒分离鉴定:开启微观探索新视界

在大众认知里&#xff0c;VR 技术往往与沉浸式游戏体验、虚拟社交紧密相连&#xff0c;让人仿佛置身于奇幻的虚拟世界中&#xff0c;感受着科技带来的奇妙娱乐享受。而病毒分离鉴定&#xff0c;听起来则是一个充满专业性与严肃性的科学领域&#xff0c;它关乎病毒的研究、疾病的…

Azure Devops pipeline 技巧和最佳实践

1. 如何显示release pipeline ? 解决方法: 登录devops, 找到organization - pipeline - setting下的Disable creation of classic release pipelines,禁用该选项。 然后在project - pipeline - setting,禁用Disable creation of classic release pipelines 现在可以看到r…

GPU的通信技术

GPU 之间直接通信主要采用了以下几种技术1&#xff1a; GPUDirect P2P&#xff1a;NVIDIA 开发的技术&#xff0c;用于单机上的 GPU 间高速通信。在没有该技术时&#xff0c;GPU 间数据交换需先通过 CPU 和 PCIe 总线复制到主机固定的共享内存&#xff0c;再复制到目标 GPU&…

重新测试deepseek Jakarta EE 10编程能力

听说deepseek做了一个小更新&#xff0c;我重新测试了一下Jakarta EE 10编程能力&#xff1b;有点进步&#xff0c;遗漏的功能比以前少了。 采用Jakarta EE 10 编写员工信息表维护表&#xff0c;包括员工查询与搜索、员工列表、新增员工、删除员工&#xff0c;修改员工&#xf…