private int[] adjustFrets(int[] frets)
{
int fretPadding = 0;
List<int> f = new List<int>(frets);
//remove frets < first note (sometimes there's a padding note at 0 which is not accurate)
while (f[0] < this.Notes.MinNoteOffsetSynced + _startPaddingMs)
f.RemoveAt(0);
//add frets from 0 to start of frets
int fretLen = 0; //first fret length
if (f.Count > 1 && f[1] - f[0] < f[0])
{
fretLen = f[1] - f[0];
int x = f[0] - fretLen;
do
{
f.Insert(0, x);
x -= fretLen;
}
while (x > 0);
}
//do we need to pad the frets to get a position of 0 (as in, move frets back so that we can have a natural fret at time 0)
int maxNote = this.Notes.MaxNoteOffsetSynced + _startPaddingMs;
//HACK - NOTESONLY
//int maxNote = this.Length - 1500;
if (f.Count > 1)
{
int l = f[f.Count - 1] - f[f.Count - 2];
while (f[f.Count - 1] < maxNote)
f.Add(f[f.Count - 1] + l);
}
//remove frets that are after the end of the audio but at least 1 after the last note and length
while (f.Count != 0 && f[f.Count - 1] > this.Length && f[f.Count - 2] > maxNote)
f.RemoveAt(f.Count - 1);
//do we need to pad the frets to get a position of 0
if (f.Count > 1 && f[0] != 0)
{
fretPadding = fretLen - f[0];
for (int i = 0; i < f.Count; i++)
f[i] += fretPadding;
f.Insert(0, 0); //insert 0 fret
}
_fretPadding = fretPadding;
return f.ToArray();
}