fixed linebonus calculation,

set frames per buffer to 1024 on capturing
This commit is contained in:
Alexander Eckart committed 2012-05-01 19:26:31 +02:00
1 parent 3d010122c7
commit 74fe5fc962
6 files changed
+61 -19

No files matched your search

+6 -5
View File
@@ -379,11 +379,12 @@ namespace Vocaluxe.Base
}
// Line Bonus
if (Note == lines[Line].NoteCount - 1)
int NumLinesWithPoints = song.Notes.GetNumLinesWithPoints(_Player[p].LineNr);
if (Note == lines[Line].NoteCount - 1 && NumLinesWithPoints > 0)
{
if (notes[Note].EndBeat == beat)
if (notes[Note].EndBeat == beat && lines[Line].Points > 0f)
{
double factor = (double)_Player[p].SingLine[Line].Points / (double)song.Notes.GetPoints(_Player[p].LineNr);
double factor = (double)_Player[p].SingLine[Line].Points / (double)lines[Line].Points;
if (factor < 0.4)
factor = 0.0;
else if (factor > 0.9)
@@ -394,8 +395,8 @@ namespace Vocaluxe.Base
factor *= 2;
factor *= factor;
}
double points = CSettings.LinebonusScore * factor;
double points = CSettings.LinebonusScore * factor * 1f / NumLinesWithPoints;
_Player[p].Points += points;
_Player[p].PointsLineBonus += points;
}
+21 -10
View File
@@ -295,7 +295,7 @@ namespace Vocaluxe.Base
private const int _NumHalfTones = 47;
private float[] _ToneWeigth;
private Int16[] _AnalysisBuffer = new Int16[4096 * 4];
private Int16[] _AnalysisBuffer = new Int16[4096];
private Object _AnalysisBufferLock = new Object();
private bool _ToneValid = false;
@@ -414,15 +414,6 @@ namespace Vocaluxe.Base
//if (assigned(fVoiceStream)) then
//fVoiceStream.WriteData(Buffer, BufferSize);
int BufferOffset = 0;
int SampleCount = (int)Math.Floor(buffer.Length / 2.0);
if (SampleCount > _AnalysisBuffer.Length)
{
BufferOffset = (SampleCount - _AnalysisBuffer.Length) * 2;
SampleCount = _AnalysisBuffer.Length;
}
lock (_AnalysisBufferLock)
{
Add(buffer);
@@ -500,7 +491,10 @@ namespace Vocaluxe.Base
double CurWeight = AnalyzeAutocorrelationFreq(CurFreq);
if (CurWeight > MaxWeight)
{
MaxWeight = CurWeight;
MaxTone = ToneIndex;
}
if (CurWeight < MinWeight)
MinWeight = CurWeight;
@@ -508,6 +502,21 @@ namespace Vocaluxe.Base
Weigth[ToneIndex] = (float)CurWeight;
}
if (valid && MaxWeight - MinWeight > 0.01)
{
for (int i = 0; i < Weigth.Length; i++)
{
_ToneWeigth[i] = Weigth[i];
}
_ToneAbs = MaxTone;
_Tone = MaxTone % 12;
_ToneValid = true;
}
else
_ToneValid = false;
/*
if (valid && MaxWeight - MinWeight > 0.01)
{
int m = -1;
@@ -537,9 +546,11 @@ namespace Vocaluxe.Base
}
else
_ToneValid = false;
}
else
_ToneValid = false;
* */
}
private double AnalyzeAutocorrelationFreq(double Freq)
+7 -1
View File
@@ -22,7 +22,9 @@ namespace Vocaluxe.GameModes
_Rounds[round, player].ProfileID = Player[player].ProfileID;
_Rounds[round, player].Name = Player[player].Name;
_Rounds[round, player].Difficulty = Player[player].Difficulty;
_Rounds[round, player].Points = 0;
_Rounds[round, player].Points = 0f;
_Rounds[round, player].PointsGoldenNotes = 0f;
_Rounds[round, player].PointsLineBonus = 0f;
_Rounds[round, player].Medley = false;
_Rounds[round, player].Duet = false;
_Rounds[round, player].SongFinished = false;
@@ -38,6 +40,8 @@ namespace Vocaluxe.GameModes
_Rounds[Round, player].SongID = SongID;
_Rounds[Round, player].LineNr = Player[player].LineNr;
_Rounds[Round, player].Points = Player[player].Points;
_Rounds[Round, player].PointsGoldenNotes = Player[player].PointsGoldenNotes;
_Rounds[Round, player].PointsLineBonus = Player[player].PointsLineBonus;
_Rounds[Round, player].Medley = Medley;
_Rounds[Round, player].Duet = Duet;
_Rounds[Round, player].DateTicks = DateTicks;
@@ -68,6 +72,8 @@ namespace Vocaluxe.GameModes
{
player[p].Name = _Rounds[Round, p].Name;
player[p].Points = _Rounds[Round, p].Points;
player[p].PointsGoldenNotes = _Rounds[Round, p].PointsGoldenNotes;
player[p].PointsLineBonus = _Rounds[Round, p].PointsLineBonus;
player[p].SongID = _Rounds[Round, p].SongID;
player[p].LineNr = _Rounds[Round, p].LineNr;
player[p].Difficulty = _Rounds[Round, p].Difficulty;
+22
View File
@@ -33,6 +33,14 @@ namespace Vocaluxe.Lib.Song
return _Lines[Index].Points;
}
public int GetNumLinesWithPoints(int Index)
{
if (Index >= _Lines.Count)
return 0;
return _Lines[Index].NumLinesWithPoints;
}
public void AddLines(CLines Lines)
{
_Lines.Add(Lines);
@@ -545,6 +553,20 @@ namespace Vocaluxe.Lib.Song
}
}
public int NumLinesWithPoints
{
get
{
int num = 0;
foreach (CLine line in _Lines)
{
if (line.Points > 0f)
num++;
}
return num;
}
}
#region Methods
public void AddLine(CLine Line)
{
+3 -2
View File
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
@@ -90,6 +91,7 @@ namespace Vocaluxe.Lib.Sound
CLog.LogError("Error initializing PortAudio: " + e.Message);
return false;
}
return true;
}
@@ -151,7 +153,7 @@ namespace Vocaluxe.Lib.Sound
ref inputParams,
IntPtr.Zero,
44100,
PortAudio.paFramesPerBufferUnspecified,
1024,
PortAudio.PaStreamFlags.paNoFlag,
_myRecProc,
new IntPtr(i))))
@@ -161,7 +163,6 @@ namespace Vocaluxe.Lib.Sound
return false;
}
}
return result;
}
+2 -1
View File
@@ -256,7 +256,8 @@ namespace Vocaluxe.Screens
_DelayTest[i].Timer.Stop();
_DelayTestRunning = false;
}
else if (CSound.RecordGetMaxVolume(player - 1) > 0.4f && CSound.RecordGetToneAbs(player - 1) == 9)
else if (CSound.RecordGetMaxVolume(player - 1) > 0.1f &&
(CSound.RecordGetToneAbs(player - 1) == 9 || CSound.RecordGetToneAbs(player - 1) == 21 || CSound.RecordGetToneAbs(player - 1) == 33))
{
_DelayTest[i].Delay = _DelayTest[i].Timer.ElapsedMilliseconds;
_DelayTest[i].Timer.Stop();