/// <summary> /// stringIndex start from 1 and from down to up on guitar /// </summary> public string GetTuneAt(int stringIndex, int fretIndex) { if (stringIndex < 1 || stringIndex > STRING_LEN) { throw new ArgumentException("stringIndex. no string at specified index"); } if (fretIndex < 0 || fretIndex >= FRET_LEN) { throw new ArgumentException("fretIndex. too small or too large"); } return(MusicalAlphabet.At( StringAt(stringIndex).BaseToneIndex, fretIndex)); }
public Tuning(IEnumerable <int> toneIndexSource, string name) { if (toneIndexSource == null) { throw new ArgumentNullException("toneIndexSource"); } var toneIndex = this.toneIndex; using (var iterator = toneIndexSource.GetEnumerator()) { for (int i = 0; i < Guitar.STRING_LEN; i++) { if (!iterator.MoveNext()) { throw new ArgumentException("toneIndexSource. Incompleted"); } int index = iterator.Current; if (index < 0 || index >= MusicalAlphabet.LEN) { throw new ArgumentException( string.Format("toneIndexSource. invalid tone index at {0}", i)); } toneIndex[i] = index; } if (iterator.MoveNext()) { throw new ArgumentException("toneIndexSource. Too long"); } } this.BaseToneIndexes = toneIndex; this.BaseTones = toneIndex .Select(item => MusicalAlphabet.At(0, item)) .ToArray(); this.hashcode = checked (toneIndex .Select((_, i) => toneIndex.Take(i + 1).Sum() + i) .Sum()); this.name = string.IsNullOrEmpty(name) ? string.Join(null, this.BaseTones) : name; }