private int FindStringForValue(Track track, Beat beat, int value)
{
// find strings which are already taken
var takenStrings = new FastDictionary<int, bool>();
for (int i = 0; i < beat.Notes.Count; i++)
{
var note = beat.Notes[i];
takenStrings[note.String] = true;
}
// find a string where the note matches into 0 to <upperbound>
// first try to find a string from 0-14 (more handy to play)
// then try from 0-20 (guitars with high frets)
// then unlimited
int[] steps = { 14, 20, int.MaxValue };
for (int i = 0; i < steps.Length; i++)
{
for (int j = 0; j < track.Tuning.Length; j++)
{
if (!takenStrings.ContainsKey(j))
{
var min = track.Tuning[j];
var max = track.Tuning[j] + steps[i];
if (value >= min && value <= max)
{
return track.Tuning.Length - j;
}
}
}
}
// will not happen
return 1;
}