Exemplo n.º 1
0
        private void InitializeVariables(Note[] firstRow)
        {
            notes = new Note[12][];

            notes[0] = firstRow
                .Select(x => Normalize(x, firstRow[0], firstRow[0] * 2))
                .ToArray();
            for (int i = 1; i < 12; i++)
            {
                notes[i] = new Note[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);
        }
Exemplo n.º 2
0
        private void Validate(Note[] 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");
            }
        }