项目
在 GitHub 查看
allanpichardo/Unity-Beat-Detection
关于
用于 Unity 游戏引擎的音乐拍点检测和音频频谱分析。
游戏与模拟器实测星标增长
- 24小时
- -1
- 7天
- -1
- 15天
- -1
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文Unity-Beat-Detection
Musical beat detection and audio spectrum analysis for use with the Unity game engine.
The AudioProcessor class contains an interface that can be implemented on your GameObject.
Usage
Add the AudioProcessor script to your Main Camera object and adjust the threshold parameter to change the sensitivity. Then set a callback delegate on the audio processor's onBeat or onSpectrum events.public class Example : MonoBehaviour
{
void Start ()
{
//Select the instance of AudioProcessor and pass a reference
//to this object
AudioProcessor processor = FindObjectOfType<AudioProcessor> ();
processor.onBeat.AddListener (onOnbeatDetected);
processor.onSpectrum.AddListener (onSpectrum);
}
//this event will be called every time a beat is detected.
//Change the threshold parameter in the inspector
//to adjust the sensitivity
void onOnbeatDetected ()
{
Debug.Log ("Beat!!!");
}
//This event will be called every frame while music is playing
void onSpectrum (float[] spectrum)
{
//The spectrum is logarithmically averaged
//to 12 bands
for (int i = 0; i < spectrum.Length; ++i) {
Vector3 start = new Vector3 (i, 0, 0);
Vector3 end = new Vector3 (i, spectrum [i], 0);
Debug.DrawLine (start, end);
}
}
}
探索相关项目
加载中…