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

43 lines
1.4 KiB
C#
Raw Normal View History

2021-01-09 06:32:47 +01:00
using System;
using FMODUnity;
using UnityEngine;
public class AudioVisualizerRuntime : MonoBehaviour
{
[SerializeField] private Renderer _ship;
[SerializeField] private Renderer _fractal;
2021-01-10 18:54:04 +01:00
// [SerializeField] private Renderer _tunnel;
2021-01-09 06:32:47 +01:00
[SerializeField] private AudioVisualizer _system;
2021-01-10 18:54:04 +01:00
[SerializeField] private TunnelController _tunnel;
2021-01-09 06:32:47 +01:00
[SerializeField] private AccessibilityOptions _accessibility;
// 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;
private void Awake()
{
// pick correct materials for accessibility
// _ship.material = _accessibility.Intensity.Ship;
2021-01-10 18:54:04 +01:00
// _tunnel.material = new Material(_accessibility.Intensity.Tunnel);
2021-01-09 06:32:47 +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-10 18:54:04 +01:00
_system.Initialise(_fractal.material, _tunnel.Active.material, _ship.material);
2021-01-09 06:32:47 +01:00
}
private void LateUpdate()
{
2021-01-10 18:54:04 +01:00
_system.UpdateAudio(_fft, _fractal, _tunnel.Active, _ship);
2021-01-09 06:32:47 +01:00
}
}