lucid-super-dream/Assets/Scripts/Rendering/AudioVisualizer.cs

41 lines
1.2 KiB
C#
Raw Normal View History

2021-01-07 03:00:17 +01:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using FMODUnity;
using NUnit.Framework;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering.Universal;
public class AudioVisualizer : MonoBehaviour
{
2021-01-07 06:44:42 +01:00
[SerializeField] private Renderer _ship;
2021-01-07 03:00:17 +01:00
[SerializeField] private Renderer _fractal;
[SerializeField] private Renderer _tunnel;
[SerializeField] private AudioVisualizerSettings _settings;
2021-01-07 06:44:42 +01:00
2021-01-07 03:00:17 +01:00
// https://qa.fmod.com/t/getting-spectrum-of-master-channel-in-unity/12579/2
// private FMOD.Studio.EventInstance _event;
private FMOD.DSP _fft;
private float _initialPower;
2021-01-07 06:44:42 +01:00
2021-01-07 03:00:17 +01:00
private void Start()
{
// _event = RuntimeManager.CreateInstance("event:/Music");
RuntimeManager.CoreSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out _fft);
RuntimeManager.CoreSystem.getMasterChannelGroup(out var channelGroup);
channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, _fft);
2021-01-07 06:44:42 +01:00
_settings.Initialise(_fractal.material, _tunnel.material, _ship.material);
2021-01-07 03:00:17 +01:00
}
private void LateUpdate()
{
2021-01-07 06:44:42 +01:00
_settings.Update(_fft, _fractal, _tunnel, _ship);
2021-01-07 03:00:17 +01:00
}
2021-01-07 06:44:42 +01:00
}