GetSymbols() public method

public GetSymbols ( Clef clef ) : MidiSheetMusic.AccidSymbol[]
clef Clef
return MidiSheetMusic.AccidSymbol[]
Ejemplo n.º 1
0
        KeySignatureWidth(KeySignature key)
        {
            ClefSymbol clefsym = new ClefSymbol(Clef.Treble, 0, false);
            int        result  = clefsym.MinWidth;

            AccidSymbol[] keys = key.GetSymbols(Clef.Treble);
            foreach (AccidSymbol symbol in keys)
            {
                result += symbol.MinWidth;
            }
            return(result + SheetMusic.LeftMargin + 5);
        }
Ejemplo n.º 2
0
        private int measureLength;          /** The time (in pulses) of a measure */

        /** Create a new staff with the given list of music symbols,
         * and the given key signature.  The clef is determined by
         * the clef of the first chord symbol. The track number is used
         * to determine whether to join this left/right vertical sides
         * with the staffs above and below. The SheetMusicOptions are used
         * to check whether to display measure numbers or not.
         */
        public Staff(List <MusicSymbol> symbols, KeySignature key,
                     MidiOptions options,
                     int tracknum, int totaltracks)
        {
            keysigWidth      = SheetMusic.KeySignatureWidth(key);
            this.tracknum    = tracknum;
            this.totaltracks = totaltracks;
            showMeasures     = (options.showMeasures && tracknum == 0);
            measureLength    = options.time.Measure;
            Clef clef = FindClef(symbols);

            clefsym      = new ClefSymbol(clef, 0, false);
            keys         = key.GetSymbols(clef);
            this.symbols = symbols;
            CalculateWidth(options.scrollVert);
            CalculateHeight();
            CalculateStartEndTime();
            FullJustify();
        }
Ejemplo n.º 3
0
        private int ytop; /** The y pixel of the top of the staff */

        #endregion Fields

        #region Constructors

        /** Create a new staff with the given list of music symbols,
         * and the given key signature.  The clef is determined by
         * the clef of the first chord symbol. The track number is used
         * to determine whether to join this left/right vertical sides
         * with the staffs above and below. The SheetMusicOptions are used
         * to check whether to display measure numbers or not.
         */
        public Staff(List<MusicSymbol> symbols, KeySignature key, 
                 MidiOptions options,
                 int tracknum, int totaltracks)
        {
            keysigWidth = SheetMusic.KeySignatureWidth(key);
            this.tracknum = tracknum;
            this.totaltracks = totaltracks;
            showMeasures = (options.showMeasures && tracknum == 0);
            measureLength = options.time.Measure;
            Clef clef = FindClef(symbols);

            clefsym = new ClefSymbol(clef, 0, false);
            keys = key.GetSymbols(clef);
            this.symbols = symbols;
            CalculateWidth(options.scrollVert);
            CalculateHeight();
            CalculateStartEndTime();
            FullJustify();
        }
Ejemplo n.º 4
0
 /** Get the width (in pixels) needed to display the key signature */
 public static int KeySignatureWidth(KeySignature key)
 {
     ClefSymbol clefsym = new ClefSymbol(Clef.Treble, 0, false);
     int result = clefsym.MinWidth;
     AccidSymbol[] keys = key.GetSymbols(Clef.Treble);
     foreach (AccidSymbol symbol in keys) {
     result += symbol.MinWidth;
     }
     return result + SheetMusic.LeftMargin + 5;
 }
Ejemplo n.º 5
0
    public void TestGetSymbols()
    {
        KeySignature k;
        AccidSymbol[] symbols1, symbols2;

        k = new KeySignature(0, 0);
        symbols1 = k.GetSymbols(Clef.Treble);
        symbols2 = k.GetSymbols(Clef.Bass);
        Assert.AreEqual(symbols1.Length, 0);
        Assert.AreEqual(symbols2.Length, 0);

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

        for (int sharp = 1; sharp < 7; sharp++) {
            k = new KeySignature(sharp, 0);
            symbols1 = k.GetSymbols(Clef.Treble);
            symbols2 = k.GetSymbols(Clef.Bass);
            for (int i = 0; i < sharp; i++) {
                Assert.AreEqual(symbols1[i].Note.Letter, sharps[i]);
                Assert.AreEqual(symbols2[i].Note.Letter, sharps[i]);
            }
        }

        int[] flats = new int[] {
            WhiteNote.B, WhiteNote.E, WhiteNote.A, WhiteNote.D,
            WhiteNote.G
        };

        for (int flat = 1; flat < 6; flat++) {
            k = new KeySignature(0, flat);
            symbols1 = k.GetSymbols(Clef.Treble);
            symbols2 = k.GetSymbols(Clef.Bass);
            for (int i = 0; i < flat; i++) {
                Assert.AreEqual(symbols1[i].Note.Letter, flats[i]);
                Assert.AreEqual(symbols2[i].Note.Letter, flats[i]);
            }
        }
    }