net.dreditor.audio.fmod 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.attestation.p7m +0 -0
- package/AudioVisualizerThreeDFMOD.cs +285 -285
- package/AudioVisualizerThreeDFMOD.cs.meta +11 -11
- package/AudioVisualizerTwoDFMOD.cs +58 -58
- package/AudioVisualizerTwoDFMOD.cs.meta +11 -11
- package/CreditsMusicFMOD.cs +22 -22
- package/CreditsMusicFMOD.cs.meta +11 -11
- package/DREditor.Audio.FMOD.asmdef +20 -20
- package/DREditor.Audio.FMOD.asmdef.meta +7 -7
- package/PlaylistFMODEditor.cs +357 -357
- package/PlaylistFMODEditor.cs.meta +11 -11
- package/{Samples → Samples~}/Audio_Visualizer_FMOD.prefab +658 -658
- package/{Samples → Samples~}/Audio_Visualizer_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Credits_Music_FMOD.prefab +66 -66
- package/{Samples → Samples~}/Credits_Music_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Environment_SFX_Manager_FMOD.prefab +163 -163
- package/{Samples → Samples~}/Environment_SFX_Manager_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Environment_Source_FMOD.prefab +101 -101
- package/{Samples → Samples~}/Environment_Source_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Music_Manager_FMOD.prefab +186 -186
- package/{Samples → Samples~}/Music_Manager_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/On_Voice_Line_Setting_Changed_FMOD.prefab +76 -76
- package/{Samples → Samples~}/On_Voice_Line_Setting_Changed_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Pop_Up_Emitter_FMOD.prefab +57 -57
- package/{Samples → Samples~}/Pop_Up_Emitter_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/SFX_Manager_FMOD.prefab +501 -501
- package/{Samples → Samples~}/SFX_Manager_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/SFX_Source_FMOD.prefab +101 -101
- package/{Samples → Samples~}/SFX_Source_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Sound_Manager_FMOD_ETemplate.prefab +515 -515
- package/{Samples → Samples~}/Sound_Manager_FMOD_ETemplate.prefab.meta +7 -7
- package/{Samples → Samples~}/Sound_Player_DRE_FMOD.prefab +47 -47
- package/{Samples → Samples~}/Sound_Player_DRE_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/UI_Cancel_Source_FMOD.prefab +101 -101
- package/{Samples → Samples~}/UI_Cancel_Source_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/UI_Select_Source_FMOD.prefab +101 -101
- package/{Samples → Samples~}/UI_Select_Source_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/UI_Submit_Source_FMOD.prefab +101 -101
- package/{Samples → Samples~}/UI_Submit_Source_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Voice_SFX_Manager_FMOD.prefab +163 -163
- package/{Samples → Samples~}/Voice_SFX_Manager_FMOD.prefab.meta +7 -7
- package/{Samples → Samples~}/Voice_Source_FMOD.prefab +57 -57
- package/{Samples → Samples~}/Voice_Source_FMOD.prefab.meta +7 -7
- package/SoundPlayerDREFMOD.cs +42 -42
- package/SoundPlayerDREFMOD.cs.meta +11 -11
- package/package.json +41 -36
- package/package.json.meta +7 -7
- package/Samples.meta +0 -8
package/.attestation.p7m
ADDED
|
Binary file
|
|
@@ -1,286 +1,286 @@
|
|
|
1
|
-
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
-
#if FMOD_UNITY
|
|
3
|
-
using DREditor.EventObjects;
|
|
4
|
-
using DREditor.Services;
|
|
5
|
-
using FMOD;
|
|
6
|
-
using FMODUnity;
|
|
7
|
-
using System;
|
|
8
|
-
using System.Collections;
|
|
9
|
-
using System.Runtime.InteropServices;
|
|
10
|
-
using UnityEngine;
|
|
11
|
-
|
|
12
|
-
namespace DREditor.Audio.FMOD
|
|
13
|
-
{
|
|
14
|
-
/// <summary>
|
|
15
|
-
///
|
|
16
|
-
/// </summary>
|
|
17
|
-
[ClassHeader("")]
|
|
18
|
-
public class AudioVisualizerThreeDFMOD : MonoBehaviour
|
|
19
|
-
{
|
|
20
|
-
/// <summary>
|
|
21
|
-
///
|
|
22
|
-
/// </summary>
|
|
23
|
-
[Header("")]
|
|
24
|
-
[Divider]
|
|
25
|
-
[Tooltip("")]
|
|
26
|
-
[SerializeField] protected bool canDisplay = false;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/// <summary>
|
|
30
|
-
///
|
|
31
|
-
/// </summary>
|
|
32
|
-
[Header("")]
|
|
33
|
-
[Divider]
|
|
34
|
-
[Tooltip("")]
|
|
35
|
-
[SerializeField] protected ValueWithEvent<float, FloatEvent> bgmSetting = null;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
/// <summary>
|
|
39
|
-
///
|
|
40
|
-
/// </summary>
|
|
41
|
-
[Header("")]
|
|
42
|
-
[Divider]
|
|
43
|
-
[Tooltip("")]
|
|
44
|
-
[SerializeField] protected Transform[] blocks;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
/// <summary>
|
|
48
|
-
///
|
|
49
|
-
/// </summary>
|
|
50
|
-
[Header("")]
|
|
51
|
-
[Divider]
|
|
52
|
-
[Tooltip("")]
|
|
53
|
-
[SerializeField] protected float heightScale = 5;
|
|
54
|
-
|
|
55
|
-
/// <summary>
|
|
56
|
-
///
|
|
57
|
-
/// </summary>
|
|
58
|
-
[Tooltip("")]
|
|
59
|
-
[SerializeField] int expScale = 3;
|
|
60
|
-
|
|
61
|
-
/// <summary>
|
|
62
|
-
///
|
|
63
|
-
/// </summary>
|
|
64
|
-
[Tooltip("")]
|
|
65
|
-
[SerializeField] int sectionAdder = 2;
|
|
66
|
-
|
|
67
|
-
/// <summary>
|
|
68
|
-
///
|
|
69
|
-
/// </summary>
|
|
70
|
-
[Tooltip("")]
|
|
71
|
-
[SerializeField] int sectionDivider = 2;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
/// <summary>
|
|
75
|
-
///
|
|
76
|
-
/// </summary>
|
|
77
|
-
protected DSP fft;
|
|
78
|
-
|
|
79
|
-
/// <summary>
|
|
80
|
-
///
|
|
81
|
-
/// </summary>
|
|
82
|
-
protected float height;
|
|
83
|
-
|
|
84
|
-
/// <summary>
|
|
85
|
-
///
|
|
86
|
-
/// </summary>
|
|
87
|
-
protected int currentIndex = 0;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
protected static readonly float DecibelMinVolume = -80.0f;
|
|
91
|
-
|
|
92
|
-
protected static readonly float DecibelMaxVolume = 0.0f;
|
|
93
|
-
|
|
94
|
-
protected static readonly float Amplitude = 20.0f;
|
|
95
|
-
|
|
96
|
-
protected static readonly int WindowSize = 16;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/// <summary>
|
|
100
|
-
///
|
|
101
|
-
/// </summary>
|
|
102
|
-
protected virtual void OnEnable() => ServiceLocator.GetService<MusicManagerBase>().OnMusicChange += PrepareEmitterData;
|
|
103
|
-
|
|
104
|
-
/// <summary>
|
|
105
|
-
///
|
|
106
|
-
/// </summary>
|
|
107
|
-
/// <param name="emitter"></param>
|
|
108
|
-
protected virtual void PrepareEmitterData(StudioEventEmitter emitter) => StartCoroutine(PrepareEmitterDataRoutine(emitter));
|
|
109
|
-
|
|
110
|
-
/// <summary>
|
|
111
|
-
///
|
|
112
|
-
/// </summary>
|
|
113
|
-
/// <param name="emitter"></param>
|
|
114
|
-
protected virtual IEnumerator PrepareEmitterDataRoutine(StudioEventEmitter emitter)
|
|
115
|
-
{
|
|
116
|
-
if (ResetBlocksOnEmitterNull(emitter))
|
|
117
|
-
yield break;
|
|
118
|
-
|
|
119
|
-
yield return new WaitUntil(() => RuntimeManager.IsInitialized);
|
|
120
|
-
|
|
121
|
-
yield return new WaitUntil(() => emitter.IsPlaying());
|
|
122
|
-
|
|
123
|
-
canDisplay = false;
|
|
124
|
-
|
|
125
|
-
InitializeEmitterData(emitter);
|
|
126
|
-
|
|
127
|
-
canDisplay = true;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/// <summary>
|
|
131
|
-
///
|
|
132
|
-
/// </summary>
|
|
133
|
-
/// <param name="emitter"></param>
|
|
134
|
-
protected virtual void InitializeEmitterData(StudioEventEmitter emitter)
|
|
135
|
-
{
|
|
136
|
-
RuntimeManager.CoreSystem.createDSPByType(DSP_TYPE.FFT, out fft);
|
|
137
|
-
|
|
138
|
-
fft.setParameterInt((int)DSP_FFT.WINDOWTYPE, (int)DSP_FFT_WINDOW.HANNING);
|
|
139
|
-
|
|
140
|
-
fft.setParameterInt((int)DSP_FFT.WINDOWSIZE, WindowSize);
|
|
141
|
-
|
|
142
|
-
UnityEngine.Debug.Log(emitter.EventInstance.getChannelGroup(out ChannelGroup channelGroup).ToString());
|
|
143
|
-
|
|
144
|
-
UnityEngine.Debug.Log(fft.getParameterInt((int)DSP_FFT.WINDOWSIZE, out int value));
|
|
145
|
-
|
|
146
|
-
UnityEngine.Debug.Log(value);
|
|
147
|
-
|
|
148
|
-
RESULT rESULT = fft.getInfo(out _, out _, out _, out _, out _);
|
|
149
|
-
|
|
150
|
-
UnityEngine.Debug.Log(rESULT.ToString());
|
|
151
|
-
|
|
152
|
-
UnityEngine.Debug.Log(channelGroup.addDSP(CHANNELCONTROL_DSP_INDEX.HEAD, fft).ToString());
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/// <summary>
|
|
156
|
-
///
|
|
157
|
-
/// </summary>
|
|
158
|
-
/// <param name="emitter"></param>
|
|
159
|
-
/// <returns></returns>
|
|
160
|
-
protected bool ResetBlocksOnEmitterNull(StudioEventEmitter emitter)
|
|
161
|
-
{
|
|
162
|
-
if (emitter == null)
|
|
163
|
-
ResetVisualizerBlocks();
|
|
164
|
-
|
|
165
|
-
return emitter == null;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
/// <summary>
|
|
171
|
-
///
|
|
172
|
-
/// </summary>
|
|
173
|
-
protected virtual void LateUpdate() => EvaluateVisualizeAudio();
|
|
174
|
-
|
|
175
|
-
/// <summary>
|
|
176
|
-
///
|
|
177
|
-
/// </summary>
|
|
178
|
-
protected virtual void EvaluateVisualizeAudio()
|
|
179
|
-
{
|
|
180
|
-
if (canDisplay)
|
|
181
|
-
VisualizeAudio();
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
/// <summary>
|
|
185
|
-
///
|
|
186
|
-
/// </summary>
|
|
187
|
-
protected virtual void VisualizeAudio()
|
|
188
|
-
{
|
|
189
|
-
fft.getParameterData((int)DSP_FFT.SPECTRUMDATA, out IntPtr unmanagedData, out _);
|
|
190
|
-
|
|
191
|
-
try
|
|
192
|
-
{
|
|
193
|
-
DSP_PARAMETER_FFT fftData = (DSP_PARAMETER_FFT)Marshal.PtrToStructure(unmanagedData, typeof(DSP_PARAMETER_FFT));
|
|
194
|
-
|
|
195
|
-
if (fftData.numchannels > 0)
|
|
196
|
-
for (int i = 0; i < blocks.Length; ++i)
|
|
197
|
-
CalculateBlockSizeDelta(fftData.spectrum, i);
|
|
198
|
-
}
|
|
199
|
-
catch { }
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
/// <summary>
|
|
204
|
-
///
|
|
205
|
-
/// </summary>
|
|
206
|
-
/// <param name="spectrum"></param>
|
|
207
|
-
/// <param name="currentBlockSize"></param>
|
|
208
|
-
/// <returns></returns>
|
|
209
|
-
/// <remarks></remarks>
|
|
210
|
-
protected virtual Vector3 CalculateBlockSizeBySpectrum(float[][] spectrum, Vector3 currentBlockSize)
|
|
211
|
-
{
|
|
212
|
-
int spectrumSection = CalculateSpectrumSection();
|
|
213
|
-
|
|
214
|
-
float decibelLevel = LinearToDecibel(spectrum[0][spectrumSection]);
|
|
215
|
-
|
|
216
|
-
height = (-1 * DecibelMinVolume) + decibelLevel;
|
|
217
|
-
|
|
218
|
-
height *= heightScale;
|
|
219
|
-
|
|
220
|
-
currentBlockSize.y = Mathf.Lerp(currentBlockSize.y, height, 0.1f);
|
|
221
|
-
|
|
222
|
-
return currentBlockSize;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
/// <summary>
|
|
226
|
-
///
|
|
227
|
-
/// </summary>
|
|
228
|
-
/// <returns></returns>
|
|
229
|
-
protected virtual int CalculateSpectrumSection() => expScale * (currentIndex + sectionAdder) / sectionDivider;
|
|
230
|
-
|
|
231
|
-
/// <summary>
|
|
232
|
-
///
|
|
233
|
-
/// </summary>
|
|
234
|
-
/// <param name="linear"></param>
|
|
235
|
-
/// <returns></returns>
|
|
236
|
-
protected float LinearToDecibel(float linear) => Mathf.Clamp(Mathf.Log10(linear) * Amplitude, DecibelMinVolume, DecibelMaxVolume);
|
|
237
|
-
|
|
238
|
-
/// <summary>
|
|
239
|
-
///
|
|
240
|
-
/// </summary>
|
|
241
|
-
protected virtual void OnDisable()
|
|
242
|
-
{
|
|
243
|
-
if (ServiceLocator.HasService<MusicManagerBase>())
|
|
244
|
-
ServiceLocator.GetService<MusicManagerBase>().OnMusicChange -= PrepareEmitterData;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
/// <summary>
|
|
250
|
-
///
|
|
251
|
-
/// </summary>
|
|
252
|
-
/// <remarks></remarks>
|
|
253
|
-
protected virtual void ResetVisualizerBlocks()
|
|
254
|
-
{
|
|
255
|
-
for (int i = 0; i < blocks.Length; ++i)
|
|
256
|
-
blocks[i].transform.localScale = new Vector3(blocks[i].transform.localScale.x, 0);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
/// <summary>
|
|
260
|
-
///
|
|
261
|
-
/// </summary>
|
|
262
|
-
/// <param name="spectrum"></param>
|
|
263
|
-
/// <param name="i"></param>
|
|
264
|
-
protected virtual void CalculateBlockSizeDelta(float[][] spectrum, int i)
|
|
265
|
-
{
|
|
266
|
-
currentIndex = i;
|
|
267
|
-
|
|
268
|
-
Vector3 currentBlockSize = CalculateBlockSizeBySpectrum(spectrum, blocks[currentIndex].transform.localScale);
|
|
269
|
-
|
|
270
|
-
SetBlockSizeDelta(currentBlockSize);
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
/// <summary>
|
|
274
|
-
///
|
|
275
|
-
/// </summary>
|
|
276
|
-
/// <param name="currentBlockSize"></param>
|
|
277
|
-
protected virtual void SetBlockSizeDelta(Vector3 currentBlockSize)
|
|
278
|
-
{
|
|
279
|
-
if (bgmSetting.Value.Equals(0))
|
|
280
|
-
blocks[currentIndex].transform.localScale = Vector3.zero;
|
|
281
|
-
else
|
|
282
|
-
blocks[currentIndex].transform.localScale = currentBlockSize;
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
}
|
|
1
|
+
//Author: Benjamin "Sweden" Jillson : Discord: sweden_gaming For Project Eden's Garden
|
|
2
|
+
#if FMOD_UNITY
|
|
3
|
+
using DREditor.EventObjects;
|
|
4
|
+
using DREditor.Services;
|
|
5
|
+
using FMOD;
|
|
6
|
+
using FMODUnity;
|
|
7
|
+
using System;
|
|
8
|
+
using System.Collections;
|
|
9
|
+
using System.Runtime.InteropServices;
|
|
10
|
+
using UnityEngine;
|
|
11
|
+
|
|
12
|
+
namespace DREditor.Audio.FMOD
|
|
13
|
+
{
|
|
14
|
+
/// <summary>
|
|
15
|
+
///
|
|
16
|
+
/// </summary>
|
|
17
|
+
[ClassHeader("")]
|
|
18
|
+
public class AudioVisualizerThreeDFMOD : MonoBehaviour
|
|
19
|
+
{
|
|
20
|
+
/// <summary>
|
|
21
|
+
///
|
|
22
|
+
/// </summary>
|
|
23
|
+
[Header("")]
|
|
24
|
+
[Divider]
|
|
25
|
+
[Tooltip("")]
|
|
26
|
+
[SerializeField] protected bool canDisplay = false;
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
///
|
|
31
|
+
/// </summary>
|
|
32
|
+
[Header("")]
|
|
33
|
+
[Divider]
|
|
34
|
+
[Tooltip("")]
|
|
35
|
+
[SerializeField] protected ValueWithEvent<float, FloatEvent> bgmSetting = null;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
///
|
|
40
|
+
/// </summary>
|
|
41
|
+
[Header("")]
|
|
42
|
+
[Divider]
|
|
43
|
+
[Tooltip("")]
|
|
44
|
+
[SerializeField] protected Transform[] blocks;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
///
|
|
49
|
+
/// </summary>
|
|
50
|
+
[Header("")]
|
|
51
|
+
[Divider]
|
|
52
|
+
[Tooltip("")]
|
|
53
|
+
[SerializeField] protected float heightScale = 5;
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
///
|
|
57
|
+
/// </summary>
|
|
58
|
+
[Tooltip("")]
|
|
59
|
+
[SerializeField] int expScale = 3;
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
///
|
|
63
|
+
/// </summary>
|
|
64
|
+
[Tooltip("")]
|
|
65
|
+
[SerializeField] int sectionAdder = 2;
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
///
|
|
69
|
+
/// </summary>
|
|
70
|
+
[Tooltip("")]
|
|
71
|
+
[SerializeField] int sectionDivider = 2;
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
///
|
|
76
|
+
/// </summary>
|
|
77
|
+
protected DSP fft;
|
|
78
|
+
|
|
79
|
+
/// <summary>
|
|
80
|
+
///
|
|
81
|
+
/// </summary>
|
|
82
|
+
protected float height;
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
///
|
|
86
|
+
/// </summary>
|
|
87
|
+
protected int currentIndex = 0;
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
protected static readonly float DecibelMinVolume = -80.0f;
|
|
91
|
+
|
|
92
|
+
protected static readonly float DecibelMaxVolume = 0.0f;
|
|
93
|
+
|
|
94
|
+
protected static readonly float Amplitude = 20.0f;
|
|
95
|
+
|
|
96
|
+
protected static readonly int WindowSize = 16;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
/// <summary>
|
|
100
|
+
///
|
|
101
|
+
/// </summary>
|
|
102
|
+
protected virtual void OnEnable() => ServiceLocator.GetService<MusicManagerBase>().OnMusicChange += PrepareEmitterData;
|
|
103
|
+
|
|
104
|
+
/// <summary>
|
|
105
|
+
///
|
|
106
|
+
/// </summary>
|
|
107
|
+
/// <param name="emitter"></param>
|
|
108
|
+
protected virtual void PrepareEmitterData(StudioEventEmitter emitter) => StartCoroutine(PrepareEmitterDataRoutine(emitter));
|
|
109
|
+
|
|
110
|
+
/// <summary>
|
|
111
|
+
///
|
|
112
|
+
/// </summary>
|
|
113
|
+
/// <param name="emitter"></param>
|
|
114
|
+
protected virtual IEnumerator PrepareEmitterDataRoutine(StudioEventEmitter emitter)
|
|
115
|
+
{
|
|
116
|
+
if (ResetBlocksOnEmitterNull(emitter))
|
|
117
|
+
yield break;
|
|
118
|
+
|
|
119
|
+
yield return new WaitUntil(() => RuntimeManager.IsInitialized);
|
|
120
|
+
|
|
121
|
+
yield return new WaitUntil(() => emitter.IsPlaying());
|
|
122
|
+
|
|
123
|
+
canDisplay = false;
|
|
124
|
+
|
|
125
|
+
InitializeEmitterData(emitter);
|
|
126
|
+
|
|
127
|
+
canDisplay = true;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/// <summary>
|
|
131
|
+
///
|
|
132
|
+
/// </summary>
|
|
133
|
+
/// <param name="emitter"></param>
|
|
134
|
+
protected virtual void InitializeEmitterData(StudioEventEmitter emitter)
|
|
135
|
+
{
|
|
136
|
+
RuntimeManager.CoreSystem.createDSPByType(DSP_TYPE.FFT, out fft);
|
|
137
|
+
|
|
138
|
+
fft.setParameterInt((int)DSP_FFT.WINDOWTYPE, (int)DSP_FFT_WINDOW.HANNING);
|
|
139
|
+
|
|
140
|
+
fft.setParameterInt((int)DSP_FFT.WINDOWSIZE, WindowSize);
|
|
141
|
+
|
|
142
|
+
UnityEngine.Debug.Log(emitter.EventInstance.getChannelGroup(out ChannelGroup channelGroup).ToString());
|
|
143
|
+
|
|
144
|
+
UnityEngine.Debug.Log(fft.getParameterInt((int)DSP_FFT.WINDOWSIZE, out int value));
|
|
145
|
+
|
|
146
|
+
UnityEngine.Debug.Log(value);
|
|
147
|
+
|
|
148
|
+
RESULT rESULT = fft.getInfo(out _, out _, out _, out _, out _);
|
|
149
|
+
|
|
150
|
+
UnityEngine.Debug.Log(rESULT.ToString());
|
|
151
|
+
|
|
152
|
+
UnityEngine.Debug.Log(channelGroup.addDSP(CHANNELCONTROL_DSP_INDEX.HEAD, fft).ToString());
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/// <summary>
|
|
156
|
+
///
|
|
157
|
+
/// </summary>
|
|
158
|
+
/// <param name="emitter"></param>
|
|
159
|
+
/// <returns></returns>
|
|
160
|
+
protected bool ResetBlocksOnEmitterNull(StudioEventEmitter emitter)
|
|
161
|
+
{
|
|
162
|
+
if (emitter == null)
|
|
163
|
+
ResetVisualizerBlocks();
|
|
164
|
+
|
|
165
|
+
return emitter == null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
/// <summary>
|
|
171
|
+
///
|
|
172
|
+
/// </summary>
|
|
173
|
+
protected virtual void LateUpdate() => EvaluateVisualizeAudio();
|
|
174
|
+
|
|
175
|
+
/// <summary>
|
|
176
|
+
///
|
|
177
|
+
/// </summary>
|
|
178
|
+
protected virtual void EvaluateVisualizeAudio()
|
|
179
|
+
{
|
|
180
|
+
if (canDisplay)
|
|
181
|
+
VisualizeAudio();
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/// <summary>
|
|
185
|
+
///
|
|
186
|
+
/// </summary>
|
|
187
|
+
protected virtual void VisualizeAudio()
|
|
188
|
+
{
|
|
189
|
+
fft.getParameterData((int)DSP_FFT.SPECTRUMDATA, out IntPtr unmanagedData, out _);
|
|
190
|
+
|
|
191
|
+
try
|
|
192
|
+
{
|
|
193
|
+
DSP_PARAMETER_FFT fftData = (DSP_PARAMETER_FFT)Marshal.PtrToStructure(unmanagedData, typeof(DSP_PARAMETER_FFT));
|
|
194
|
+
|
|
195
|
+
if (fftData.numchannels > 0)
|
|
196
|
+
for (int i = 0; i < blocks.Length; ++i)
|
|
197
|
+
CalculateBlockSizeDelta(fftData.spectrum, i);
|
|
198
|
+
}
|
|
199
|
+
catch { }
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
/// <summary>
|
|
204
|
+
///
|
|
205
|
+
/// </summary>
|
|
206
|
+
/// <param name="spectrum"></param>
|
|
207
|
+
/// <param name="currentBlockSize"></param>
|
|
208
|
+
/// <returns></returns>
|
|
209
|
+
/// <remarks></remarks>
|
|
210
|
+
protected virtual Vector3 CalculateBlockSizeBySpectrum(float[][] spectrum, Vector3 currentBlockSize)
|
|
211
|
+
{
|
|
212
|
+
int spectrumSection = CalculateSpectrumSection();
|
|
213
|
+
|
|
214
|
+
float decibelLevel = LinearToDecibel(spectrum[0][spectrumSection]);
|
|
215
|
+
|
|
216
|
+
height = (-1 * DecibelMinVolume) + decibelLevel;
|
|
217
|
+
|
|
218
|
+
height *= heightScale;
|
|
219
|
+
|
|
220
|
+
currentBlockSize.y = Mathf.Lerp(currentBlockSize.y, height, 0.1f);
|
|
221
|
+
|
|
222
|
+
return currentBlockSize;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/// <summary>
|
|
226
|
+
///
|
|
227
|
+
/// </summary>
|
|
228
|
+
/// <returns></returns>
|
|
229
|
+
protected virtual int CalculateSpectrumSection() => expScale * (currentIndex + sectionAdder) / sectionDivider;
|
|
230
|
+
|
|
231
|
+
/// <summary>
|
|
232
|
+
///
|
|
233
|
+
/// </summary>
|
|
234
|
+
/// <param name="linear"></param>
|
|
235
|
+
/// <returns></returns>
|
|
236
|
+
protected float LinearToDecibel(float linear) => Mathf.Clamp(Mathf.Log10(linear) * Amplitude, DecibelMinVolume, DecibelMaxVolume);
|
|
237
|
+
|
|
238
|
+
/// <summary>
|
|
239
|
+
///
|
|
240
|
+
/// </summary>
|
|
241
|
+
protected virtual void OnDisable()
|
|
242
|
+
{
|
|
243
|
+
if (ServiceLocator.HasService<MusicManagerBase>())
|
|
244
|
+
ServiceLocator.GetService<MusicManagerBase>().OnMusicChange -= PrepareEmitterData;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
/// <summary>
|
|
250
|
+
///
|
|
251
|
+
/// </summary>
|
|
252
|
+
/// <remarks></remarks>
|
|
253
|
+
protected virtual void ResetVisualizerBlocks()
|
|
254
|
+
{
|
|
255
|
+
for (int i = 0; i < blocks.Length; ++i)
|
|
256
|
+
blocks[i].transform.localScale = new Vector3(blocks[i].transform.localScale.x, 0);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/// <summary>
|
|
260
|
+
///
|
|
261
|
+
/// </summary>
|
|
262
|
+
/// <param name="spectrum"></param>
|
|
263
|
+
/// <param name="i"></param>
|
|
264
|
+
protected virtual void CalculateBlockSizeDelta(float[][] spectrum, int i)
|
|
265
|
+
{
|
|
266
|
+
currentIndex = i;
|
|
267
|
+
|
|
268
|
+
Vector3 currentBlockSize = CalculateBlockSizeBySpectrum(spectrum, blocks[currentIndex].transform.localScale);
|
|
269
|
+
|
|
270
|
+
SetBlockSizeDelta(currentBlockSize);
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/// <summary>
|
|
274
|
+
///
|
|
275
|
+
/// </summary>
|
|
276
|
+
/// <param name="currentBlockSize"></param>
|
|
277
|
+
protected virtual void SetBlockSizeDelta(Vector3 currentBlockSize)
|
|
278
|
+
{
|
|
279
|
+
if (bgmSetting.Value.Equals(0))
|
|
280
|
+
blocks[currentIndex].transform.localScale = Vector3.zero;
|
|
281
|
+
else
|
|
282
|
+
blocks[currentIndex].transform.localScale = currentBlockSize;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
286
|
#endif
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: f8d6d0a6c261824468ac33e60f2ffc6d
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: f8d6d0a6c261824468ac33e60f2ffc6d
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|