some performance changes in CNotes.cs (thx to rayo)
This commit is contained in:
1 parent
3420cc0972
commit
ee70a8fa6b
1 file changed
+36
-30
+36
-30
@@ -245,6 +245,8 @@ namespace Vocaluxe.Lib.Song
|
|||||||
private int _EndBeat;
|
private int _EndBeat;
|
||||||
private bool _PerfectLine; // for drawing perfect line effect
|
private bool _PerfectLine; // for drawing perfect line effect
|
||||||
|
|
||||||
|
private int _MinBeat = int.MaxValue;
|
||||||
|
private int _MaxBeat = int.MinValue;
|
||||||
private List<CNote> _Notes;
|
private List<CNote> _Notes;
|
||||||
|
|
||||||
#region Constructors
|
#region Constructors
|
||||||
@@ -263,14 +265,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
get { return _StartBeat; }
|
get { return _StartBeat; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
int min = int.MaxValue;
|
if (value <= _MinBeat)
|
||||||
foreach (CNote note in _Notes)
|
|
||||||
{
|
|
||||||
if (note.StartBeat < min)
|
|
||||||
min = note.StartBeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value <= min)
|
|
||||||
_StartBeat = value;
|
_StartBeat = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -280,14 +275,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
get { return _EndBeat; }
|
get { return _EndBeat; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
int max = int.MinValue;
|
if (value >= _MaxBeat)
|
||||||
foreach (CNote note in _Notes)
|
|
||||||
{
|
|
||||||
if (note.EndBeat > max)
|
|
||||||
max = note.EndBeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value >= max)
|
|
||||||
_EndBeat = value;
|
_EndBeat = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,13 +290,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int Result = int.MaxValue;
|
return _MinBeat;
|
||||||
foreach (CNote note in _Notes)
|
|
||||||
{
|
|
||||||
if (note.StartBeat < Result)
|
|
||||||
Result = note.StartBeat;
|
|
||||||
}
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,13 +298,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int Result = int.MinValue;
|
return _MaxBeat;
|
||||||
foreach (CNote note in _Notes)
|
|
||||||
{
|
|
||||||
if (note.EndBeat > Result)
|
|
||||||
Result = note.EndBeat;
|
|
||||||
}
|
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +405,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
public void AddNote(CNote Note)
|
public void AddNote(CNote Note)
|
||||||
{
|
{
|
||||||
_Notes.Add(Note);
|
_Notes.Add(Note);
|
||||||
|
updateMinMaxBeat(Note);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool InsertNote(CNote Note, int Index)
|
public bool InsertNote(CNote Note, int Index)
|
||||||
@@ -436,6 +413,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
if (_Notes.Count >= Index)
|
if (_Notes.Count >= Index)
|
||||||
{
|
{
|
||||||
_Notes.Insert(Index, Note);
|
_Notes.Insert(Index, Note);
|
||||||
|
updateMinMaxBeat(Note);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -446,6 +424,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
if (_Notes.Count > Index)
|
if (_Notes.Count > Index)
|
||||||
{
|
{
|
||||||
_Notes.RemoveAt(Index);
|
_Notes.RemoveAt(Index);
|
||||||
|
updateMinMaxBeat();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -457,6 +436,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
{
|
{
|
||||||
_Notes.RemoveAt(Index);
|
_Notes.RemoveAt(Index);
|
||||||
_Notes.Insert(Index, Note);
|
_Notes.Insert(Index, Note);
|
||||||
|
updateMinMaxBeat();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -467,6 +447,7 @@ namespace Vocaluxe.Lib.Song
|
|||||||
if (_Notes.Count > 0)
|
if (_Notes.Count > 0)
|
||||||
{
|
{
|
||||||
_Notes[_Notes.Count - 1].Duration++;
|
_Notes[_Notes.Count - 1].Duration++;
|
||||||
|
updateMinMaxBeat();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -474,6 +455,31 @@ namespace Vocaluxe.Lib.Song
|
|||||||
public void DeleteAllNotes()
|
public void DeleteAllNotes()
|
||||||
{
|
{
|
||||||
_Notes.Clear();
|
_Notes.Clear();
|
||||||
|
_MinBeat = int.MaxValue;
|
||||||
|
_MaxBeat = int.MinValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMinMaxBeat(CNote Note)
|
||||||
|
{
|
||||||
|
if (Note.StartBeat < _MinBeat)
|
||||||
|
{
|
||||||
|
_MinBeat = Note.StartBeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Note.EndBeat > _MaxBeat)
|
||||||
|
{
|
||||||
|
_MaxBeat = Note.EndBeat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateMinMaxBeat()
|
||||||
|
{
|
||||||
|
_MinBeat = int.MaxValue;
|
||||||
|
_MaxBeat = int.MinValue;
|
||||||
|
foreach (CNote note in _Notes)
|
||||||
|
{
|
||||||
|
updateMinMaxBeat(note);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion Methods
|
#endregion Methods
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user