Inheritance: MusicSymbol
Beispiel #1
0
        RestSymbol[] GetRests(TimeSignature time, int start, int end)
        {
            RestSymbol[] result;
            RestSymbol   r1, r2;

            if (end - start < 0)
            {
                return(null);
            }

            NoteDuration dur = time.GetNoteDuration(end - start);

            switch (dur)
            {
            case NoteDuration.Whole:
            case NoteDuration.Half:
            case NoteDuration.Quarter:
            case NoteDuration.Eighth:
                r1     = new RestSymbol(start, dur);
                result = new RestSymbol[] { r1 };
                return(result);

            case NoteDuration.DottedHalf:
                r1 = new RestSymbol(start, NoteDuration.Half);
                r2 = new RestSymbol(start + time.Quarter * 2,
                                    NoteDuration.Quarter);
                result = new RestSymbol[] { r1, r2 };
                return(result);

            case NoteDuration.DottedQuarter:
                r1 = new RestSymbol(start, NoteDuration.Quarter);
                r2 = new RestSymbol(start + time.Quarter,
                                    NoteDuration.Eighth);
                result = new RestSymbol[] { r1, r2 };
                return(result);

            case NoteDuration.DottedEighth:
                r1 = new RestSymbol(start, NoteDuration.Eighth);
                r2 = new RestSymbol(start + time.Quarter / 2,
                                    NoteDuration.Sixteenth);
                result = new RestSymbol[] { r1, r2 };
                return(result);

            default:
                return(null);
            }
        }
Beispiel #2
0
        /** Return the rest symbols needed to fill the time interval between
         * start and end.  If no rests are needed, return nil.
         */
        private RestSymbol[] GetRests(TimeSignature time, int start, int end)
        {
            RestSymbol[] result;
            RestSymbol r1, r2;

            if (end - start < 0)
            return null;

            NoteDuration dur = time.GetNoteDuration(end - start);
            switch (dur) {
            case NoteDuration.Whole:
            case NoteDuration.Half:
            case NoteDuration.Quarter:
            case NoteDuration.Eighth:
                r1 = new RestSymbol(start, dur);
                result = new RestSymbol[]{ r1 };
                return result;

            case NoteDuration.DottedHalf:
                r1 = new RestSymbol(start, NoteDuration.Half);
                r2 = new RestSymbol(start + time.Quarter*2,
                                    NoteDuration.Quarter);
                result = new RestSymbol[]{ r1, r2 };
                return result;

            case NoteDuration.DottedQuarter:
                r1 = new RestSymbol(start, NoteDuration.Quarter);
                r2 = new RestSymbol(start + time.Quarter,
                                    NoteDuration.Eighth);
                result = new RestSymbol[]{ r1, r2 };
                return result;

            case NoteDuration.DottedEighth:
                r1 = new RestSymbol(start, NoteDuration.Eighth);
                r2 = new RestSymbol(start + time.Quarter/2,
                                    NoteDuration.Sixteenth);
                result = new RestSymbol[]{ r1, r2 };
                return result;

            default:
                return null;
            }
        }