some more test with pitch detection, new line bonus calculation
This commit is contained in:
1 parent
9154243a7f
commit
2c4e0d8708
2 files changed
+71
-42
No files matched your search
+37
-11
@@ -16,6 +16,8 @@ namespace Vocaluxe.Base
|
|||||||
public string Name;
|
public string Name;
|
||||||
public EGameDifficulty Difficulty;
|
public EGameDifficulty Difficulty;
|
||||||
public double Points;
|
public double Points;
|
||||||
|
public double PointsLineBonus;
|
||||||
|
public double PointsGoldenNotes;
|
||||||
public int NoteDiff;
|
public int NoteDiff;
|
||||||
public int LineNr;
|
public int LineNr;
|
||||||
public List<CLine> SingLine;
|
public List<CLine> SingLine;
|
||||||
@@ -213,6 +215,8 @@ namespace Vocaluxe.Base
|
|||||||
for (int i = 0; i < _Player.Length; i++)
|
for (int i = 0; i < _Player.Length; i++)
|
||||||
{
|
{
|
||||||
_Player[i].Points = 0f;
|
_Player[i].Points = 0f;
|
||||||
|
_Player[i].PointsLineBonus = 0f;
|
||||||
|
_Player[i].PointsGoldenNotes = 0f;
|
||||||
_Player[i].LineNr = 0;
|
_Player[i].LineNr = 0;
|
||||||
_Player[i].NoteDiff = 0;
|
_Player[i].NoteDiff = 0;
|
||||||
_Player[i].SingLine = new List<CLine>();
|
_Player[i].SingLine = new List<CLine>();
|
||||||
@@ -247,7 +251,7 @@ namespace Vocaluxe.Base
|
|||||||
CSound.AnalyzeBuffer(p);
|
CSound.AnalyzeBuffer(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_OldBeatD == _CurrentBeatD)
|
if (_OldBeatD >= _CurrentBeatD)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int p = 0; p < _NumPlayer; p++)
|
for (int p = 0; p < _NumPlayer; p++)
|
||||||
@@ -321,8 +325,12 @@ namespace Vocaluxe.Base
|
|||||||
if (_Player[p].NoteDiff <= (2 - (int)_Player[p].Difficulty))
|
if (_Player[p].NoteDiff <= (2 - (int)_Player[p].Difficulty))
|
||||||
{
|
{
|
||||||
// valid
|
// valid
|
||||||
CSound.RecordSetTone(p, Tone);
|
//CSound.RecordSetTone(p, Tone);
|
||||||
_Player[p].Points += (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[Note].PointsForBeat / (double)song.Notes.GetLines(_Player[p].LineNr).Points;
|
double points = (CSettings.MaxScore - CSettings.LinebonusScore) * (double)notes[Note].PointsForBeat / (double)song.Notes.GetLines(_Player[p].LineNr).Points;
|
||||||
|
if (notes[Note].NoteType == ENoteType.Golden)
|
||||||
|
_Player[p].PointsGoldenNotes += points;
|
||||||
|
|
||||||
|
_Player[p].Points += points;
|
||||||
|
|
||||||
// update player notes (sung notes)
|
// update player notes (sung notes)
|
||||||
if (_Player[p].SingLine[Line].NoteCount > 0)
|
if (_Player[p].SingLine[Line].NoteCount > 0)
|
||||||
@@ -342,11 +350,6 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
_Player[p].SingLine[Line].LastNote.IsPerfect(notes[Note]);
|
_Player[p].SingLine[Line].LastNote.IsPerfect(notes[Note]);
|
||||||
_Player[p].SingLine[Line].IsPerfect(lines[Line]);
|
_Player[p].SingLine[Line].IsPerfect(lines[Line]);
|
||||||
|
|
||||||
if (_Player[p].SingLine[Line].PerfectLine)
|
|
||||||
{
|
|
||||||
_Player[p].Points += CSettings.LinebonusScore * (double)lines[Line].Points / (double)song.Notes.GetPoints(_Player[p].LineNr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -354,7 +357,7 @@ namespace Vocaluxe.Base
|
|||||||
{
|
{
|
||||||
CNote nt = _Player[p].SingLine[Line].LastNote;
|
CNote nt = _Player[p].SingLine[Line].LastNote;
|
||||||
if (nt.EndBeat + 1 != beat || nt.Hit)
|
if (nt.EndBeat + 1 != beat || nt.Hit)
|
||||||
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, notes[Note].NoteType));
|
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (nt.Tone == TonePlayer && nt.EndBeat + 1 == beat)
|
if (nt.Tone == TonePlayer && nt.EndBeat + 1 == beat)
|
||||||
@@ -363,17 +366,40 @@ namespace Vocaluxe.Base
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, notes[Note].NoteType));
|
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, notes[Note].NoteType));
|
_Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Line Bonus
|
||||||
|
if (Note == lines[Line].NoteCount - 1)
|
||||||
|
{
|
||||||
|
if (notes[Note].EndBeat == beat)
|
||||||
|
{
|
||||||
|
double factor = (double)_Player[p].SingLine[Line].Points / (double)song.Notes.GetPoints(_Player[p].LineNr);
|
||||||
|
if (factor < 0.4)
|
||||||
|
factor = 0.0;
|
||||||
|
else if (factor > 0.9)
|
||||||
|
factor = 1.0;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
factor -= 0.4;
|
||||||
|
factor *= 2;
|
||||||
|
factor *= factor;
|
||||||
|
}
|
||||||
|
|
||||||
|
double points = CSettings.LinebonusScore * factor;
|
||||||
|
_Player[p].Points += points;
|
||||||
|
_Player[p].PointsLineBonus += points;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+34
-31
@@ -295,7 +295,7 @@ namespace Vocaluxe.Base
|
|||||||
private const int _NumHalfTones = 47;
|
private const int _NumHalfTones = 47;
|
||||||
|
|
||||||
private float[] _ToneWeigth;
|
private float[] _ToneWeigth;
|
||||||
private Int16[] _AnalysisBuffer = new Int16[4096*2];
|
private Int16[] _AnalysisBuffer = new Int16[4096 * 4];
|
||||||
private Object _AnalysisBufferLock = new Object();
|
private Object _AnalysisBufferLock = new Object();
|
||||||
|
|
||||||
private bool _ToneValid = false;
|
private bool _ToneValid = false;
|
||||||
@@ -425,30 +425,25 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
lock (_AnalysisBufferLock)
|
lock (_AnalysisBufferLock)
|
||||||
{
|
{
|
||||||
try
|
Add(buffer);
|
||||||
|
|
||||||
|
int len = _AnalysisBuffer.Length * 2;
|
||||||
|
if (_Stream.Length >= len)
|
||||||
{
|
{
|
||||||
// move old samples to the beginning of the array (if necessary)
|
byte[] buf = new byte[len];
|
||||||
for (int i = 0; i < _AnalysisBuffer.Length - SampleCount; i++)
|
_Stream.Position -= len;
|
||||||
{
|
_Stream.Read(buf, 0, len);
|
||||||
_AnalysisBuffer[i] = _AnalysisBuffer[i + SampleCount];
|
|
||||||
}
|
|
||||||
|
|
||||||
byte[] b = new byte[2];
|
byte[] b = new byte[2];
|
||||||
// copy new samples to analysis buffer
|
for (int i = 0; i < _AnalysisBuffer.Length; i++)
|
||||||
for (int i = 0; i < SampleCount; i++)
|
|
||||||
{
|
{
|
||||||
b[0] = buffer[BufferOffset + i * 2];
|
b[0] = buf[i * 2];
|
||||||
b[1] = buffer[BufferOffset + i * 2 + 1];
|
b[1] = buf[i * 2 + 1];
|
||||||
|
|
||||||
_AnalysisBuffer[_AnalysisBuffer.Length - SampleCount + i] = BitConverter.ToInt16(b, 0);
|
_AnalysisBuffer[i] = BitConverter.ToInt16(b, 0);
|
||||||
}
|
}
|
||||||
|
_NewSamples = true;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
Add(buffer);
|
|
||||||
_NewSamples = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +465,7 @@ namespace Vocaluxe.Base
|
|||||||
_MaxVolume = Volume;
|
_MaxVolume = Volume;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_MaxVolume >= 0.05f)
|
if (_MaxVolume >= 0.02f)
|
||||||
AnalyzeByAutocorrelation(true);
|
AnalyzeByAutocorrelation(true);
|
||||||
else
|
else
|
||||||
AnalyzeByAutocorrelation(false);
|
AnalyzeByAutocorrelation(false);
|
||||||
@@ -513,27 +508,35 @@ namespace Vocaluxe.Base
|
|||||||
Weigth[ToneIndex] = (float)CurWeight;
|
Weigth[ToneIndex] = (float)CurWeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid && MaxWeight - MinWeight > 0.05)
|
if (valid && MaxWeight - MinWeight > 0.01)
|
||||||
{
|
{
|
||||||
int m = -1;
|
int m = -1;
|
||||||
float prev = 0f;
|
float prev = -1f;
|
||||||
|
bool raising = false;
|
||||||
for (int i = 0; i < Weigth.Length; i++)
|
for (int i = 0; i < Weigth.Length; i++)
|
||||||
{
|
{
|
||||||
if (Weigth[i] < prev && i > 0)
|
if (i > 0 && Weigth[i] > prev)
|
||||||
{
|
raising = true;
|
||||||
m = i;
|
|
||||||
MaxTone = i;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == Weigth.Length - 1 && m == -1)
|
if (Weigth[i] < prev && raising)
|
||||||
MaxTone = i;
|
{
|
||||||
|
m = i-1;
|
||||||
|
MaxTone = i-1;
|
||||||
|
raising = false;
|
||||||
|
}
|
||||||
|
|
||||||
prev = Weigth[i];
|
prev = Weigth[i];
|
||||||
_ToneWeigth[i] = Weigth[i];
|
_ToneWeigth[i] = Weigth[i];
|
||||||
}
|
}
|
||||||
_ToneAbs = MaxTone;
|
|
||||||
_Tone = MaxTone % 12;
|
if (m != -1)
|
||||||
_ToneValid = true;
|
{
|
||||||
|
_ToneAbs = MaxTone;
|
||||||
|
_Tone = MaxTone % 12;
|
||||||
|
_ToneValid = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
_ToneValid = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_ToneValid = false;
|
_ToneValid = false;
|
||||||
|
|||||||
Reference in new issue
Block a user