private void InitializeVariables(Tone[] firstRow) { notes = new Tone[12][]; notes[0] = firstRow .Select(x => Normalize(x, firstRow[0], firstRow[0] * 2)) .ToArray(); for (int i = 1; i < 12; i++) { notes[i] = new Tone[12]; } noteToOrdinal = notes[0] .OrderBy(x => (int)x) .Select((note, ordinal) => new { note, ordinal }) .ToDictionary(obj => obj.note, obj => obj.ordinal); ordinalToNote = noteToOrdinal .ToDictionary(x => x.Value, x => x.Key); }
private void Validate(Tone[] firstRow) { if (firstRow.Length != 12) { throw new ArgumentException("firstRow must have 12 tones"); } if (firstRow.Select(x => (int)x).Distinct().Count() != firstRow.Length) { throw new ArgumentException("row must not have repeated values"); } }