init
This commit is contained in:
commit
e58a138bea
176 files changed
+6194
No files matched your search
@@ -0,0 +1,28 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.WasapiAudio.Scripts.Unity.Transformers
|
||||
{
|
||||
[Serializable]
|
||||
public class CurveScaledSpectrumTransformer : SpectrumTransformer
|
||||
{
|
||||
public AnimationCurve ScaleCurve;
|
||||
|
||||
protected override void PerformTransform(float[] input, ref float[] output)
|
||||
{
|
||||
if (ScaleCurve == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var scaleStep = 1.0f / input.Length;
|
||||
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
{
|
||||
var scaledValue = ScaleCurve.Evaluate(scaleStep * i) * input[i];
|
||||
|
||||
output[i] = scaledValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 565fed8317271174792674bb2bc0e5af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.WasapiAudio.Scripts.Unity.Transformers
|
||||
{
|
||||
[Serializable]
|
||||
public class PercentileBoostSpectrumTransformer : SpectrumTransformer
|
||||
{
|
||||
private float[] _sortedPercentileArray;
|
||||
|
||||
[Range(0.0f, 1.0f)]
|
||||
public float Percentile = 0.5f;
|
||||
public float BelowPercentileMultiplier = 0.5f;
|
||||
public float AbovePercentileMultiplier = 2.0f;
|
||||
|
||||
protected override void PerformTransform(float[] input, ref float[] output)
|
||||
{
|
||||
if (_sortedPercentileArray == null || _sortedPercentileArray.Length != input.Length)
|
||||
{
|
||||
_sortedPercentileArray = new float[input.Length];
|
||||
}
|
||||
|
||||
input.CopyTo(_sortedPercentileArray, 0);
|
||||
|
||||
var percentile = GetPercentile(_sortedPercentileArray, Percentile);
|
||||
|
||||
for (int i = 0; i < input.Length; i++)
|
||||
{
|
||||
if (input[i] < percentile)
|
||||
{
|
||||
output[i] = input[i] * BelowPercentileMultiplier;
|
||||
}
|
||||
else
|
||||
{
|
||||
output[i] = input[i] * AbovePercentileMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public float GetPercentile(float[] sequence, float percentile)
|
||||
{
|
||||
Array.Sort(sequence);
|
||||
|
||||
var length = sequence.Length;
|
||||
var n = (length - 1) * percentile + 1;
|
||||
|
||||
// Another method: double n = (N + 1) * excelPercentile;
|
||||
if (n == 1.0f)
|
||||
{
|
||||
return sequence[0];
|
||||
}
|
||||
|
||||
if (n == length)
|
||||
{
|
||||
return sequence[length - 1];
|
||||
}
|
||||
|
||||
int k = (int)n;
|
||||
float d = n - k;
|
||||
|
||||
return sequence[k - 1] + d * (sequence[k] - sequence[k - 1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ac3cd62c87d1ef54f90e71e71fe2000b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using Assets.WasapiAudio.Scripts.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.WasapiAudio.Scripts.Unity.Transformers
|
||||
{
|
||||
[Serializable]
|
||||
public class SmoothSpectrumTransformer : SpectrumTransformer
|
||||
{
|
||||
private SpectrumSmoother _smoother;
|
||||
|
||||
[Range(1, 50)]
|
||||
public byte Iterations = 1;
|
||||
|
||||
protected override void PerformTransform(float[] input, ref float[] output)
|
||||
{
|
||||
if (_smoother == null || _smoother.SmoothingIterations != Iterations)
|
||||
{
|
||||
_smoother = new SpectrumSmoother(input.Length, Iterations);
|
||||
}
|
||||
|
||||
output = _smoother.GetSpectrumData(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a86e967af4ca4f4ab907c1a6d5a77aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user