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

+1 -1
View File
@@ -547,7 +547,7 @@ namespace Vocaluxe.Screens
for (int i = 1; i <= CGame.NumPlayer; i++)
{
CRecord.AnalyzeBuffer(i - 1);
_Equalizers["EqualizerPlayer" + i].Update(CRecord.ToneWeigth(i - 1));
_Equalizers["EqualizerPlayer" + i].Update(CRecord.ToneWeigth(i - 1), CRecord.GetMaxVolume(i - 1));
}
return true;
}
+13 -9
View File
@@ -223,25 +223,29 @@ namespace Vocaluxe.Screens
if (_CheckMicConfig())
{
_ChannelEnergy[0] = 0f;
int player = _SelectSlides[_SelectSlideRecordChannel1].Selection;
if (player > 0)
int player = _SelectSlides[_SelectSlideRecordChannel1].Selection - 1;
if (player >= 0)
{
_ChannelEnergy[0] = CRecord.GetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel1].Update(CRecord.ToneWeigth(player - 1));
_ChannelEnergy[0] = CRecord.GetMaxVolume(player);
_Equalizers[_EqualizerChannel1].Update(CRecord.ToneWeigth(player), CRecord.GetMaxVolume(player));
}
else
{
_ChannelEnergy[0] = 0f;
_Equalizers[_EqualizerChannel1].Reset();
}
_ChannelEnergy[1] = 0f;
player = _SelectSlides[_SelectSlideRecordChannel2].Selection;
if (player > 0)
player = _SelectSlides[_SelectSlideRecordChannel2].Selection - 1;
if (player >= 0)
{
_ChannelEnergy[1] = CRecord.GetMaxVolume(player - 1);
_Equalizers[_EqualizerChannel2].Update(CRecord.ToneWeigth(player - 1));
_Equalizers[_EqualizerChannel2].Update(CRecord.ToneWeigth(player), CRecord.GetMaxVolume(player));
}
else
{
_ChannelEnergy[1] = 0f;
_Equalizers[_EqualizerChannel2].Reset();
}
}
else
{
+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);