16块的音频可视化,参考了https://blog.youkuaiyun.com/noEnoughChief/article/details/82984635
效果:

第一种:
- 挂在长方形上,调节band从1到15。band0和16值为零。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(AudioSource))]
public class AudioVisable : MonoBehaviour {
AudioSource audioSource;
float[] samples = new float[1024];//每个采样约20Hz
public static float[] freqBand = new float[16];
int[] sampleCount = {
1,2,4,8,10,12,15,17,20,22,25,27,30,70,100,250,500,1000};//区块之间的分割数
public static float[] bandBuffer = new float[16];//缓冲区以减缓过于跳跃的变化
float[] bufferDecrease = new float[16];//柱子的下降速度
float[] freqBandHighest = new float[16];
public static float[] audioBandBuffer = new float[16];
void Start () {
audioSource = GetComponent<AudioSource>();
}
void CreateAudioBands()
{
for (int i = 0; i < 16; i++)
{
if (freqBand[i] > freqBandHighest[i]

本文介绍了一种使用Unity实现音频可视化的技术,通过16个频段的划分,将音频信号转换为可视化的频率波形。文章提供了两种实现方案,一种是通过缓冲区平滑频率波形变化,另一种是在Android设备上优化后的方案,限制了长方体的高度以增强视觉效果。
最低0.47元/天 解锁文章
1348

被折叠的 条评论
为什么被折叠?



