Fix equalizers showing inverted values

This commit is contained in:
Flamefire committed 2014-03-23 13:00:58 +01:00
1 parent 3dba30d58e
commit 50494d902b
3 files changed
+38 -26

No files matched your search

+24 -16
View File
@@ -22,7 +22,7 @@ namespace VocaluxeLib.Menu
{
enum EEqualizerStyle
{
Collums
Columns
}
struct SThemeEqualizer
@@ -64,6 +64,8 @@ namespace VocaluxeLib.Menu
}
private float[] _Bars;
private int _MaxBar;
private float _MaxVolume;
public CEqualizer(int partyModeID)
{
@@ -211,17 +213,31 @@ namespace VocaluxeLib.Menu
return false;
}
public void Update(float[] weights)
public void Update(float[] weights, float volume)
{
if (weights == null || weights.Length == 0 || _Bars == null)
return;
if (volume < 0.001)
return;
if (volume > _MaxVolume)
_MaxVolume = volume;
_MaxBar = 0;
float maxVal = -99f;
for (int i = 0; i < _Bars.Length; i++)
{
if (weights.Length > i)
{
_Bars[i] = 1f - weights[i];
if (_Theme.DrawNegative == EOffOn.TR_CONFIG_OFF && weights[i] < 0)
_Bars[i] = 1f + weights[i];
_Bars[i] = 0f;
else
{
_Bars[i] = weights[i] * volume / _MaxVolume;
if (_Bars[i] > maxVal)
{
maxVal = _Bars[i];
_MaxBar = i;
}
}
}
else
_Bars[i] = 0f;
@@ -235,30 +251,22 @@ namespace VocaluxeLib.Menu
for (int i = 0; i < _Bars.Length; i++)
_Bars[i] = 0f;
_MaxBar = 0;
_MaxVolume = 0f;
}
public void Draw()
{
if (_Bars == null || _Theme.Style != EEqualizerStyle.Collums)
if (_Bars == null || _Theme.Style != EEqualizerStyle.Columns)
return;
float dx = Rect.W / _Bars.Length;
int max = _Bars.Length - 1;
float maxB = _Bars[max];
for (int i = 0; i < _Bars.Length - 1; i++)
{
if (_Bars[i] > maxB)
{
maxB = _Bars[i];
max = i;
}
}
for (int i = 0; i < _Bars.Length; i++)
{
var bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z);
SColorF color = Color;
if (i == max)
if (i == _MaxBar)
color = MaxColor;
CBase.Drawing.DrawColor(color, bar);