trying to save the curve presets
This commit is contained in:
1 parent
0cac336db2
commit
e033519317
11 files changed
+347
-229
No files matched your search
@@ -0,0 +1,76 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.VFX;
|
||||
using UnityEngine.VFX.Utility;
|
||||
using Assets.WasapiAudio.Scripts.Unity;
|
||||
|
||||
namespace Assets.WasapiAudio.Scripts.Unity
|
||||
{
|
||||
[AddComponentMenu("VFX/Property Binders/Spectre - VFX Binder")]
|
||||
[VFXBinder("Audio/Audio Spectrum Data to AttributeMap")]
|
||||
public class SpectreVfxBinder : VfxAudioVisualizationEffect
|
||||
{
|
||||
[VFXPropertyBinding("System.UInt32"), SerializeField]
|
||||
protected ExposedProperty SpectrumSizeParameter = "SpectrumSize";
|
||||
|
||||
[VFXPropertyBinding("UnityEngine.Texture2D"), SerializeField]
|
||||
protected ExposedProperty SpectrumDataTextureParameter = "SpectrumDataTexture";
|
||||
|
||||
public bool symmetric = false;
|
||||
|
||||
private Texture2D _texture;
|
||||
private Color[] _colorCache;
|
||||
|
||||
private void InitialiseTexture() {
|
||||
Debug.Log("Reinitialising spectrum texture...");
|
||||
if (symmetric) {
|
||||
_texture = new Texture2D(SpectrumSize * 2, 1, TextureFormat.RFloat, false);
|
||||
_colorCache = new Color[SpectrumSize * 2];
|
||||
} else {
|
||||
_texture = new Texture2D(SpectrumSize, 1, TextureFormat.RFloat, false);
|
||||
_colorCache = new Color[SpectrumSize];
|
||||
}
|
||||
|
||||
_texture.name = $"AudioSpectrumData{SpectrumSize}";
|
||||
}
|
||||
|
||||
private void UpdateTexture() {
|
||||
// init
|
||||
if (_texture == null) InitialiseTexture();
|
||||
|
||||
// has symmetric been toggled and the texture needs updating?
|
||||
if (symmetric && _texture.width != SpectrumSize * 2) InitialiseTexture();
|
||||
if (!symmetric && _texture.width != SpectrumSize) InitialiseTexture();
|
||||
|
||||
var spectrumData = GetSpectrumData();
|
||||
|
||||
if (symmetric) {
|
||||
for (int i = 0; i < SpectrumSize; i++) {
|
||||
_colorCache[SpectrumSize + i] = new Color(spectrumData[i], 0, 0, 0);
|
||||
_colorCache[SpectrumSize - (i + 1)] = new Color(spectrumData[i], 0, 0, 0);
|
||||
}
|
||||
} else {
|
||||
for (int i = 0; i < SpectrumSize; i++) {
|
||||
_colorCache[i] = new Color(spectrumData[i], 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
_texture.SetPixels(_colorCache);
|
||||
_texture.Apply();
|
||||
}
|
||||
|
||||
public override void UpdateBinding(VisualEffect component) {
|
||||
base.UpdateBinding(component);
|
||||
UpdateTexture();
|
||||
if (symmetric) {
|
||||
component.SetUInt(SpectrumSizeParameter, (uint) SpectrumSize * 2);
|
||||
} else {
|
||||
component.SetUInt(SpectrumSizeParameter, (uint) SpectrumSize);
|
||||
}
|
||||
component.SetTexture(SpectrumDataTextureParameter, _texture);
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "Audio Spectrum Data";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc21ac8b706913b47897e9f83d170bc5
|
||||
guid: d2c94a50cf5c1d2449fe8305e8a79075
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+164
-160
@@ -1113,164 +1113,6 @@ MonoBehaviour:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_IsOn: 1
|
||||
--- !u!1 &3396357262573175923
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 421876249768687115}
|
||||
- component: {fileID: 8933658421904991632}
|
||||
- component: {fileID: 6749243352969479682}
|
||||
- component: {fileID: 2478420379614445965}
|
||||
- component: {fileID: 3975575999960435775}
|
||||
- component: {fileID: 634275950743134112}
|
||||
m_Layer: 5
|
||||
m_Name: AudioSelector
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &421876249768687115
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3396357262573175923}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5305278010342315827}
|
||||
m_RootOrder: 9
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: -128, y: 0}
|
||||
m_SizeDelta: {x: 64, y: 64}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!222 &8933658421904991632
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3396357262573175923}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &6749243352969479682
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3396357262573175923}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 2478420379614445965}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 3975575999960435775}
|
||||
m_TargetAssemblyTypeName: Display, Assembly-CSharp
|
||||
m_MethodName: SetWindowed
|
||||
m_Mode: 6
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &2478420379614445965
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3396357262573175923}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Texture: {fileID: 2800000, guid: 2172509423aef564cbffe0df01411020, type: 3}
|
||||
m_UVRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
--- !u!114 &3975575999960435775
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3396357262573175923}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 99247b6907a6da441af07cf95950880f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &634275950743134112
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3396357262573175923}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fc21ac8b706913b47897e9f83d170bc5, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
sources:
|
||||
- {fileID: 0}
|
||||
--- !u!1 &3686114034736848159
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1693,7 +1535,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
themeSelector: {fileID: 7285044980238930537}
|
||||
data:
|
||||
themeIndex: 8
|
||||
themeIndex: 0
|
||||
--- !u!1 &5305278009141335879
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1895,7 +1737,7 @@ RectTransform:
|
||||
- {fileID: 3507733486544043422}
|
||||
- {fileID: 3099289455289463194}
|
||||
- {fileID: 7200639167805561534}
|
||||
- {fileID: 421876249768687115}
|
||||
- {fileID: 5238569079413814885}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@@ -1981,6 +1823,168 @@ MonoBehaviour:
|
||||
vfxMenu: {fileID: 0}
|
||||
mouseHideTimeSeconds: 3
|
||||
mouseHideThreshold: 3
|
||||
--- !u!1 &6258673511580980956
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5238569079413814885}
|
||||
- component: {fileID: 1813467189418542979}
|
||||
- component: {fileID: 2660024567781865894}
|
||||
- component: {fileID: 883576059044723690}
|
||||
- component: {fileID: 9009658349614990470}
|
||||
- component: {fileID: 4584006364056922639}
|
||||
m_Layer: 5
|
||||
m_Name: AudioSource
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &5238569079413814885
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6258673511580980956}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 5305278010342315827}
|
||||
m_RootOrder: 9
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 1, y: 1}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: -128, y: 0}
|
||||
m_SizeDelta: {x: 64, y: 64}
|
||||
m_Pivot: {x: 1, y: 1}
|
||||
--- !u!222 &1813467189418542979
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6258673511580980956}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!114 &2660024567781865894
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6258673511580980956}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 883576059044723690}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls:
|
||||
- m_Target: {fileID: 4584006364056922639}
|
||||
m_TargetAssemblyTypeName: AudioSource, Assembly-CSharp
|
||||
m_MethodName: ToggleCaptureType
|
||||
m_Mode: 1
|
||||
m_Arguments:
|
||||
m_ObjectArgument: {fileID: 0}
|
||||
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||
m_IntArgument: 0
|
||||
m_FloatArgument: 0
|
||||
m_StringArgument:
|
||||
m_BoolArgument: 0
|
||||
m_CallState: 2
|
||||
--- !u!114 &883576059044723690
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6258673511580980956}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Texture: {fileID: 2800000, guid: 2172509423aef564cbffe0df01411020, type: 3}
|
||||
m_UVRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
--- !u!114 &9009658349614990470
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6258673511580980956}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 99247b6907a6da441af07cf95950880f, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &4584006364056922639
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6258673511580980956}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 66a6b9c6a6e18884ebeb1bf742e3be4d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
CaptureType: 0
|
||||
SpectrumSize: 128
|
||||
MinFrequency: 100
|
||||
MaxFrequency: 20000
|
||||
ScalingStrategy: 2
|
||||
Filters: []
|
||||
--- !u!1 &6466943970290633308
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
using Assets.WasapiAudio.Scripts.Unity;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioSelector : MonoBehaviour {
|
||||
public WasapiAudioSource[] sources;
|
||||
private int sources_i = 0;
|
||||
|
||||
void Awake() {
|
||||
sources_i = 0;
|
||||
Debug.Log($"{sources[sources_i]}");
|
||||
}
|
||||
|
||||
public void UseNextSource() {
|
||||
sources_i = (sources_i + 1) % sources.Length;
|
||||
}
|
||||
|
||||
public WasapiAudioSource CurrentSource() {
|
||||
return sources[sources_i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
using Assets.WasapiAudio.Scripts.Core;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class AudioSource : MonoBehaviour {
|
||||
public WasapiCaptureType CaptureType = WasapiCaptureType.Loopback;
|
||||
public int SpectrumSize = 32;
|
||||
public int MinFrequency = 100;
|
||||
public int MaxFrequency = 20000;
|
||||
public ScalingStrategy ScalingStrategy = ScalingStrategy.Sqrt;
|
||||
public WasapiAudioFilter[] Filters;
|
||||
|
||||
private WasapiAudio _wasapiAudio;
|
||||
private float[] _spectrumData;
|
||||
|
||||
public void Awake() {
|
||||
Initialise();
|
||||
}
|
||||
|
||||
void Initialise() {
|
||||
_wasapiAudio?.StopListen();
|
||||
|
||||
_wasapiAudio = new WasapiAudio(CaptureType, SpectrumSize, ScalingStrategy, MinFrequency, MaxFrequency, Filters, spectrumData =>
|
||||
{
|
||||
_spectrumData = spectrumData;
|
||||
});
|
||||
|
||||
_wasapiAudio.StartListen();
|
||||
}
|
||||
|
||||
public float[] GetSpectrumData() {
|
||||
return _spectrumData;
|
||||
}
|
||||
|
||||
void OnDestroy() {
|
||||
_wasapiAudio?.StopListen();
|
||||
}
|
||||
|
||||
public void ToggleCaptureType() {
|
||||
if (CaptureType == WasapiCaptureType.Loopback) {
|
||||
CaptureType = WasapiCaptureType.Microphone;
|
||||
} else {
|
||||
CaptureType = WasapiCaptureType.Loopback;
|
||||
}
|
||||
|
||||
Initialise();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66a6b9c6a6e18884ebeb1bf742e3be4d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -6,7 +6,7 @@ using UnityEngine.VFX;
|
||||
using UnityEngine;
|
||||
|
||||
[AddComponentMenu("VFX/Property Binders/Kaiju - Theme Binder")]
|
||||
[VFXBinder("Kaiju/Kaiju Theme Binder")]
|
||||
[VFXBinder("Kaiju/Kaiju - Theme Binder")]
|
||||
public class ThemeVfxBinder : VFXBinderBase {
|
||||
public Preferences preferences;
|
||||
|
||||
@@ -36,4 +36,8 @@ public class ThemeVfxBinder : VFXBinderBase {
|
||||
protected override void OnDisable() {
|
||||
// Debug.Log("OnDisable");
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "Kaiju VFX Theme Binder";
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ using UnityEngine.VFX.Utility;
|
||||
using Assets.WasapiAudio.Scripts.Unity;
|
||||
|
||||
[AddComponentMenu("VFX/Property Binders/Kaiju/VFX Spectrum Binder")]
|
||||
[VFXBinder("Kaiju/VFX Spectrum Binder")]
|
||||
[VFXBinder("Kaiju/Kaiju - VFX Spectrum Binder")]
|
||||
public class VfxSpectrumBinder : VfxAudioVisualizationEffect {
|
||||
[VFXPropertyBinding("System.UInt32"), SerializeField]
|
||||
protected ExposedProperty SpectrumSizeParameter = "SpectrumSize";
|
||||
@@ -67,6 +67,6 @@ public class VfxSpectrumBinder : VfxAudioVisualizationEffect {
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return "Audio Spectrum Data";
|
||||
return "Kaiju VFX Spectrum Binder";
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,7 @@ namespace Assets.WasapiAudio.Scripts.Unity
|
||||
public abstract class VfxAudioVisualizationEffect : VFXBinderBase
|
||||
{
|
||||
// Inspector Properties
|
||||
public AudioSelector selector;
|
||||
WasapiAudioSource WasapiAudioSource;
|
||||
public AudioSource source;
|
||||
|
||||
[SerializeReference]
|
||||
[SerializeReferenceButton]
|
||||
@@ -21,20 +20,18 @@ namespace Assets.WasapiAudio.Scripts.Unity
|
||||
protected int SpectrumSize { get; private set; }
|
||||
|
||||
public override bool IsValid(VisualEffect component) {
|
||||
return selector != null
|
||||
&& selector.CurrentSource() != null;
|
||||
return source != null;
|
||||
}
|
||||
|
||||
public override void UpdateBinding(VisualEffect component) {
|
||||
WasapiAudioSource = selector.CurrentSource();
|
||||
SpectrumSize = WasapiAudioSource.SpectrumSize;
|
||||
SpectrumSize = source.SpectrumSize;
|
||||
Preview = new SpectrumData();
|
||||
}
|
||||
|
||||
protected float[] GetSpectrumData()
|
||||
{
|
||||
// Get raw / unmodified spectrum data
|
||||
var spectrumData = WasapiAudioSource.GetSpectrumData();
|
||||
var spectrumData = source.GetSpectrumData();
|
||||
|
||||
// Run spectrum data through all configured transformers
|
||||
if (Transformers != null && Transformers.Count > 0)
|
||||
|
||||
Reference in new issue
Block a user