Fix overlapping notes

More consistent CLyric
Some renaming for clearer meaning
This commit is contained in:
Flamefire committed 2013-10-11 14:50:27 +02:00
1 parent bf1c00b5d1
commit 55d5c61a66
11 files changed
+177 -201

No files matched your search

+4
View File
@@ -15,6 +15,8 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
namespace VocaluxeLib.Songs
{
/// <summary>
@@ -38,6 +40,8 @@ namespace VocaluxeLib.Songs
StartBeat = startBeat;
Duration = duration;
Tone = tone;
if (Duration < 1)
throw new Exception("Note to short. All notes should be at least 1 beat long!");
}
#endregion Constructors
+5 -1
View File
@@ -79,7 +79,11 @@ namespace VocaluxeLib.Songs
#endregion Properties
#region Methods
//Find last note with StartBeat<=Beat
/// <summary>
/// Find last note with StartBeat<=Beat
/// </summary>
/// <param name="beat"></param>
/// <returns>Note index of last note with StartBeat<=Beat or -1 if all notes start after beat</returns>
public int FindPreviousNote(int beat)
{
//If no notes -> No previous note
+29 -22
View File
@@ -628,33 +628,40 @@ namespace VocaluxeLib.Songs
sr.Read();
string paramS = sr.ReadLine();
ENoteType noteType;
if (tempC.CompareTo('*') == 0)
noteType = ENoteType.Golden;
else if (tempC.CompareTo('F') == 0)
noteType = ENoteType.Freestyle;
if (param2 < 1)
CBase.Log.LogError("Warning! Ignored note in song because length is < 1. Line No.: " + fileLineNo + ": " + filePath);
else
noteType = ENoteType.Normal;
if (Relative == EOffOn.TR_CONFIG_ON)
param1 += currentPos;
int curPlayer = 0;
int tmpPlayer = player;
//Evaluate as bitset
while (tmpPlayer > 0)
{
if ((tmpPlayer & 1) != 0)
ENoteType noteType;
if (tempC.CompareTo('*') == 0)
noteType = ENoteType.Golden;
else if (tempC.CompareTo('F') == 0)
noteType = ENoteType.Freestyle;
else
noteType = ENoteType.Normal;
if (Relative == EOffOn.TR_CONFIG_ON)
param1 += currentPos;
int curPlayer = 0;
int tmpPlayer = player;
//Evaluate as bitset
while (tmpPlayer > 0)
{
if (!_ParseNote(curPlayer, noteType, param1, param2, param3, paramS))
CBase.Log.LogError("Warning! Ignored note for player " + (curPlayer + 1) + " in song because it overlaps with other note. Line No.: " +
fileLineNo + ": " + filePath);
if ((tmpPlayer & 1) != 0)
{
if (!_ParseNote(curPlayer, noteType, param1, param2, param3, paramS))
{
CBase.Log.LogError("Warning! Ignored note for player " + (curPlayer + 1) + " in song because it overlaps with other note. Line No.: " +
fileLineNo + ": " + filePath);
}
}
tmpPlayer >>= 1;
curPlayer++;
}
tmpPlayer >>= 1;
curPlayer++;
isNewSentence = false;
}
isNewSentence = false;
break;
case '-':
if (isNewSentence)
+12 -5
View File
@@ -77,12 +77,19 @@ namespace VocaluxeLib.Songs
_Notes.Add(note);
else
{
//Insert AFTER this note
int insPos = FindPreviousNote(note.StartBeat);
//Check for overlapping notes
if (insPos >= 0 && _Notes[insPos].EndBeat > note.StartBeat)
return false;
if (insPos < _Notes.Count - 1 && _Notes[insPos + 1].StartBeat > note.EndBeat)
return false;
if (insPos >= 0) //Check note before
{
if (_Notes[insPos].EndBeat > note.StartBeat)
return false;
}
if (insPos < _Notes.Count - 1) //Check note after
{
if (_Notes[insPos + 1].StartBeat < note.EndBeat)
return false;
}
_Notes.Insert(insPos + 1, note);
}
return true;
@@ -91,7 +98,7 @@ namespace VocaluxeLib.Songs
public void SetMedley(int startBeat, int endBeat)
{
foreach (CSongNote note in _Notes.Where(note => note.StartBeat < startBeat || note.EndBeat > endBeat))
note.NoteType = ENoteType.Freestyle;
note.Type = ENoteType.Freestyle;
VisibleInTimeLine = FirstNoteBeat >= startBeat && LastNoteBeat <= endBeat;
}
+4 -4
View File
@@ -25,20 +25,20 @@ namespace VocaluxeLib.Songs
#region Contructors
public CSongNote(CSongNote note) : base(note)
{
NoteType = note.NoteType;
Type = note.Type;
Text = note.Text;
}
public CSongNote(int startBeat, int duration, int tone, string text, ENoteType noteType)
: base(startBeat, duration, tone)
{
NoteType = noteType;
Type = noteType;
Text = text;
}
#endregion Constructors
#region Properties
public ENoteType NoteType { get; set; }
public ENoteType Type { get; set; }
public string Text { get; set; }
@@ -46,7 +46,7 @@ namespace VocaluxeLib.Songs
{
get
{
switch (NoteType)
switch (Type)
{
case ENoteType.Normal:
return 1;
+2
View File
@@ -122,6 +122,8 @@ namespace VocaluxeLib.Songs
public bool AddNote(CSongNote note, bool updateTimings = false)
{
int lineIndex = FindPreviousLine(note.StartBeat);
if (lineIndex + 1 < _Lines.Count && _Lines[lineIndex + 1].FirstNoteBeat < note.EndBeat) //First note in next line starts before this one ends
return false;
if (lineIndex < 0)
{
//Note is before ALL lines