some drawing changes and other improvements

This commit is contained in:
Alexander Eckart committed 2012-04-28 12:50:39 +02:00
1 parent 9448e4054b
commit 9154243a7f
3 files changed
+55 -15

No files matched your search

+1 -1
View File
@@ -215,7 +215,7 @@ namespace Vocaluxe.Base
// Record
public static SMicConfig[] MicConfig;
public static int MicDelay = 200; //[ms]
public static int MicDelay = 300; //[ms]
//Lists to save parameters and values
private static List<string> _Params = new List<string>();
+27 -10
View File
@@ -295,7 +295,7 @@ namespace Vocaluxe.Base
private const int _NumHalfTones = 47;
private float[] _ToneWeigth;
private Int16[] _AnalysisBuffer = new Int16[4096];
private Int16[] _AnalysisBuffer = new Int16[4096*2];
private Object _AnalysisBufferLock = new Object();
private bool _ToneValid = false;
@@ -490,7 +490,9 @@ namespace Vocaluxe.Base
// prepare to analyze
double MaxWeight = -1.0;
int MaxTone = 0;
double MinWeight = 1.0;
int MaxTone = -1;
float[] Weigth = new float[_NumHalfTones];
// analyze halftones
// Note: at the lowest tone (~65Hz) and a buffer-size of 4096
@@ -502,18 +504,33 @@ namespace Vocaluxe.Base
double CurFreq = _BaseToneFreq * Math.Pow(HalftoneBase, ToneIndex);
double CurWeight = AnalyzeAutocorrelationFreq(CurFreq);
// TODO: prefer higher frequencies (use >= or use downto)
if (CurWeight > MaxWeight /* && (Math.Abs(ToneIndex - _ToneAbs) < 5 || _ToneAbs == 0)*/)
{
// this frequency has a higher weight
if (CurWeight > MaxWeight)
MaxWeight = CurWeight;
MaxTone = ToneIndex;
}
_ToneWeigth[ToneIndex] = (float)CurWeight;
if (CurWeight < MinWeight)
MinWeight = CurWeight;
Weigth[ToneIndex] = (float)CurWeight;
}
if (valid)
if (valid && MaxWeight - MinWeight > 0.05)
{
int m = -1;
float prev = 0f;
for (int i = 0; i < Weigth.Length; i++)
{
if (Weigth[i] < prev && i > 0)
{
m = i;
MaxTone = i;
}
if (i == Weigth.Length - 1 && m == -1)
MaxTone = i;
prev = Weigth[i];
_ToneWeigth[i] = Weigth[i];
}
_ToneAbs = MaxTone;
_Tone = MaxTone % 12;
_ToneValid = true;
+27 -4
View File
@@ -278,6 +278,8 @@ namespace Vocaluxe.Screens
ChannelEnergy[0] = CSound.RecordGetMaxVolume(player - 1);
_Equalizer[0].Update(CSound.ToneWeigth(player - 1));
}
else
_Equalizer[0].Reset();
ChannelEnergy[1] = 0f;
player = SelectSlides[htSelectSlides(SelectSlideRecordChannel2)].Selection;
@@ -286,6 +288,8 @@ namespace Vocaluxe.Screens
ChannelEnergy[1] = CSound.RecordGetMaxVolume(player - 1);
_Equalizer[1].Update(CSound.ToneWeigth(player - 1));
}
else
_Equalizer[1].Reset();
}
else
{
@@ -361,7 +365,7 @@ namespace Vocaluxe.Screens
for (int i = 0; i < _Equalizer.Length; i++)
{
_Equalizer[i] = new Equalizer(new SRectF(50 + 300 * i, 400, 250, 150, -1), CSound.NumHalfTones(0), 1);
_Equalizer[i] = new Equalizer(new SRectF(50 + 350 * i, 400, 230, 150, -1), CSound.NumHalfTones(0), 2);
}
}
@@ -600,6 +604,7 @@ namespace Vocaluxe.Screens
public Equalizer(SRectF bounds, int numBars, float space)
{
_Bounds = bounds;
_Space = space;
if (numBars > 0)
_Bars = new float[numBars];
@@ -644,12 +649,30 @@ namespace Vocaluxe.Screens
if (_Bars == null)
return;
float dx = _Bounds.W / _Bars.Length;
float dx = _Bounds.W / _Bars.Length + _Space;
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++)
{
SRectF bar = new SRectF(_Bounds.X + dx * i, _Bounds.Y + _Bounds.H - _Bars[i] * _Bounds.H, dx, _Bars[i] * _Bounds.H, _Bounds.Z);
CDraw.DrawColor(new SColorF(1f, 1f, 1f, 1f), bar);
SRectF bar = new SRectF(_Bounds.X + dx * i, _Bounds.Y + _Bounds.H - _Bars[i] * _Bounds.H, dx - _Space, _Bars[i] * _Bounds.H, _Bounds.Z);
SColorF color = new SColorF(1f, 1f, 1f, 1f);
if (i == max)
{
color.B = 0f;
color.G = 0f;
}
CDraw.DrawColor(color, bar);
}
}
}