虚拟实验室-Unreal 版本

虚拟实验室的Unreal 版本,第一个版本主要是以《探究通电螺线管外部的磁场分布》颗粒为例,设计和开发一个正式版本。


基础能力--音频播放

<p>[TOC]</p> <table> <thead> <tr> <th>作者</th> <th>范丽民(969618)</th> </tr> </thead> <tbody> <tr> <td>更新日期</td> <td>2024-7-24</td> </tr> <tr> <td>版本</td> <td>V1.0.0</td> </tr> </tbody> </table> <h1>组件说明</h1> <p>播放音效和背景音乐,以及音频捕获并分析最大音量和平均音量 背景音默认会循环播放 统一在“Content/VLabUE/Audio/” 目录下存放声音文件</p> <h1>组件用法</h1> <p>```C++ //播放音效 USoundManager::Get()-&gt;PlaySoundByName(音效名字); //播放背景音乐 USoundManager::Get()-&gt;PlayBackGroundSoundByName(背景音名字); //停止音效 USoundManager::Get()-&gt;StopSoundEffect(); //停止背景音 USoundManager::Get()-&gt;StopBackGroundSound(); //开始声音采集 USoundManager::Get()-&gt;StartCapturingAudio(); //结束声音采集 USoundManager::Get()-&gt;StopCapturingAudio(); //获取采集音的平均强度 USoundManager::Get()-&gt;AverageStrength; //获取采集音的最大强度 USoundManager::Get()-&gt;MaxStrength;</p> <pre><code># 组件接口 ```C++ //播放音效 void PlaySoundByName(FString soundName); //停止音效 void StopSoundEffect() const; //播放背景音乐 void PlayBackGroundSoundByName(FString soundName); //停止背景音乐 void StopBackGroundSound() const; // 开始捕获音频 void StartCapturingAudio(); //停止捕获音频 void StopCapturingAudio(); </code></pre> <h1>组件示例</h1> <p>```c++</p> <h1>include &quot;Sound/SoundManager.h&quot;</h1> <p>//播放音效 USoundManager::Get()-&gt;PlaySoundByName(TEXT(&quot;A_Click&quot;)); //播放背景音乐 USoundManager::Get()-&gt;PlayBackGroundSoundByName(TEXT(&quot;A_Win_Cue&quot;)); //停止音效 USoundManager::Get()-&gt;StopSoundEffect(); //停止背景音乐 USoundManager::Get()-&gt;StopBackGroundSound(); //开始声音采集 USoundManager::Get()-&gt;StartCapturingAudio(); //停止声音采集 USoundManager::Get()-&gt;StopCapturingAudio();</p> <pre><code></code></pre>

页面列表

ITEM_HTML