Esempio n. 1
0
        /* Draw the accidental symbols.  If two symbols overlap (if they
         * are less than 6 notes apart), we cannot draw the symbol directly
         * above the previous one.  Instead, we must shift it to the right.
         * @param ytop The ylocation (in pixels) where the top of the staff starts.
         * @return The x pixel width used by all the accidentals.
         */
        public int DrawAccid(Graphics g, Pen pen, int ytop)
        {
            int xpos = 0;

            AccidSymbol prev = null;

            foreach (AccidSymbol symbol in accidsymbols)
            {
                if (prev != null && symbol.Note.Dist(prev.Note) < 6)
                {
                    xpos += symbol.Width;
                }
                g.TranslateTransform(xpos, 0);
                symbol.Draw(g, pen, ytop);
                g.TranslateTransform(-xpos, 0);
                prev = symbol;
            }
            if (prev != null)
            {
                xpos += prev.Width;
            }
            return(xpos);
        }
Esempio n. 2
0
        /* Return the minimum width needed to display this chord.
         *
         * The accidental symbols can be drawn above one another as long
         * as they don't overlap (they must be at least 6 notes apart).
         * If two accidental symbols do overlap, the accidental symbol
         * on top must be shifted to the right.  So the width needed for
         * accidental symbols depends on whether they overlap or not.
         *
         * If we are also displaying the letters, include extra width.
         */
        int GetMinWidth()
        {
            /* The width needed for the note circles */
            int result = 2 * SheetMusic.NoteHeight + SheetMusic.NoteHeight * 3 / 4;

            if (accidsymbols.Length > 0)
            {
                result += accidsymbols[0].MinWidth;
                for (int i = 1; i < accidsymbols.Length; i++)
                {
                    AccidSymbol accid = accidsymbols[i];
                    AccidSymbol prev  = accidsymbols[i - 1];
                    if (accid.Note.Dist(prev.Note) < 6)
                    {
                        result += accid.MinWidth;
                    }
                }
            }
            if (sheetmusic != null && sheetmusic.ShowNoteLetters != MidiOptions.NoteNameNone)
            {
                result += 8;
            }
            return(result);
        }
Esempio n. 3
0
        CreateAccidSymbols(NoteData[] notedata, Clef clef)
        {
            int count = 0;

            foreach (NoteData n in notedata)
            {
                if (n.accid != Accid.None)
                {
                    count++;
                }
            }
            AccidSymbol[] symbols = new AccidSymbol[count];
            int           i       = 0;

            foreach (NoteData n in notedata)
            {
                if (n.accid != Accid.None)
                {
                    symbols[i] = new AccidSymbol(n.accid, n.whitenote, clef);
                    i++;
                }
            }
            return(symbols);
        }
Esempio n. 4
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);
            }
        }
Esempio n. 5
0
 /** Given the note data (the white keys and accidentals), create
  * the Accidental Symbols and return them.
  */
 private static AccidSymbol[] CreateAccidSymbols(NoteData[] notedata, Clef clef)
 {
     int count = 0;
     foreach (NoteData n in notedata) {
     if (n.accid != Accid.None) {
         count++;
     }
     }
     AccidSymbol[] symbols = new AccidSymbol[count];
     int i = 0;
     foreach (NoteData n in notedata) {
     if (n.accid != Accid.None) {
         symbols[i] = new AccidSymbol(n.accid, n.whitenote, clef);
         i++;
     }
     }
     return symbols;
 }
Esempio n. 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);
            }
        }