Beispiel #1
0
        private int width;           /** Width of symbol */

        /**
         * Create a new AccidSymbol with the given accidental, that is
         * displayed at the given note in the given clef.
         */
        public AccidSymbol(Accid accid, WhiteNote note, Clef clef)
        {
            this.accid     = accid;
            this.whitenote = note;
            this.clef      = clef;
            width          = MinWidth;
        }
        private int width; /** Width of symbol */

        #endregion Fields

        #region Constructors

        /**
         * Create a new AccidSymbol with the given accidental, that is
         * displayed at the given note in the given clef.
         */
        public AccidSymbol(Accid accid, WhiteNote note, Clef clef)
        {
            this.accid = accid;
            this.whitenote = note;
            this.clef = clef;
            width = MinWidth;
        }
        /** Given a midi note number, return the accidental (if any)
         * that should be used when displaying the note in this key signature.
         *
         * The current measure is also required.  Once we return an
         * accidental for a measure, the accidental remains for the
         * rest of the measure. So we must update the current keymap
         * with any new accidentals that we return.  When we move to another
         * measure, we reset the keymap back to the key signature.
         */
        public Accid GetAccidental(int notenumber, int measure)
        {
            if (measure != prevmeasure)
            {
                ResetKeyMap();
                prevmeasure = measure;
            }

            Accid result = keymap[notenumber];

            if (result == Accid.Sharp)
            {
                keymap[notenumber]     = Accid.None;
                keymap[notenumber - 1] = Accid.Natural;
            }
            else if (result == Accid.Flat)
            {
                keymap[notenumber]     = Accid.None;
                keymap[notenumber + 1] = Accid.Natural;
            }
            else if (result == Accid.Natural)
            {
                keymap[notenumber] = Accid.None;
                int nextkey = NoteScale.FromNumber(notenumber + 1);
                int prevkey = NoteScale.FromNumber(notenumber - 1);

                /* If we insert a natural, then either:
                 * - the next key must go back to sharp,
                 * - the previous key must go back to flat.
                 */
                if (notenumber > 0)
                {
                    if (keymap[notenumber - 1] == Accid.None && keymap[notenumber + 1] == Accid.None &&
                        NoteScale.IsBlackKey(nextkey) && NoteScale.IsBlackKey(prevkey))
                    {
                        if (num_flats == 0)
                        {
                            keymap[notenumber + 1] = Accid.Sharp;
                        }
                        else
                        {
                            keymap[notenumber - 1] = Accid.Flat;
                        }
                    }
                    else if (keymap[notenumber - 1] == Accid.None && NoteScale.IsBlackKey(prevkey))
                    {
                        keymap[notenumber - 1] = Accid.Flat;
                    }
                    else if (keymap[notenumber + 1] == Accid.None && NoteScale.IsBlackKey(nextkey))
                    {
                        keymap[notenumber + 1] = Accid.Sharp;
                    }
                    else
                    {
                        /* Shouldn't get here */
                    }
                }
            }
            return(result);
        }
        /// <summary>
        /// Add properties to Accidental
        /// </summary>
        /// <param name="_accidobj">Empty accidental object</param>
        /// <param name="_accid">MEI accid element</param>
        /// <returns></returns>
        public static Accidental ConvertAccidental(Accidental _accidobj, Accid _accid)
        {
            _accidobj.AccidentalPosition = GetPosition(_accid);
            _accidobj.AccidentalType     = GetAccidentalType(_accid);
            _accidobj.PitchLocation      = GetAccidPitchLoc(_accid);

            return(_accidobj);
        }
Beispiel #5
0
        /** Given a midi note number, return the white note (the
         * non-sharp/non-flat note) that should be used when displaying
         * this note in this key signature.  This should be called
         * before calling GetAccidental().
         */
        public WhiteNote GetWhiteNote(int notenumber)
        {
            int notescale = NoteScale.FromNumber(notenumber);
            int octave    = (notenumber + 3) / 12 - 1;
            int letter    = 0;

            int[] whole_sharps =
            {
                WhiteNote.A, WhiteNote.A,
                WhiteNote.B,
                WhiteNote.C, WhiteNote.C,
                WhiteNote.D, WhiteNote.D,
                WhiteNote.E,
                WhiteNote.F, WhiteNote.F,
                WhiteNote.G, WhiteNote.G
            };

            int[] whole_flats =
            {
                WhiteNote.A,
                WhiteNote.B,WhiteNote.B,
                WhiteNote.C,
                WhiteNote.D,WhiteNote.D,
                WhiteNote.E,WhiteNote.E,
                WhiteNote.F,
                WhiteNote.G,WhiteNote.G,
                WhiteNote.A
            };

            Accid accid = keymap[notenumber];

            if (accid == Accid.Flat)
            {
                letter = whole_flats[notescale];
            }
            else if (accid == Accid.Sharp)
            {
                letter = whole_sharps[notescale];
            }
            else if (accid == Accid.Natural)
            {
                letter = whole_sharps[notescale];
            }
            else if (accid == Accid.None)
            {
                letter = whole_sharps[notescale];

                /* If the note number is a sharp/flat, and there's no accidental,
                 * determine the white note by seeing whether the previous or next note
                 * is a natural.
                 */
                if (NoteScale.IsBlackKey(notescale))
                {
                    if (keymap[notenumber - 1] == Accid.Natural &&
                        keymap[notenumber + 1] == Accid.Natural)
                    {
                        if (num_flats > 0)
                        {
                            letter = whole_flats[notescale];
                        }
                        else
                        {
                            letter = whole_sharps[notescale];
                        }
                    }
                    else if (keymap[notenumber - 1] == Accid.Natural)
                    {
                        letter = whole_sharps[notescale];
                    }
                    else if (keymap[notenumber + 1] == Accid.Natural)
                    {
                        letter = whole_flats[notescale];
                    }
                }
            }

            /* The above algorithm doesn't quite work for G-flat major.
             * Handle it here.
             */
            if (num_flats == Gflat && notescale == NoteScale.B)
            {
                letter = WhiteNote.C;
            }
            if (num_flats == Gflat && notescale == NoteScale.Bflat)
            {
                letter = WhiteNote.B;
            }

            if (num_flats > 0 && notescale == NoteScale.Aflat)
            {
                octave++;
            }

            return(new WhiteNote(letter, octave));
        }
Beispiel #6
0
        /** Create the Accidental symbols for this key, for
         * the treble and bass clefs.
         */
        private void CreateSymbols()
        {
            int count = Math.Max(num_sharps, num_flats);

            treble = new AccidSymbol[count];
            bass   = new AccidSymbol[count];

            if (count == 0)
            {
                return;
            }

            WhiteNote[] treblenotes = null;
            WhiteNote[] bassnotes   = null;

            if (num_sharps > 0)
            {
                treblenotes = new WhiteNote[] {
                    new WhiteNote(WhiteNote.F, 5),
                    new WhiteNote(WhiteNote.C, 5),
                    new WhiteNote(WhiteNote.G, 5),
                    new WhiteNote(WhiteNote.D, 5),
                    new WhiteNote(WhiteNote.A, 6),
                    new WhiteNote(WhiteNote.E, 5)
                };
                bassnotes = new WhiteNote[] {
                    new WhiteNote(WhiteNote.F, 3),
                    new WhiteNote(WhiteNote.C, 3),
                    new WhiteNote(WhiteNote.G, 3),
                    new WhiteNote(WhiteNote.D, 3),
                    new WhiteNote(WhiteNote.A, 4),
                    new WhiteNote(WhiteNote.E, 3)
                };
            }
            else if (num_flats > 0)
            {
                treblenotes = new WhiteNote[] {
                    new WhiteNote(WhiteNote.B, 5),
                    new WhiteNote(WhiteNote.E, 5),
                    new WhiteNote(WhiteNote.A, 5),
                    new WhiteNote(WhiteNote.D, 5),
                    new WhiteNote(WhiteNote.G, 4),
                    new WhiteNote(WhiteNote.C, 5)
                };
                bassnotes = new WhiteNote[] {
                    new WhiteNote(WhiteNote.B, 3),
                    new WhiteNote(WhiteNote.E, 3),
                    new WhiteNote(WhiteNote.A, 3),
                    new WhiteNote(WhiteNote.D, 3),
                    new WhiteNote(WhiteNote.G, 2),
                    new WhiteNote(WhiteNote.C, 3)
                };
            }

            Accid a = Accid.None;

            if (num_sharps > 0)
            {
                a = Accid.Sharp;
            }
            else
            {
                a = Accid.Flat;
            }

            for (int i = 0; i < count; i++)
            {
                treble[i] = new AccidSymbol(a, treblenotes[i], Clef.Treble);
                bass[i]   = new AccidSymbol(a, bassnotes[i], Clef.Bass);
            }
        }
Beispiel #7
0
        /** Iniitalize the sharpkeys and flatkeys maps */
        private static void CreateAccidentalMaps()
        {
            if (sharpkeys != null)
            {
                return;
            }

            Accid[] map;
            sharpkeys = new Accid[8][];
            flatkeys  = new Accid[8][];

            for (int i = 0; i < 8; i++)
            {
                sharpkeys[i] = new Accid[12];
                flatkeys[i]  = new Accid[12];
            }

            map = sharpkeys[C];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Asharp] = Accid.Flat;
            map[NoteScale.B]      = Accid.None;
            map[NoteScale.C]      = Accid.None;
            map[NoteScale.Csharp] = Accid.Sharp;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Dsharp] = Accid.Sharp;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.None;
            map[NoteScale.Fsharp] = Accid.Sharp;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Gsharp] = Accid.Sharp;

            map = sharpkeys[G];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Asharp] = Accid.Flat;
            map[NoteScale.B]      = Accid.None;
            map[NoteScale.C]      = Accid.None;
            map[NoteScale.Csharp] = Accid.Sharp;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Dsharp] = Accid.Sharp;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.Natural;
            map[NoteScale.Fsharp] = Accid.None;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Gsharp] = Accid.Sharp;

            map = sharpkeys[D];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Asharp] = Accid.Flat;
            map[NoteScale.B]      = Accid.None;
            map[NoteScale.C]      = Accid.Natural;
            map[NoteScale.Csharp] = Accid.None;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Dsharp] = Accid.Sharp;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.Natural;
            map[NoteScale.Fsharp] = Accid.None;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Gsharp] = Accid.Sharp;

            map = sharpkeys[A];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Asharp] = Accid.Flat;
            map[NoteScale.B]      = Accid.None;
            map[NoteScale.C]      = Accid.Natural;
            map[NoteScale.Csharp] = Accid.None;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Dsharp] = Accid.Sharp;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.Natural;
            map[NoteScale.Fsharp] = Accid.None;
            map[NoteScale.G]      = Accid.Natural;
            map[NoteScale.Gsharp] = Accid.None;

            map = sharpkeys[E];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Asharp] = Accid.Flat;
            map[NoteScale.B]      = Accid.None;
            map[NoteScale.C]      = Accid.Natural;
            map[NoteScale.Csharp] = Accid.None;
            map[NoteScale.D]      = Accid.Natural;
            map[NoteScale.Dsharp] = Accid.None;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.Natural;
            map[NoteScale.Fsharp] = Accid.None;
            map[NoteScale.G]      = Accid.Natural;
            map[NoteScale.Gsharp] = Accid.None;

            map = sharpkeys[B];
            map[NoteScale.A]      = Accid.Natural;
            map[NoteScale.Asharp] = Accid.None;
            map[NoteScale.B]      = Accid.None;
            map[NoteScale.C]      = Accid.Natural;
            map[NoteScale.Csharp] = Accid.None;
            map[NoteScale.D]      = Accid.Natural;
            map[NoteScale.Dsharp] = Accid.None;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.Natural;
            map[NoteScale.Fsharp] = Accid.None;
            map[NoteScale.G]      = Accid.Natural;
            map[NoteScale.Gsharp] = Accid.None;

            /* Flat keys */
            map = flatkeys[C];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Asharp] = Accid.Flat;
            map[NoteScale.B]      = Accid.None;
            map[NoteScale.C]      = Accid.None;
            map[NoteScale.Csharp] = Accid.Sharp;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Dsharp] = Accid.Sharp;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.None;
            map[NoteScale.Fsharp] = Accid.Sharp;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Gsharp] = Accid.Sharp;

            map = flatkeys[F];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Bflat]  = Accid.None;
            map[NoteScale.B]      = Accid.Natural;
            map[NoteScale.C]      = Accid.None;
            map[NoteScale.Csharp] = Accid.Sharp;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Eflat]  = Accid.Flat;
            map[NoteScale.E]      = Accid.None;
            map[NoteScale.F]      = Accid.None;
            map[NoteScale.Fsharp] = Accid.Sharp;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Aflat]  = Accid.Flat;

            map = flatkeys[Bflat];
            map[NoteScale.A]      = Accid.None;
            map[NoteScale.Bflat]  = Accid.None;
            map[NoteScale.B]      = Accid.Natural;
            map[NoteScale.C]      = Accid.None;
            map[NoteScale.Csharp] = Accid.Sharp;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Eflat]  = Accid.None;
            map[NoteScale.E]      = Accid.Natural;
            map[NoteScale.F]      = Accid.None;
            map[NoteScale.Fsharp] = Accid.Sharp;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Aflat]  = Accid.Flat;

            map = flatkeys[Eflat];
            map[NoteScale.A]      = Accid.Natural;
            map[NoteScale.Bflat]  = Accid.None;
            map[NoteScale.B]      = Accid.Natural;
            map[NoteScale.C]      = Accid.None;
            map[NoteScale.Dflat]  = Accid.Flat;
            map[NoteScale.D]      = Accid.None;
            map[NoteScale.Eflat]  = Accid.None;
            map[NoteScale.E]      = Accid.Natural;
            map[NoteScale.F]      = Accid.None;
            map[NoteScale.Fsharp] = Accid.Sharp;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Aflat]  = Accid.None;

            map = flatkeys[Aflat];
            map[NoteScale.A]      = Accid.Natural;
            map[NoteScale.Bflat]  = Accid.None;
            map[NoteScale.B]      = Accid.Natural;
            map[NoteScale.C]      = Accid.None;
            map[NoteScale.Dflat]  = Accid.None;
            map[NoteScale.D]      = Accid.Natural;
            map[NoteScale.Eflat]  = Accid.None;
            map[NoteScale.E]      = Accid.Natural;
            map[NoteScale.F]      = Accid.None;
            map[NoteScale.Fsharp] = Accid.Sharp;
            map[NoteScale.G]      = Accid.None;
            map[NoteScale.Aflat]  = Accid.None;

            map = flatkeys[Dflat];
            map[NoteScale.A]     = Accid.Natural;
            map[NoteScale.Bflat] = Accid.None;
            map[NoteScale.B]     = Accid.Natural;
            map[NoteScale.C]     = Accid.None;
            map[NoteScale.Dflat] = Accid.None;
            map[NoteScale.D]     = Accid.Natural;
            map[NoteScale.Eflat] = Accid.None;
            map[NoteScale.E]     = Accid.Natural;
            map[NoteScale.F]     = Accid.None;
            map[NoteScale.Gflat] = Accid.None;
            map[NoteScale.G]     = Accid.Natural;
            map[NoteScale.Aflat] = Accid.None;

            map = flatkeys[Gflat];
            map[NoteScale.A]     = Accid.Natural;
            map[NoteScale.Bflat] = Accid.None;
            map[NoteScale.B]     = Accid.None;
            map[NoteScale.C]     = Accid.Natural;
            map[NoteScale.Dflat] = Accid.None;
            map[NoteScale.D]     = Accid.Natural;
            map[NoteScale.Eflat] = Accid.None;
            map[NoteScale.E]     = Accid.Natural;
            map[NoteScale.F]     = Accid.None;
            map[NoteScale.Gflat] = Accid.None;
            map[NoteScale.G]     = Accid.Natural;
            map[NoteScale.Aflat] = Accid.None;
        }
 /// <summary>
 /// Gets base-40 pitch location for accid element
 /// </summary>
 /// <param name="_accid">MEI accid</param>
 /// <returns>Base-40 int</returns>
 private static int GetAccidPitchLoc(Accid _accid)
 {
     return(ConverterHelper.ConvertToBase40(_accid.GetPlocValue(), _accid.GetOlocValue()));
 }
 /// <summary>
 /// Reads @mse:accidPos
 /// </summary>
 /// <param name="_accid">MEI accid element</param>
 /// <returns>Position</returns>
 private static Position GetPosition(Accid _accid)
 {
     Enum.TryParse(_accid.GetAccidPosValue(), true, out Position pos);
     return(pos);
 }
Beispiel #10
0
    public void TestGetAccidental()
    {
        int measure = 1;
        KeySignature k;
        Accid[] expected = new Accid[12];
        for (int i = 0; i < 12; i++) {
            expected[i] = Accid.None;
        }
        expected[NoteScale.Bflat]  = Accid.Flat;
        expected[NoteScale.Csharp] = Accid.Sharp;
        expected[NoteScale.Dsharp] = Accid.Sharp;
        expected[NoteScale.Fsharp] = Accid.Sharp;
        expected[NoteScale.Gsharp] = Accid.Sharp;

        /* Test C Major */
        k = new KeySignature(0, 0);
        measure = 1;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test G major, F# */
        k = new KeySignature(1, 0);
        measure = 1;
        expected[NoteScale.Fsharp] = Accid.None;
        expected[NoteScale.F] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test D major, F#, C# */
        k = new KeySignature(2, 0);
        measure = 1;
        expected[NoteScale.Csharp] = Accid.None;
        expected[NoteScale.C] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test A major, F#, C#, G# */
        k = new KeySignature(3, 0);
        measure = 1;
        expected[NoteScale.Gsharp] = Accid.None;
        expected[NoteScale.G] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test E major, F#, C#, G#, D# */
        k = new KeySignature(4, 0);
        measure = 1;
        expected[NoteScale.Dsharp] = Accid.None;
        expected[NoteScale.D] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test B major, F#, C#, G#, D#, A# */
        k = new KeySignature(5, 0);
        measure = 1;
        expected[NoteScale.Asharp] = Accid.None;
        expected[NoteScale.A] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        for (int i = 0; i < 12; i++) {
            expected[i] = Accid.None;
        }
        expected[NoteScale.Aflat]  = Accid.Flat;
        expected[NoteScale.Bflat]  = Accid.Flat;
        expected[NoteScale.Csharp] = Accid.Sharp;
        expected[NoteScale.Eflat]  = Accid.Flat;
        expected[NoteScale.Fsharp] = Accid.Sharp;

        /* Test F major, Bflat */
        k = new KeySignature(0, 1);
        measure = 1;
        expected[NoteScale.Bflat] = Accid.None;
        expected[NoteScale.B] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test Bflat major, Bflat, Eflat */
        k = new KeySignature(0, 2);
        measure = 1;
        expected[NoteScale.Eflat] = Accid.None;
        expected[NoteScale.E] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test Eflat major, Bflat, Eflat, Afat */
        k = new KeySignature(0, 3);
        measure = 1;
        expected[NoteScale.Aflat] = Accid.None;
        expected[NoteScale.A] = Accid.Natural;
        expected[NoteScale.Dflat] = Accid.Flat;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test Aflat major, Bflat, Eflat, Aflat, Dflat */
        k = new KeySignature(0, 4);
        measure = 1;
        expected[NoteScale.Dflat] = Accid.None;
        expected[NoteScale.D] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }

        /* Test Dflat major, Bflat, Eflat, Aflat, Dflat, Gflat */
        k = new KeySignature(0, 5);
        measure = 1;
        expected[NoteScale.Gflat] = Accid.None;
        expected[NoteScale.G] = Accid.Natural;
        for (int note = 1; note < 128; note++) {
            int notescale = NoteScale.FromNumber(note);
            Assert.AreEqual(expected[notescale],
                          k.GetAccidental(note, measure));
            measure++;
        }
    }
        /** Iniitalize the sharpkeys and flatkeys maps */
        private static void CreateAccidentalMaps()
        {
            if (sharpkeys != null)
            return;

            Accid[] map;
            sharpkeys = new Accid[8][];
            flatkeys = new Accid[8][];

            for (int i = 0; i < 8; i++) {
            sharpkeys[i] = new Accid[12];
            flatkeys[i] = new Accid[12];
            }

            map = sharpkeys[C];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Asharp ] = Accid.Flat;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Csharp ] = Accid.Sharp;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Dsharp ] = Accid.Sharp;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Fsharp ] = Accid.Sharp;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Gsharp ] = Accid.Sharp;

            map = sharpkeys[G];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Asharp ] = Accid.Flat;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Csharp ] = Accid.Sharp;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Dsharp ] = Accid.Sharp;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.Natural;
            map[ NoteScale.Fsharp ] = Accid.None;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Gsharp ] = Accid.Sharp;

            map = sharpkeys[D];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Asharp ] = Accid.Flat;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.Natural;
            map[ NoteScale.Csharp ] = Accid.None;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Dsharp ] = Accid.Sharp;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.Natural;
            map[ NoteScale.Fsharp ] = Accid.None;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Gsharp ] = Accid.Sharp;

            map = sharpkeys[A];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Asharp ] = Accid.Flat;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.Natural;
            map[ NoteScale.Csharp ] = Accid.None;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Dsharp ] = Accid.Sharp;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.Natural;
            map[ NoteScale.Fsharp ] = Accid.None;
            map[ NoteScale.G ]      = Accid.Natural;
            map[ NoteScale.Gsharp ] = Accid.None;

            map = sharpkeys[E];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Asharp ] = Accid.Flat;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.Natural;
            map[ NoteScale.Csharp ] = Accid.None;
            map[ NoteScale.D ]      = Accid.Natural;
            map[ NoteScale.Dsharp ] = Accid.None;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.Natural;
            map[ NoteScale.Fsharp ] = Accid.None;
            map[ NoteScale.G ]      = Accid.Natural;
            map[ NoteScale.Gsharp ] = Accid.None;

            map = sharpkeys[B];
            map[ NoteScale.A ]      = Accid.Natural;
            map[ NoteScale.Asharp ] = Accid.None;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.Natural;
            map[ NoteScale.Csharp ] = Accid.None;
            map[ NoteScale.D ]      = Accid.Natural;
            map[ NoteScale.Dsharp ] = Accid.None;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.Natural;
            map[ NoteScale.Fsharp ] = Accid.None;
            map[ NoteScale.G ]      = Accid.Natural;
            map[ NoteScale.Gsharp ] = Accid.None;

            /* Flat keys */
            map = flatkeys[C];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Asharp ] = Accid.Flat;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Csharp ] = Accid.Sharp;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Dsharp ] = Accid.Sharp;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Fsharp ] = Accid.Sharp;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Gsharp ] = Accid.Sharp;

            map = flatkeys[F];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Bflat ]  = Accid.None;
            map[ NoteScale.B ]      = Accid.Natural;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Csharp ] = Accid.Sharp;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Eflat ]  = Accid.Flat;
            map[ NoteScale.E ]      = Accid.None;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Fsharp ] = Accid.Sharp;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Aflat ]  = Accid.Flat;

            map = flatkeys[Bflat];
            map[ NoteScale.A ]      = Accid.None;
            map[ NoteScale.Bflat ]  = Accid.None;
            map[ NoteScale.B ]      = Accid.Natural;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Csharp ] = Accid.Sharp;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Eflat ]  = Accid.None;
            map[ NoteScale.E ]      = Accid.Natural;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Fsharp ] = Accid.Sharp;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Aflat ]  = Accid.Flat;

            map = flatkeys[Eflat];
            map[ NoteScale.A ]      = Accid.Natural;
            map[ NoteScale.Bflat ]  = Accid.None;
            map[ NoteScale.B ]      = Accid.Natural;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Dflat ]  = Accid.Flat;
            map[ NoteScale.D ]      = Accid.None;
            map[ NoteScale.Eflat ]  = Accid.None;
            map[ NoteScale.E ]      = Accid.Natural;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Fsharp ] = Accid.Sharp;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Aflat ]  = Accid.None;

            map = flatkeys[Aflat];
            map[ NoteScale.A ]      = Accid.Natural;
            map[ NoteScale.Bflat ]  = Accid.None;
            map[ NoteScale.B ]      = Accid.Natural;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Dflat ]  = Accid.None;
            map[ NoteScale.D ]      = Accid.Natural;
            map[ NoteScale.Eflat ]  = Accid.None;
            map[ NoteScale.E ]      = Accid.Natural;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Fsharp ] = Accid.Sharp;
            map[ NoteScale.G ]      = Accid.None;
            map[ NoteScale.Aflat ]  = Accid.None;

            map = flatkeys[Dflat];
            map[ NoteScale.A ]      = Accid.Natural;
            map[ NoteScale.Bflat ]  = Accid.None;
            map[ NoteScale.B ]      = Accid.Natural;
            map[ NoteScale.C ]      = Accid.None;
            map[ NoteScale.Dflat ]  = Accid.None;
            map[ NoteScale.D ]      = Accid.Natural;
            map[ NoteScale.Eflat ]  = Accid.None;
            map[ NoteScale.E ]      = Accid.Natural;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Gflat ]  = Accid.None;
            map[ NoteScale.G ]      = Accid.Natural;
            map[ NoteScale.Aflat ]  = Accid.None;

            map = flatkeys[Gflat];
            map[ NoteScale.A ]      = Accid.Natural;
            map[ NoteScale.Bflat ]  = Accid.None;
            map[ NoteScale.B ]      = Accid.None;
            map[ NoteScale.C ]      = Accid.Natural;
            map[ NoteScale.Dflat ]  = Accid.None;
            map[ NoteScale.D ]      = Accid.Natural;
            map[ NoteScale.Eflat ]  = Accid.None;
            map[ NoteScale.E ]      = Accid.Natural;
            map[ NoteScale.F ]      = Accid.None;
            map[ NoteScale.Gflat ]  = Accid.None;
            map[ NoteScale.G ]      = Accid.Natural;
            map[ NoteScale.Aflat ]  = Accid.None;
        }