Exemple #1
0
        public static Attributes CreateAttribute(AttributeProperties ai)
        {
            ObjectFactory factory    = new ObjectFactory();
            Attributes    attributes = factory.createAttributes();
            //create a key
            Key key = factory.createKey();
            //create a time element
            Time time = factory.createTime();
            //create a clef element
            Clef clef = factory.createClef();

            //set the staffs
            attributes.setStaves(new BigInteger(ai.staves.ToString()));


            //now add the elements to the attributes

            if (ai.divisions != 0)
            {
                //set the divisions
                attributes.setDivisions(new BigDecimal(ai.divisions));
            }
            if (ai.fifths != "")
            {
                //set the key
                key.setFifths(new BigInteger(ai.fifths));
                key.setMode(ai.mode);

                //add the key
                attributes.getKey().add(key);
            }
            if (ai.BeatsPerMeasure != "")
            {
                //set the time signature
                time.getTimeSignature().add(factory.createTimeBeats(ai.BeatsPerMeasure));
                time.getTimeSignature().add(factory.createTimeBeatType(ai.BeatType));

                // add the time signature
                attributes.getTime().add(time);
            }
            // add the cleff
            if (ai.ClefSign != "")
            {
                //set the clef
                clef.setSign(ClefSign.fromValue(ai.ClefSign));
                clef.setLine(new BigInteger(ai.ClefLine));
                clef.setNumber(new BigInteger(ai.ClefStaff.ToString()));

                attributes.getClef().add(clef);
            }
            return(attributes);
        }